Class VerticleBase
- java.lang.Object
-
- io.vertx.core.VerticleBase
-
- All Implemented Interfaces:
Deployable
public abstract class VerticleBase extends Object implements Deployable
An abstract base class that you can extend to write your own Verticle classes.In the simplest case, just override the
start()
method. If you have verticle clean-up to do you can optionally override thestop()
method too. This class also maintains references to theVertx
andContext
instances of the verticle for easy access.It also provides methods for getting the
verticle configuration
anddeployment ID
.- Author:
- Tim Fox, Julien Viet
-
-
Constructor Summary
Constructors Constructor Description VerticleBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonObject
config()
Get the configuration of the verticle.Future<?>
deploy(Context context)
Start the deployable.String
deploymentID()
Get the deployment ID of the verticle deploymentvoid
init(Vertx vertx, Context context)
Initialise the verticle.Future<?>
start()
Start the verticle.Future<?>
stop()
Stop the verticle.Future<?>
undeploy(Context context)
Stop the deployable.
-
-
-
Method Detail
-
init
public void init(Vertx vertx, Context context)
Initialise the verticle.This is called by Vert.x when the verticle instance is deployed. Don't call it yourself.
- Parameters:
vertx
- the deploying Vert.x instancecontext
- the context of the verticle
-
deploymentID
public String deploymentID()
Get the deployment ID of the verticle deployment- Returns:
- the deployment ID
-
config
public JsonObject config()
Get the configuration of the verticle.This can be specified when the verticle is deployed.
- Returns:
- the configuration
-
deploy
public final Future<?> deploy(Context context) throws Exception
Description copied from interface:Deployable
Start the deployable.Vert.x calls this method when deploying this deployable. You do not call it yourself.
- Specified by:
deploy
in interfaceDeployable
- Parameters:
context
- the Vert.x context assigned to this deployable- Returns:
- a future signalling the start-up completion
- Throws:
Exception
-
undeploy
public final Future<?> undeploy(Context context) throws Exception
Description copied from interface:Deployable
Stop the deployable.Vert.x calls this method when undeploying this deployable. You do not call it yourself.
- Specified by:
undeploy
in interfaceDeployable
- Parameters:
context
- the Vert.x context assigned to this deployable- Returns:
- a future signalling the clean-up completion
- Throws:
Exception
-
start
public Future<?> start() throws Exception
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.
- Returns:
- a future signalling the start-up completion
- Throws:
Exception
-
-