Top Description Fields Constructors Methods
io.vertx.core

public abstract Class AbstractVerticle

extends Object
implements Verticle
Class Inheritance
All Implemented Interfaces
io.vertx.core.Verticle
Known Direct Subclasses
examples.ConfigurableVerticleExamples, examples.CoreExamples.MyVerticle
Imports
io.vertx.core.json.JsonObject, java.util.List

An abstract base class that you can extend to write your own Verticle classes.

Instead of implementing io.vertx.core.Verticle directly, it is often simpler to just extend this class.

In the simplest case, just override the start(Promise) method. If you have verticle clean-up to do you can optionally override the stop(Promise) method too.

If your verticle does extra start-up or clean-up that takes some time (e.g. it deploys other verticles) then you should override the asynchronous start and stop methods.

This class also maintains references to the io.vertx.core.Vertx and io.vertx.core.Context instances of the verticle for easy access.

It also provides methods for getting the verticle configuration, process arguments, and deployment ID.

Author
Tim Fox

Field Summary

Modifier and TypeField and Description
protected Context
context

Reference to the context of the verticle

protected Vertx
vertx

Reference to the Vert.x instance that deployed this verticle

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public JsonObject

Returns:

the configuration
config
()
References Deprecated JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

Get the configuration of the verticle.

public String

Returns:

the deployment ID
deploymentID
()

Get the deployment ID of the verticle deployment

public Vertx

Returns:

the Vert.x instance
getVertx
()

Implements io.vertx.core.Verticle.getVertx.

Get the Vert.x instance

public void
init(Vertx
the deploying Vert.x instance
vertx
,
Context
the context of the verticle
context
)

Implements io.vertx.core.Verticle.init.

Initialise the verticle.

public List<String>

Returns:

the list of arguments
processArgs
()

Get the arguments used when deploying the Vert.x process.

public void
start(Promise<Void>
a promise which should be called when verticle start-up is complete.
startPromise
)

Implements io.vertx.core.Verticle.start.

Start the verticle.

public void
start()

If your verticle does a simple, synchronous start-up then override this method and put your start-up code in here.

public void
stop(Promise<Void>
a promise which should be called when verticle clean-up is complete.
stopPromise
)

Implements io.vertx.core.Verticle.stop.

Stop the verticle.

public void
stop()

If your verticle has simple synchronous clean-up tasks to complete then override this method and put your clean-up code in here.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contextback to summary
protected Context context

Reference to the context of the verticle

vertxback to summary
protected Vertx vertx

Reference to the Vert.x instance that deployed this verticle

Constructor Detail

AbstractVerticleback to summary
public AbstractVerticle()

Method Detail

configback to summary
public JsonObject config()

References Deprecated

JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Get the configuration of the verticle.

This can be specified when the verticle is deployed.

Returns:JsonObject

the configuration

deploymentIDback to summary
public String deploymentID()

Get the deployment ID of the verticle deployment

Returns:String

the deployment ID

getVertxback to summary
public Vertx getVertx()

Implements io.vertx.core.Verticle.getVertx.

Get the Vert.x instance

Returns:Vertx

the Vert.x instance

Annotations
@Override
initback to summary
public void init(Vertx vertx, Context context)

Implements io.vertx.core.Verticle.init.

Initialise the verticle.

This is called by Vert.x when the verticle instance is deployed. Don't call it yourself.

Parameters
vertx:Vertx

the deploying Vert.x instance

context:Context

the context of the verticle

Annotations
@Override
processArgsback to summary
public List<String> processArgs()

Get the arguments used when deploying the Vert.x process.

Returns:List<String>

the list of arguments

startback to summary
public void start(Promise<Void> startPromise) throws Exception

Implements io.vertx.core.Verticle.start.

Start the verticle.

This is called by Vert.x when the verticle instance is deployed. Don't call it yourself.

If your verticle does things in its startup which take some time then you can override this method and call the startFuture some time later when start up is complete.

Parameters
startPromise:Promise<Void>

a promise which should be called when verticle start-up is complete.

Annotations
@Override
startback to summary
public void start() throws Exception

If your verticle does a simple, synchronous start-up then override this method and put your start-up code in here.

stopback to summary
public void stop(Promise<Void> stopPromise) throws Exception

Implements io.vertx.core.Verticle.stop.

Stop the verticle.

This is called by Vert.x when the verticle instance is un-deployed. Don't call it yourself.

If your verticle does things in its shut-down which take some time then you can override this method and call the stopFuture some time later when clean-up is complete.

Parameters
stopPromise:Promise<Void>

a promise which should be called when verticle clean-up is complete.

Annotations
@Override
stopback to summary
public void stop() throws Exception

If your verticle has simple synchronous clean-up tasks to complete then override this method and put your clean-up code in here.