Package io.dropwizard.core.cli
Class EnvironmentCommand<T extends Configuration>
java.lang.Object
io.dropwizard.core.cli.Command
io.dropwizard.core.cli.ConfiguredCommand<T>
io.dropwizard.core.cli.EnvironmentCommand<T>
- Type Parameters:
T
- theConfiguration
subclass which is loaded from the configuration file
- Direct Known Subclasses:
ServerCommand
A command which executes with a configured
Environment
.- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
EnvironmentCommand
(Application<T> application, String name, String description) Creates a new environment command. -
Method Summary
Modifier and TypeMethodDescription@Nullable Environment
Returns the constructed environment ornull
if it hasn't been constructed yet.protected void
Runs the command with the givenBootstrap
andConfiguration
.protected abstract void
run
(Environment environment, net.sourceforge.argparse4j.inf.Namespace namespace, T configuration) Runs the command with the givenEnvironment
andConfiguration
.Methods inherited from class io.dropwizard.core.cli.ConfiguredCommand
addFileArgument, cleanup, cleanupAsynchronously, configure, getConfiguration, getConfigurationClass, run
Methods inherited from class io.dropwizard.core.cli.Command
getDescription, getName, onError
-
Constructor Details
-
EnvironmentCommand
Creates a new environment command.- Parameters:
application
- the application providing this commandname
- the name of the command, used for command line invocationdescription
- a description of the command's purpose
-
-
Method Details
-
getEnvironment
Returns the constructed environment ornull
if it hasn't been constructed yet.- Returns:
- Returns the constructed environment or
null
if it hasn't been constructed yet - Since:
- 2.0.19
-
run
protected void run(Bootstrap<T> bootstrap, net.sourceforge.argparse4j.inf.Namespace namespace, T configuration) throws Exception Description copied from class:ConfiguredCommand
Runs the command with the givenBootstrap
andConfiguration
.- Specified by:
run
in classConfiguredCommand<T extends Configuration>
- Parameters:
bootstrap
- the bootstrapnamespace
- the parsed command line namespaceconfiguration
- the configuration object- Throws:
Exception
- if something goes wrong
-
run
protected abstract void run(Environment environment, net.sourceforge.argparse4j.inf.Namespace namespace, T configuration) throws Exception Runs the command with the givenEnvironment
andConfiguration
.- Parameters:
environment
- the configured environmentnamespace
- the parsed command line namespaceconfiguration
- the configuration object- Throws:
Exception
- if something goes wrong
-