Package io.vertx.core

Class Launcher

  • All Implemented Interfaces:
    io.vertx.core.impl.launcher.VertxLifecycleHooks

    public class Launcher
    extends io.vertx.core.impl.launcher.VertxCommandLauncher
    implements io.vertx.core.impl.launcher.VertxLifecycleHooks
    A main() class that can be used to create Vert.x instance and deploy a verticle, or run a bare Vert.x instance.

    This class is used by the vertx command line utility to deploy verticles from the command line. It is extensible as "commands" can be added using the CommandFactory SPI.

    E.g.

    vertx run myverticle.js vertx my-command ...

    It can also be used as the main class of an executable jar so you can run verticles directly with:

    java -jar myapp.jar

    Author:
    Clement Escoffier
    • Constructor Detail

      • Launcher

        public Launcher()
    • Method Detail

      • main

        public static void main​(String[] args)
        Main entry point.
        Parameters:
        args - the user command line arguments.
      • executeCommand

        public static void executeCommand​(String cmd,
                                          String... args)
        Utility method to execute a specific command.
        Parameters:
        cmd - the command
        args - the arguments
      • afterConfigParsed

        public void afterConfigParsed​(JsonObject config)
        Hook for sub-classes of Launcher after the config has been parsed.
        Specified by:
        afterConfigParsed in interface io.vertx.core.impl.launcher.VertxLifecycleHooks
        Parameters:
        config - the read config, empty if none are provided.
      • beforeStartingVertx

        public void beforeStartingVertx​(VertxOptions options)
        Hook for sub-classes of Launcher before the vertx instance is started.
        Specified by:
        beforeStartingVertx in interface io.vertx.core.impl.launcher.VertxLifecycleHooks
        Parameters:
        options - the configured Vert.x options. Modify them to customize the Vert.x instance.
      • createVertxBuilder

        public VertxBuilder createVertxBuilder​(VertxOptions options)
        Hook for sub-classes of Launcher to customize the Vert.x builder.
        Specified by:
        createVertxBuilder in interface io.vertx.core.impl.launcher.VertxLifecycleHooks
        Parameters:
        options - the configured Vert.x options
        Returns:
        the builder configured with the options
      • afterStartingVertx

        public void afterStartingVertx​(Vertx vertx)
        Hook for sub-classes of Launcher after the vertx instance is started.
        Specified by:
        afterStartingVertx in interface io.vertx.core.impl.launcher.VertxLifecycleHooks
        Parameters:
        vertx - the created Vert.x instance
      • beforeDeployingVerticle

        public void beforeDeployingVerticle​(DeploymentOptions deploymentOptions)
        Hook for sub-classes of Launcher before the verticle is deployed.
        Specified by:
        beforeDeployingVerticle in interface io.vertx.core.impl.launcher.VertxLifecycleHooks
        Parameters:
        deploymentOptions - the current deployment options. Modify them to customize the deployment.
      • beforeStoppingVertx

        public void beforeStoppingVertx​(Vertx vertx)
        Description copied from interface: io.vertx.core.impl.launcher.VertxLifecycleHooks
        Hook for sub classes of the Launcher class called before the Vertx instance is terminated. The hook is called during the Vertx.close() method.
        Specified by:
        beforeStoppingVertx in interface io.vertx.core.impl.launcher.VertxLifecycleHooks
        Parameters:
        vertx - the Vertx instance, cannot be null
      • afterStoppingVertx

        public void afterStoppingVertx()
        Description copied from interface: io.vertx.core.impl.launcher.VertxLifecycleHooks
        Hook for sub classes of the Launcher class called after the Vertx instance has been terminated. The hook is called after the Vertx.close() method.
        Specified by:
        afterStoppingVertx in interface io.vertx.core.impl.launcher.VertxLifecycleHooks
      • handleDeployFailed

        public void handleDeployFailed​(Vertx vertx,
                                       String mainVerticle,
                                       DeploymentOptions deploymentOptions,
                                       Throwable cause)
        A deployment failure has been encountered. You can override this method to customize the behavior. By default it closes the `vertx` instance.
        Specified by:
        handleDeployFailed in interface io.vertx.core.impl.launcher.VertxLifecycleHooks
        Parameters:
        vertx - the vert.x instance
        mainVerticle - the verticle
        deploymentOptions - the verticle deployment options
        cause - the cause of the failure