Class TelestionVerticle<T extends TelestionConfiguration>

java.lang.Object
io.vertx.core.AbstractVerticle
de.wuespace.telestion.api.verticle.TelestionVerticle<T>
Type Parameters:
T - the type of your Configuration class
All Implemented Interfaces:
io.vertx.core.Verticle
Direct Known Subclasses:
DefaultConfigVerticle, GenericSimpleCommandHandler, HelloWorld, PingVerticle, PongVerticle, PositionPublisher, Publisher, RandomPositionPublisher, Receiver, Requester, Responder, SayHello, SimpleCommandHandler, SystemInfoVerticle, TestVerticle

public abstract class TelestionVerticle<T extends TelestionConfiguration> extends io.vertx.core.AbstractVerticle
An abstract verticle class that you can extend to write your own verticle classes.

It's extends the AbstractVerticle from Vert.x to add support for default configurations and type-safe usage of the configuration JSON object provided by Vert.x.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.slf4j.Logger
    The default logger instance.

    Fields inherited from class io.vertx.core.AbstractVerticle

    context, vertx
  • Constructor Summary

    Constructors
    Constructor
    Description
    Same as TelestionVerticle(boolean) but enables loading of default configuration if possible.
    TelestionVerticle​(boolean skipDefaultConfigLoading)
    Creates a new Telestion verticle and tries to load the default configuration from the specified configuration class.
  • Method Summary

    Modifier and Type
    Method
    Description
    io.vertx.core.json.JsonObject
    Block the usage of config() in inheriting classes.
    Get the verticle configuration in the Configuration type format.
    protected Class<T>
    Get the Configuration Class type from the inheriting class.
    Get the default verticle configuration in the Configuration type format.
    io.vertx.core.json.JsonObject
    Get the verticle configuration in a generic format.
    io.vertx.core.json.JsonObject
    Get the default verticle configuration in a generic format.
    void
    Starts the verticle.
    void
    onStart​(io.vertx.core.Promise<Void> startPromise)
    Starts the verticle.
    void
    Stops the verticle.
    void
    onStop​(io.vertx.core.Promise<Void> stopPromise)
    Stops the verticle.
    void
    setDefaultConfig​(io.vertx.core.json.JsonObject defaultConfig)
    Set the default verticle configuration and update the verticle configuration.
    void
    setDefaultConfig​(T defaultConfig)
    Set the default verticle configuration and update the verticle configuration.
    void
     
    void
    start​(io.vertx.core.Promise<Void> startPromise)
     
    void
     
    void
    stop​(io.vertx.core.Promise<Void> stopPromise)
     

    Methods inherited from class io.vertx.core.AbstractVerticle

    deploymentID, getVertx, init, processArgs

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • logger

      protected final org.slf4j.Logger logger
      The default logger instance.
  • Constructor Details

    • TelestionVerticle

      public TelestionVerticle(boolean skipDefaultConfigLoading)
      Creates a new Telestion verticle and tries to load the default configuration from the specified configuration class.
      Parameters:
      skipDefaultConfigLoading - when true the loading of the default configuration is skipped
    • TelestionVerticle

      public TelestionVerticle()
      Same as TelestionVerticle(boolean) but enables loading of default configuration if possible.
  • Method Details

    • getConfigType

      protected Class<T> getConfigType()
      Get the Configuration Class type from the inheriting class.
      Returns:
      the Configuration Class type
    • start

      public final void start(io.vertx.core.Promise<Void> startPromise) throws Exception
      Specified by:
      start in interface io.vertx.core.Verticle
      Overrides:
      start in class io.vertx.core.AbstractVerticle
      Throws:
      Exception
    • start

      public final void start() throws Exception
      Overrides:
      start in class io.vertx.core.AbstractVerticle
      Throws:
      Exception
    • stop

      public final void stop(io.vertx.core.Promise<Void> stopPromise) throws Exception
      Specified by:
      stop in interface io.vertx.core.Verticle
      Overrides:
      stop in class io.vertx.core.AbstractVerticle
      Throws:
      Exception
    • stop

      public final void stop() throws Exception
      Overrides:
      stop in class io.vertx.core.AbstractVerticle
      Throws:
      Exception
    • onStart

      public void onStart(io.vertx.core.Promise<Void> startPromise) throws Exception
      Starts the verticle.

      This is called by Vert.x when the verticle instance is deployed. Please don't call it yourself.

      If your verticle needs a start routine which takes some time to finish, then complete the start promise some time later.

      This is the asynchronous part to the onStart() method.

      Parameters:
      startPromise - a promise which should be called when verticle start is complete
      Throws:
      Exception
    • onStart

      public void onStart() throws Exception
      Starts the verticle.

      This is called by Vert.x when the verticle instance is deployed. Please don't call it yourself.

      If your verticle only does synchronous start tasks, use this method.

      This is the synchronous part to the onStart(Promise) method.

      Throws:
      Exception
    • onStop

      public void onStop(io.vertx.core.Promise<Void> stopPromise) throws Exception
      Stops the verticle.

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

      If your verticle needs a stop routine which takes some time to finish, then complete the stop promise some time later.

      This is the asynchronous part to the onStop() method.

      Parameters:
      stopPromise - a promise which should be called when verticle stop is complete
      Throws:
      Exception
    • onStop

      public void onStop() throws Exception
      Stops the verticle.

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

      If your verticle only does synchronous stop tasks, use this method.

      This is the synchronous part to the onStop(Promise) method.

      Throws:
      Exception
    • setDefaultConfig

      public void setDefaultConfig(io.vertx.core.json.JsonObject defaultConfig)
      Set the default verticle configuration and update the verticle configuration.
      Parameters:
      defaultConfig - the new default verticle configuration
    • setDefaultConfig

      public void setDefaultConfig(T defaultConfig)
      Set the default verticle configuration and update the verticle configuration.
      Parameters:
      defaultConfig - the new default verticle configuration
    • getDefaultConfig

      public T getDefaultConfig()
      Get the default verticle configuration in the Configuration type format.

      Returns null when no type via getConfigType() is given.

      Returns:
      the default verticle configuration
    • getGenericDefaultConfig

      public io.vertx.core.json.JsonObject getGenericDefaultConfig()
      Get the default verticle configuration in a generic format.
      Returns:
      the default verticle configuration
    • getConfig

      public T getConfig()
      Get the verticle configuration in the Configuration type format.

      Returns null when no type via getConfigType() is given.

      Returns:
      the verticle configuration
    • getGenericConfig

      public io.vertx.core.json.JsonObject getGenericConfig()
      Get the verticle configuration in a generic format.
      Returns:
      the verticle configuration
    • config

      public final io.vertx.core.json.JsonObject config()
      Block the usage of config() in inheriting classes.
      Overrides:
      config in class io.vertx.core.AbstractVerticle
      Returns:
      the verticle configuration from vertx merged with the default configuration