Package io.vertx.core

## 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 the `stop()` method too. 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` and `deployment ID`.

  Author:
    Tim Fox, Julien Viet

- - ### Field Summary

    Fields
    Modifier and Type | Field | 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

    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 deployment
    `void` | `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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### vertx

          protected Vertx vertx

      Reference to the Vert.x instance that deployed this verticle

    - #### context

          protected Context context

      Reference to the context of the verticle

  - ### Constructor Detail

    - #### VerticleBase

          public VerticleBase()

  - ### 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 instance
        `context` - 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 interface `Deployable`
      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 interface `Deployable`
      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`

    - #### stop

          public Future<?> stop()
                         throws Exception

      Stop the verticle.

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

      Returns:
        a future signalling the clean-up completion
      Throws:
        `Exception`