Package io.dropwizard.core
Class Application<T extends Configuration>
java.lang.Object
io.dropwizard.core.Application<T>
- Type Parameters:
T- the type of configuration class for this application
The base class for Dropwizard applications.
Because the default constructor will be inherited by all
subclasses, {BootstrapLogging.bootstrap()} will always be
invoked. The log level used during the bootstrap process can be
configured by {Application} subclasses by overriding
{#bootstrapLogLevel}.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddDefaultCommands(Bootstrap<T> bootstrap) Called byrun(String...)to add the standard "server" and "check" commandsprotected voidprotected ch.qos.logback.classic.LevelThe log level at which to bootstrap logging on application startup.Returns theClassof the configuration class type parameter.getName()Returns the name of the application.voidinitialize(Bootstrap<T> bootstrap) Initializes the application bootstrap.protected voidCalled byrun(String...)to indicate there was a fatal error running the requested command.voidParses command-line arguments and runs the application.abstract voidrun(T configuration, Environment environment) When the application runs, this is called after theConfiguredBundles are run.
-
Constructor Details
-
Application
protected Application()
-
-
Method Details
-
bootstrapLogLevel
protected ch.qos.logback.classic.Level bootstrapLogLevel()The log level at which to bootstrap logging on application startup. -
bootstrapLogging
protected void bootstrapLogging() -
getConfigurationClass
Returns theClassof the configuration class type parameter.- Returns:
- the configuration class
- See Also:
-
Generics.getTypeParameter(Class, Class)
-
getName
Returns the name of the application.- Returns:
- the application's name
-
initialize
Initializes the application bootstrap.- Parameters:
bootstrap- the application bootstrap
-
run
When the application runs, this is called after theConfiguredBundles are run. Override it to add providers, resources, etc. for your application.- Parameters:
configuration- the parsedConfigurationobjectenvironment- the application'sEnvironment- Throws:
Exception- if something goes wrong
-
run
Parses command-line arguments and runs the application. Call this method from apublic static void mainentry point in your application.- Parameters:
arguments- the command-line arguments- Throws:
Exception- if something goes wrong
-
addDefaultCommands
Called byrun(String...)to add the standard "server" and "check" commands- Parameters:
bootstrap- the bootstrap instance
-
onFatalError
Called byrun(String...)to indicate there was a fatal error running the requested command. The default implementation callsSystem.exit(int)with a non-zero status code to terminate the application.- Parameters:
t- TheThrowableinstance which caused the command to fail.- Since:
- 2.0
-