Package io.vertx.core
Class Launcher
- java.lang.Object
-
- io.vertx.core.cli.UsageMessageFormatter
-
- io.vertx.core.impl.launcher.VertxCommandLauncher
-
- io.vertx.core.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
Amain()
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 thevertx
command line utility to deploy verticles from the command line. It is extensible as "commands" can be added using theCommandFactory
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
-
-
Field Summary
-
Fields inherited from class io.vertx.core.impl.launcher.VertxCommandLauncher
commandByName, lookups, main, PROCESS_ARGS
-
Fields inherited from class io.vertx.core.cli.UsageMessageFormatter
DEFAULT_ARG_NAME, DEFAULT_DESC_PAD, DEFAULT_LEFT_PAD, DEFAULT_LONG_OPT_PREFIX, DEFAULT_LONG_OPT_SEPARATOR, DEFAULT_OPT_PREFIX, DEFAULT_USAGE_PREFIX, DEFAULT_WIDTH, optionComparator
-
-
Constructor Summary
Constructors Constructor Description Launcher()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterConfigParsed(JsonObject config)
Hook for sub-classes ofLauncher
after the config has been parsed.void
afterStartingVertx(Vertx vertx)
Hook for sub-classes ofLauncher
after the vertx instance is started.void
afterStoppingVertx()
void
beforeDeployingVerticle(DeploymentOptions deploymentOptions)
Hook for sub-classes ofLauncher
before the verticle is deployed.void
beforeStartingVertx(VertxOptions options)
Hook for sub-classes ofLauncher
before the vertx instance is started.void
beforeStoppingVertx(Vertx vertx)
VertxBuilder
createVertxBuilder(VertxOptions options)
Hook for sub-classes ofLauncher
to customize the Vert.x builder.static void
executeCommand(String cmd, String... args)
Utility method to execute a specific command.void
handleDeployFailed(Vertx vertx, String mainVerticle, DeploymentOptions deploymentOptions, Throwable cause)
A deployment failure has been encountered.static void
main(String[] args)
Main entry point.-
Methods inherited from class io.vertx.core.impl.launcher.VertxCommandLauncher
dispatch, dispatch, execute, getCommandFromManifest, getCommandLinePrefix, getCommandNames, getDefaultCommand, getExistingCommandInstance, getMainVerticle, getNewCommandInstance, getPrintStream, getProcessArguments, isAskingForHelp, isAskingForVersion, load, printCommandNotFound, printCommandUsage, printGenericExecutionError, printGlobalUsage, printSpecificException, register, register, register, resetProcessArguments, unregister
-
Methods inherited from class io.vertx.core.cli.UsageMessageFormatter
appendArgument, appendOption, buildWrapped, buildWrapped, computeOptionsAndArguments, computeUsage, computeUsageLine, createPadding, findWrapPos, getArgName, getDescPadding, getLeftPadding, getLongOptionPrefix, getLongOptionSeparator, getNewLine, getOptionComparator, getOptionPrefix, getUsagePrefix, getWidth, isNullOrEmpty, renderCommands, renderOptionsAndArguments, renderWrappedText, renderWrappedTextBlock, rtrim, setArgName, setDescPadding, setLeftPadding, setLongOptionPrefix, setLongOptionSeparator, setNewLine, setOptionComparator, setOptionPrefix, setUsagePrefix, setWidth, usage, usage
-
-
-
-
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 commandargs
- the arguments
-
afterConfigParsed
public void afterConfigParsed(JsonObject config)
Hook for sub-classes ofLauncher
after the config has been parsed.- Specified by:
afterConfigParsed
in interfaceio.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 ofLauncher
before the vertx instance is started.- Specified by:
beforeStartingVertx
in interfaceio.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 ofLauncher
to customize the Vert.x builder.- Specified by:
createVertxBuilder
in interfaceio.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 ofLauncher
after the vertx instance is started.- Specified by:
afterStartingVertx
in interfaceio.vertx.core.impl.launcher.VertxLifecycleHooks
- Parameters:
vertx
- the created Vert.x instance
-
beforeDeployingVerticle
public void beforeDeployingVerticle(DeploymentOptions deploymentOptions)
Hook for sub-classes ofLauncher
before the verticle is deployed.- Specified by:
beforeDeployingVerticle
in interfaceio.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 theLauncher
class called before theVertx
instance is terminated. The hook is called during theVertx.close()
method.- Specified by:
beforeStoppingVertx
in interfaceio.vertx.core.impl.launcher.VertxLifecycleHooks
- Parameters:
vertx
- theVertx
instance, cannot benull
-
afterStoppingVertx
public void afterStoppingVertx()
Description copied from interface:io.vertx.core.impl.launcher.VertxLifecycleHooks
Hook for sub classes of theLauncher
class called after theVertx
instance has been terminated. The hook is called after theVertx.close()
method.- Specified by:
afterStoppingVertx
in interfaceio.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 interfaceio.vertx.core.impl.launcher.VertxLifecycleHooks
- Parameters:
vertx
- the vert.x instancemainVerticle
- the verticledeploymentOptions
- the verticle deployment optionscause
- the cause of the failure
-
-