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
- Direct Known Subclasses:
HelloWorldApplication
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
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addDefaultCommands
(Bootstrap<T> bootstrap) Called byrun(String...)
to add the standard "server" and "check" commandsprotected void
protected ch.qos.logback.classic.Level
The log level at which to bootstrap logging on application startup.Returns theClass
of the configuration class type parameter.getName()
Returns the name of the application.void
initialize
(Bootstrap<T> bootstrap) Initializes the application bootstrap.protected void
Called byrun(String...)
to indicate there was a fatal error running the requested command.void
Parses command-line arguments and runs the application.abstract void
run
(T configuration, Environment environment) When the application runs, this is called after theConfiguredBundle
s 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 theClass
of the configuration class type parameter.- Returns:
- the configuration class
- See Also:
-
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 theConfiguredBundle
s are run. Override it to add providers, resources, etc. for your application.- Parameters:
configuration
- the parsedConfiguration
objectenvironment
- 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 main
entry 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
- TheThrowable
instance which caused the command to fail.- Since:
- 2.0
-