Package io.vertx.core

## 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 use `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
    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
    --- | ---
    `AbstractVerticle()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated 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
    `Vertx` | `getVertx()` | Get the Vert.x instance
    `void` | `init​(Vertx vertx, Context context)` | Initialise the verticle.
    `List<String>` | `processArgs()` | Deprecated. As of version 5, Vert.x is no longer tightly coupled to the CLI
    `void` | `start()` | If your verticle does a simple, synchronous start-up then override this method and put your start-up code in here.
    `void` | `start​(Promise<Void> startPromise)` | Start the verticle.
    `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.
    `void` | `stop​(Promise<Void> stopPromise)` | 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

    - #### AbstractVerticle

          public AbstractVerticle()

  - ### Method Detail

    - #### getVertx

          public Vertx getVertx()

      Get the Vert.x instance
      Specified by:
        `getVertx` in interface `Verticle`
      Returns:
        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.

      Specified by:
        `init` in interface `Verticle`
      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

    - #### 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: `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

    - #### undeploy

          public final Future<?> undeploy​(Context context)

      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

    - #### 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.

      Specified by:
        `start` in interface `Verticle`
      Parameters:
        `startPromise` - a promise which should be called when verticle start-up is complete.
      Throws:
        `Exception`

    - #### 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.

      Specified by:
        `stop` in interface `Verticle`
      Parameters:
        `stopPromise` - a promise which should be called when verticle clean-up is complete.
      Throws:
        `Exception`

    - #### start

          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.
      Throws:
        `Exception`

    - #### stop

          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.
      Throws:
        `Exception`