Package io.dropwizard.core.setup
Class Bootstrap<T extends Configuration>
- java.lang.Object
-
- io.dropwizard.core.setup.Bootstrap<T>
-
- Type Parameters:
T- the configuration type
public class Bootstrap<T extends Configuration> extends Object
The pre-start application environment, containing everything required to bootstrap a Dropwizard command.
-
-
Constructor Summary
Constructors Constructor Description Bootstrap(Application<T> application)Creates a newBootstrapfor the given application.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBundle(ConfiguredBundle<? super T> bundle)Adds the given bundle to the bootstrap.voidaddCommand(Command command)Adds the given command to the bootstrap.voidaddCommand(ConfiguredCommand<T> command)Adds the given command to the bootstrap.Application<T>getApplication()Returns the bootstrap'sApplication.ClassLoadergetClassLoader()Returns the bootstrap's class loader.List<Command>getCommands()Returns the application's commands.ConfigurationFactoryFactory<T>getConfigurationFactoryFactory()ConfigurationSourceProvidergetConfigurationSourceProvider()Returns the bootstrap'sConfigurationSourceProvider.com.codahale.metrics.health.HealthCheckRegistrygetHealthCheckRegistry()returns the health check registry@Nullable com.codahale.metrics.jmx.JmxReportergetJmxReporter()Returns theJmxReporterregistered with the bootstrap'sMetricRegistry.com.codahale.metrics.MetricRegistrygetMetricRegistry()Returns the application metrics.com.fasterxml.jackson.databind.ObjectMappergetObjectMapper()Returns the bootstrap'sObjectMapper.javax.validation.ValidatorFactorygetValidatorFactory()Returns the application's validator factory.voidregisterMetrics()Registers the JVM metrics to the metric registry and start to report the registry metrics via JMX.voidrun(T configuration, Environment environment)Runs the bootstrap's bundles with the given configuration and environment.voidsetClassLoader(ClassLoader classLoader)Sets the bootstrap's class loader.voidsetConfigurationFactoryFactory(ConfigurationFactoryFactory<T> configurationFactoryFactory)voidsetConfigurationSourceProvider(ConfigurationSourceProvider provider)Sets the bootstrap'sConfigurationSourceProvider.voidsetHealthCheckRegistry(com.codahale.metrics.health.HealthCheckRegistry healthCheckRegistry)voidsetMetricRegistry(com.codahale.metrics.MetricRegistry metricRegistry)Sets a custom registry for the application metrics.voidsetObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)Sets the givenObjectMapperto the bootstrap.voidsetValidatorFactory(javax.validation.ValidatorFactory validatorFactory)
-
-
-
Constructor Detail
-
Bootstrap
public Bootstrap(Application<T> application)
Creates a newBootstrapfor the given application.- Parameters:
application- a DropwizardApplication
-
-
Method Detail
-
registerMetrics
public void registerMetrics()
Registers the JVM metrics to the metric registry and start to report the registry metrics via JMX.
-
getJmxReporter
public @Nullable com.codahale.metrics.jmx.JmxReporter getJmxReporter()
Returns theJmxReporterregistered with the bootstrap'sMetricRegistry.- Since:
- 2.1
-
getApplication
public Application<T> getApplication()
Returns the bootstrap'sApplication.
-
getConfigurationSourceProvider
public ConfigurationSourceProvider getConfigurationSourceProvider()
Returns the bootstrap'sConfigurationSourceProvider.
-
setConfigurationSourceProvider
public void setConfigurationSourceProvider(ConfigurationSourceProvider provider)
Sets the bootstrap'sConfigurationSourceProvider.
-
getClassLoader
public ClassLoader getClassLoader()
Returns the bootstrap's class loader.
-
setClassLoader
public void setClassLoader(ClassLoader classLoader)
Sets the bootstrap's class loader.
-
addBundle
public void addBundle(ConfiguredBundle<? super T> bundle)
Adds the given bundle to the bootstrap.- Parameters:
bundle- aConfiguredBundle
-
addCommand
public void addCommand(Command command)
Adds the given command to the bootstrap.- Parameters:
command- aCommand
-
addCommand
public void addCommand(ConfiguredCommand<T> command)
Adds the given command to the bootstrap.- Parameters:
command- aConfiguredCommand
-
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
Returns the bootstrap'sObjectMapper.
-
setObjectMapper
public void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Sets the givenObjectMapperto the bootstrap.WARNING: The mapper should be created by
Jackson.newMinimalObjectMapper()orJackson.newObjectMapper(), otherwise it will not work with Dropwizard.- Parameters:
objectMapper- anObjectMapper
-
run
public void run(T configuration, Environment environment) throws Exception
Runs the bootstrap's bundles with the given configuration and environment.- Parameters:
configuration- the parsed configurationenvironment- the application environment- Throws:
Exception- if a bundle throws an exception
-
getMetricRegistry
public com.codahale.metrics.MetricRegistry getMetricRegistry()
Returns the application metrics.
-
setMetricRegistry
public void setMetricRegistry(com.codahale.metrics.MetricRegistry metricRegistry)
Sets a custom registry for the application metrics.- Parameters:
metricRegistry- a custom metric registry
-
getValidatorFactory
public javax.validation.ValidatorFactory getValidatorFactory()
Returns the application's validator factory.
-
setValidatorFactory
public void setValidatorFactory(javax.validation.ValidatorFactory validatorFactory)
-
getConfigurationFactoryFactory
public ConfigurationFactoryFactory<T> getConfigurationFactoryFactory()
-
setConfigurationFactoryFactory
public void setConfigurationFactoryFactory(ConfigurationFactoryFactory<T> configurationFactoryFactory)
-
getHealthCheckRegistry
public com.codahale.metrics.health.HealthCheckRegistry getHealthCheckRegistry()
returns the health check registry
-
setHealthCheckRegistry
public void setHealthCheckRegistry(com.codahale.metrics.health.HealthCheckRegistry healthCheckRegistry)
-
-