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- theConfigurationsubclass which is loaded from the configuration file
- Direct Known Subclasses:
ServerCommand
A command which executes with a configured
Environment.- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedEnvironmentCommand(Application<T> application, String name, String description) Creates a new environment command. -
Method Summary
Modifier and TypeMethodDescription@Nullable EnvironmentReturns the constructed environment ornullif it hasn't been constructed yet.protected voidRuns the command with the givenBootstrapandConfiguration.protected abstract voidrun(Environment environment, net.sourceforge.argparse4j.inf.Namespace namespace, T configuration) Runs the command with the givenEnvironmentandConfiguration.Methods inherited from class io.dropwizard.core.cli.ConfiguredCommand
addFileArgument, cleanup, cleanupAsynchronously, configure, getConfiguration, getConfigurationClass, runMethods 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 ornullif it hasn't been constructed yet.- Returns:
- Returns the constructed environment or
nullif 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:ConfiguredCommandRuns the command with the givenBootstrapandConfiguration.- Specified by:
runin 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 givenEnvironmentandConfiguration.- Parameters:
environment- the configured environmentnamespace- the parsed command line namespaceconfiguration- the configuration object- Throws:
Exception- if something goes wrong
-