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
public abstract class EnvironmentCommand<T extends Configuration> extends ConfiguredCommand<T>
A command which executes with a configuredEnvironment
.- See Also:
Configuration
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
EnvironmentCommand(Application<T> application, String name, String description)
Creates a new environment command.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description @Nullable Environment
getEnvironment()
Returns the constructed environment ornull
if it hasn't been constructed yet.protected void
run(Bootstrap<T> bootstrap, net.sourceforge.argparse4j.inf.Namespace namespace, T configuration)
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 Detail
-
EnvironmentCommand
protected EnvironmentCommand(Application<T> application, String name, String description)
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 Detail
-
getEnvironment
public @Nullable Environment 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 bootstrap 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
-
-