Name: dropwizard-guicier
Owner: HubSpot
Description: null
Created: 2015-10-30 17:10:36.0
Updated: 2018-04-25 19:34:55.0
Pushed: 2018-04-25 19:34:53.0
Homepage: null
Size: 83
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A Dropwizard bundle to handle Guice integration.
<dependencies>
<dependency>
<groupId>com.hubspot.dropwizard</groupId>
<artifactId>dropwizard-guicier</artifactId>
<version>1.0.9.1</version>
</dependency>
</dependencies>
Simply install a new instance of the bundle during your service initialization
ic class ExampleApplication extends Application<ExampleConfiguration> {
blic static void main(String... args) throws Exception {
new ExampleApplication().run(args);
verride
blic void initialize(Bootstrap<ExampleConfiguration> bootstrap) {
GuiceBundle<ExampleConfiguration> guiceBundle = GuiceBundle.defaultBuilder(ExampleConfiguration.class)
.modules(new ExampleModule())
.build();
bootstrap.addBundle(guiceBundle);
verride
blic void run(ExampleConfiguration configuration, Environment environment) throws Exception {}
Configuration
and Environment
are available to eager singletons (injector is also
created with Stage.PRODUCTION
by default)GuiceBundle
can extend DropwizardAwareModule
which gives them
access to the Bootstrap
, Configuration
, and Environment
inside of the configure
method. This can be used to do conditional
binding, for exampleManaged
, Task
, HealthCheck
, or ServerLifecycleListener
bound in Guice will be added to Dropwizard for you, for example (must be eager singletons for this to work)There is an example project you can clone and play with if you'd like to get going right away.
Enjoy!