Top Description Fields Constructors Methods
io.vertx.core.spi.launcher

public abstract Class DefaultCommand

extends Object
implements Command
Class Inheritance
All Implemented Interfaces
io.vertx.core.spi.launcher.Command
Known Direct Subclasses
examples.cli.MyCommand, io.vertx.core.impl.launcher.commands.ClasspathHandler, io.vertx.core.impl.launcher.commands.ListCommand, io.vertx.core.impl.launcher.commands.StartCommand, io.vertx.core.impl.launcher.commands.StopCommand, io.vertx.core.impl.launcher.commands.VersionCommand
Imports
io.vertx.core.cli.CLIException, io.vertx.core.cli.annotations.Description, .Hidden, .Option, java.io.File, .PrintStream, java.util.List

Default implementation of Command using annotation to define itself. It is highly recommended to extend this class when implementing a command.

It defines two hidden Options to create system properties (-Dkey=value) and a way to configure the current working directory.

Field Summary

Modifier and TypeField and Description
private File
protected ExecutionContext
executionContext

The execution context of the command.

protected PrintStream
out

The PrintStream that the command can use to write on the console.

protected List<String>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
applySystemProperties()

Sets the system properties specified by the user command line.

public File

Returns:

the configure current working directory. If not set use the "regular" Java current working directory.
getCwd
()

public PrintStream

Returns:

the print stream on which message should be written.
out
()

public void
setCwd(File
the directory
cwd
)

Sets the current working directory.

public void
setSystemProps(List<String>
the properties
props
)

Gets system properties passed in the user command line.

public void
setUp(ExecutionContext
the context
ec
)

Implements io.vertx.core.spi.launcher.Command.setUp.

Set up the command execution environment.

public void
tearDown()

Implements io.vertx.core.spi.launcher.Command.tearDown.

The command has been executed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cwdback to summary
private File cwd
executionContextback to summary
protected ExecutionContext executionContext

The execution context of the command.

outback to summary
protected PrintStream out

The PrintStream that the command can use to write on the console.

systemPropertiesback to summary
protected List<String> systemProperties

Constructor Detail

DefaultCommandback to summary
public DefaultCommand()

Method Detail

applySystemPropertiesback to summary
protected void applySystemProperties()

Sets the system properties specified by the user command line.

getCwdback to summary
public File getCwd()
Returns:File

the configure current working directory. If not set use the "regular" Java current working directory.

outback to summary
public PrintStream out()
Returns:PrintStream

the print stream on which message should be written.

setCwdback to summary
public void setCwd(File cwd)

Sets the current working directory. This method is called when the user configure the "cwd" option as follows: --cwd=the-directory.

Parameters
cwd:File

the directory

Annotations
@SuppressWarnings:unused
@Option
longName:cwd
argName:dir
@Description:Specifies the current working directory for this command, default set to the Java current directory
@Hidden
setSystemPropsback to summary
public void setSystemProps(List<String> props)

Gets system properties passed in the user command line. The user can configure system properties using -Dkey=value.

Parameters
props:List<String>

the properties

Annotations
@SuppressWarnings:unused
@Option
longName:systemProperty
shortName:D
argName:key>=@Description:Set a system property
@Hidden
setUpback to summary
public void setUp(ExecutionContext ec) throws CLIException

Implements io.vertx.core.spi.launcher.Command.setUp.

Doc from io.vertx.core.spi.launcher.Command.setUp.

Set up the command execution environment. The command line model has been retrieved and is frozen. Values has been set / injected. You can use this callback to validate the inputs.

Parameters
ec:ExecutionContext

the context

Annotations
@Override
Exceptions
CLIException:
if the validation failed
tearDownback to summary
public void tearDown() throws CLIException

Implements io.vertx.core.spi.launcher.Command.tearDown.

Doc from io.vertx.core.spi.launcher.Command.tearDown.

The command has been executed. Use this method to cleanup the environment.

Annotations
@Override
Exceptions
CLIException:
if anything went wrong