Skip to content

Instantly share code, notes, and snippets.

@mrserverless
Last active February 17, 2017 09:53
Show Gist options
  • Save mrserverless/cbdb80ddca1403b55833 to your computer and use it in GitHub Desktop.
Save mrserverless/cbdb80ddca1403b55833 to your computer and use it in GitHub Desktop.
Using Governator with Dropwizard-Guice, pending pull request https://github.com/HubSpot/dropwizard-guice/pull/39/
compile("com.netflix.governator:governator:${governatorVersion}") {
// must exclude guava dependency to avoid
exclude group: 'com.google.guava', module: 'guava'
exclude group: 'commons-lang'
}
@Override
public void initialize( final Bootstrap<PlatformConfiguration> bootstrap ) {
final GuiceBundle<PlatformConfiguration> guiceBundle = GuiceBundle.<PlatformConfiguration>newBuilder()
.addModule( new PlatformModule() )
.enableAutoConfig( "com.apmasphere.platform.resources", "com.apmasphere.platform.health" )
.setConfigClass( PlatformConfiguration.class )
.setInjectorFactory( new GovernatorInjectorFactory() )
.build();
bootstrap.addBundle( guiceBundle );
}
public class GovernatorInjectorFactory implements InjectorFactory {
@Override
public Injector create( final Stage stage, final List<Module> modules ) {
return LifecycleInjector.builder().inStage( stage ).withModules( modules ).build()
.createInjector();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment