Last active
February 17, 2017 09:53
-
-
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/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
compile("com.netflix.governator:governator:${governatorVersion}") { | |
// must exclude guava dependency to avoid | |
exclude group: 'com.google.guava', module: 'guava' | |
exclude group: 'commons-lang' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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