Class AbstractVerticle
- All Implemented Interfaces:
Deployable, Verticle
- Direct Known Subclasses:
AbstractVerticle, AbstractVerticle, ScriptVerticle, ShellVerticle
VerticleBase
An abstract base class that you can extend to write your own Verticle classes.
Instead of implementing 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 Vertx and 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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconfig()Get the configuration of the verticle.final Future<?> Start the deployable.Get the deployment ID of the verticle deploymentgetVertx()Get the Vert.x instancevoidInitialise the verticle.Deprecated.As of version 5, Vert.x is no longer tightly coupled to the CLIvoidstart()If your verticle does a simple, synchronous start-up then override this method and put your start-up code in here.voidStart the verticle.voidstop()If your verticle has simple synchronous clean-up tasks to complete then override this method and put your clean-up code in here.voidStop the verticle.final Future<?> Stop the deployable.
-
Field Details
-
vertx
Reference to the Vert.x instance that deployed this verticle -
context
Reference to the context of the verticle
-
-
Constructor Details
-
AbstractVerticle
public AbstractVerticle()
-
-
Method Details
-
getVertx
-
init
-
deploymentID
Get the deployment ID of the verticle deployment- Returns:
- the deployment ID
-
config
Get the configuration of the verticle.This can be specified when the verticle is deployed.
- Returns:
- the configuration
-
processArgs
Deprecated.As of version 5, Vert.x is no longer tightly coupled to the CLI- Returns:
- an empty list
-
deploy
Description copied from interface:DeployableStart the deployable.Vert.x calls this method when deploying this deployable. You do not call it yourself.
- Specified by:
deployin interfaceDeployable- Parameters:
context- the Vert.x context assigned to this deployable- Returns:
- a future signalling the start-up completion
-
undeploy
Description copied from interface:DeployableStop the deployable.Vert.x calls this method when undeploying this deployable. You do not call it yourself.
- Specified by:
undeployin interfaceDeployable- Parameters:
context- the Vert.x context assigned to this deployable- Returns:
- a future signalling the clean-up completion
-
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.
-
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.
-
start
-
stop
-