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
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 protectedEnvironmentCommand(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 EnvironmentgetEnvironment()Returns the constructed environment ornullif it hasn't been constructed yet.protected voidrun(Bootstrap<T> bootstrap, net.sourceforge.argparse4j.inf.Namespace namespace, T configuration)Runs 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, 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 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
-
-