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
The pre-start application environment, containing everything required to bootstrap a Dropwizard
command.
-
Constructor Summary
ConstructorsConstructorDescriptionBootstrap
(Application<T> application) Creates a newBootstrap
for the given application. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBundle
(ConfiguredBundle<? super T> bundle) Adds the given bundle to the bootstrap.void
addCommand
(Command command) Adds the given command to the bootstrap.void
addCommand
(ConfiguredCommand<T> command) Adds the given command to the bootstrap.Returns the bootstrap'sApplication
.Returns the bootstrap's class loader.Returns the application's commands.Returns the bootstrap'sConfigurationSourceProvider
.com.codahale.metrics.health.HealthCheckRegistry
returns the health check registry@Nullable com.codahale.metrics.jmx.JmxReporter
Returns theJmxReporter
registered with the bootstrap'sMetricRegistry
.com.codahale.metrics.MetricRegistry
Returns the application metrics.com.fasterxml.jackson.databind.ObjectMapper
Returns the bootstrap'sObjectMapper
.jakarta.validation.ValidatorFactory
Returns the application's validator factory.void
Registers the JVM metrics to the metric registry and start to report the registry metrics via JMX.void
run
(T configuration, Environment environment) Runs the bootstrap's bundles with the given configuration and environment.void
setClassLoader
(ClassLoader classLoader) Sets the bootstrap's class loader.void
setConfigurationFactoryFactory
(ConfigurationFactoryFactory<T> configurationFactoryFactory) void
Sets the bootstrap'sConfigurationSourceProvider
.void
setHealthCheckRegistry
(com.codahale.metrics.health.HealthCheckRegistry healthCheckRegistry) void
setMetricRegistry
(com.codahale.metrics.MetricRegistry metricRegistry) Sets a custom registry for the application metrics.void
setObjectMapper
(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Sets the givenObjectMapper
to the bootstrap.void
setValidatorFactory
(jakarta.validation.ValidatorFactory validatorFactory)
-
Constructor Details
-
Bootstrap
Creates a newBootstrap
for the given application.- Parameters:
application
- a DropwizardApplication
-
-
Method Details
-
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 theJmxReporter
registered with the bootstrap'sMetricRegistry
.- Since:
- 2.1
-
getApplication
Returns the bootstrap'sApplication
. -
getConfigurationSourceProvider
Returns the bootstrap'sConfigurationSourceProvider
. -
setConfigurationSourceProvider
Sets the bootstrap'sConfigurationSourceProvider
. -
getClassLoader
Returns the bootstrap's class loader. -
setClassLoader
Sets the bootstrap's class loader. -
addBundle
Adds the given bundle to the bootstrap.- Parameters:
bundle
- aConfiguredBundle
-
addCommand
Adds the given command to the bootstrap.- Parameters:
command
- aCommand
-
addCommand
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 givenObjectMapper
to the bootstrap. <pWARNING: The mapper should be created byJackson.newMinimalObjectMapper()
orJackson.newObjectMapper()
, otherwise it will not work with Dropwizard.- Parameters:
objectMapper
- anObjectMapper
-
run
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
-
getCommands
Returns the application's commands. -
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 jakarta.validation.ValidatorFactory getValidatorFactory()Returns the application's validator factory. -
setValidatorFactory
public void setValidatorFactory(jakarta.validation.ValidatorFactory validatorFactory) -
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)
-