Class AbstractVerticle
- java.lang.Object
-
- io.vertx.core.AbstractVerticle
-
- All Implemented Interfaces:
Deployable,Verticle
- Direct Known Subclasses:
AbstractVerticle,AbstractVerticle,ScriptVerticle,ShellVerticle
public abstract class AbstractVerticle extends Object implements Verticle
WARNING : this class is not deprecated, however we encourage instead to useVerticleBaseAn abstract base class that you can extend to write your own Verticle classes.Instead of implementing
Verticledirectly, 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 thestop(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
startandstopmethods.This class also maintains references to the
VertxandContextinstances of the verticle for easy access.It also provides methods for getting the
verticle configuration,process arguments, anddeployment ID.- Author:
- Tim Fox
-
-
Constructor Summary
Constructors Constructor Description AbstractVerticle()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description JsonObjectconfig()Get the configuration of the verticle.Future<?>deploy(Context context)Start the deployable.StringdeploymentID()Get the deployment ID of the verticle deploymentVertxgetVertx()Get the Vert.x instancevoidinit(Vertx vertx, Context context)Initialise the verticle.List<String>processArgs()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(Promise<Void> startPromise)Start 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(Promise<Void> stopPromise)Stop the verticle.Future<?>undeploy(Context context)Stop the deployable.
-
-
-
Method Detail
-
getVertx
public Vertx getVertx()
Get the Vert.x instance
-
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.
-
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
-
processArgs
@Deprecated public List<String> processArgs()
Deprecated.As of version 5, Vert.x is no longer tightly coupled to the CLI- Returns:
- an empty list
-
deploy
public final Future<?> deploy(Context context)
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
public final Future<?> undeploy(Context context)
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
public void start(Promise<Void> startPromise) 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.
-
stop
public void stop(Promise<Void> stopPromise) throws Exception
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
public void start() throws ExceptionIf your verticle does a simple, synchronous start-up then override this method and put your start-up code in here.- Throws:
Exception
-
-