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
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 invalid input: '<'[email protected]>
-
Nested Class Summary
Nested classes/interfaces inherited from class io.vertx.core.impl.launcher.VertxCommandLauncher
io.vertx.core.impl.launcher.VertxCommandLauncher.CommandRegistration -
Field Summary
Fields inherited from class io.vertx.core.impl.launcher.VertxCommandLauncher
commandByName, lookups, main, PROCESS_ARGS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterConfigParsed(JsonObject config) Hook for sub-classes ofLauncherafter the config has been parsed.voidafterStartingVertx(Vertx vertx) Hook for sub-classes ofLauncherafter the vertx instance is started.voidvoidbeforeDeployingVerticle(DeploymentOptions deploymentOptions) Hook for sub-classes ofLauncherbefore the verticle is deployed.voidbeforeStartingVertx(VertxOptions options) Hook for sub-classes ofLauncherbefore the vertx instance is started.voidbeforeStoppingVertx(Vertx vertx) createVertxBuilder(VertxOptions options) Hook for sub-classes ofLauncherto customize the Vert.x builder.static voidexecuteCommand(String cmd, String... args) Utility method to execute a specific command.voidhandleDeployFailed(Vertx vertx, String mainVerticle, DeploymentOptions deploymentOptions, Throwable cause) A deployment failure has been encountered.static voidMain 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, unregisterMethods inherited from class 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
-
Constructor Details
-
Launcher
public Launcher()
-
-
Method Details
-
main
Main entry point.- Parameters:
args- the user command line arguments.
-
executeCommand
-
afterConfigParsed
Hook for sub-classes ofLauncherafter the config has been parsed.- Specified by:
afterConfigParsedin interfaceio.vertx.core.impl.launcher.VertxLifecycleHooks- Parameters:
config- the read config, empty if none are provided.
-
beforeStartingVertx
Hook for sub-classes ofLauncherbefore the vertx instance is started.- Specified by:
beforeStartingVertxin interfaceio.vertx.core.impl.launcher.VertxLifecycleHooks- Parameters:
options- the configured Vert.x options. Modify them to customize the Vert.x instance.
-
createVertxBuilder
Hook for sub-classes ofLauncherto customize the Vert.x builder.- Specified by:
createVertxBuilderin interfaceio.vertx.core.impl.launcher.VertxLifecycleHooks- Parameters:
options- the configured Vert.x options- Returns:
- the builder configured with the
options
-
afterStartingVertx
-
beforeDeployingVerticle
Hook for sub-classes ofLauncherbefore the verticle is deployed.- Specified by:
beforeDeployingVerticlein interfaceio.vertx.core.impl.launcher.VertxLifecycleHooks- Parameters:
deploymentOptions- the current deployment options. Modify them to customize the deployment.
-
beforeStoppingVertx
Description copied from interface:io.vertx.core.impl.launcher.VertxLifecycleHooksHook for sub classes of theLauncherclass called before theVertxinstance is terminated. The hook is called during theVertx.close()method.- Specified by:
beforeStoppingVertxin interfaceio.vertx.core.impl.launcher.VertxLifecycleHooks- Parameters:
vertx- theVertxinstance, cannot benull
-
afterStoppingVertx
public void afterStoppingVertx()Description copied from interface:io.vertx.core.impl.launcher.VertxLifecycleHooksHook for sub classes of theLauncherclass called after theVertxinstance has been terminated. The hook is called after theVertx.close()method.- Specified by:
afterStoppingVertxin 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:
handleDeployFailedin interfaceio.vertx.core.impl.launcher.VertxLifecycleHooks- Parameters:
vertx- the vert.x instancemainVerticle- the verticledeploymentOptions- the verticle deployment optionscause- the cause of the failure
-