use of io.druid.guice.LifecycleModule in project druid by druid-io.
the class ComposingEmitterModuleTest method testGetEmitterViaRealGuice.
@Test
public void testGetEmitterViaRealGuice() {
Injector injector = Guice.createInjector(new DruidGuiceExtensions(), new LifecycleModule(), new Module() {
@Override
public void configure(Binder binder) {
Properties props = new Properties();
props.put("druid.emitter.composing.emitters", "[\"" + testEmitterType + "\"]");
binder.bind(Properties.class).toInstance(props);
binder.bind(Validator.class).toInstance(Validation.buildDefaultValidatorFactory().getValidator());
binder.bind(Emitter.class).annotatedWith(Names.named(testEmitterType)).toInstance(emitter);
}
}, new ComposingEmitterModule());
injector.getInstance(Key.get(Emitter.class, Names.named("composing"))).start();
EasyMock.verify(emitter);
}
use of io.druid.guice.LifecycleModule in project druid by druid-io.
the class Initialization method makeInjectorWithModules.
public static Injector makeInjectorWithModules(final Injector baseInjector, Iterable<? extends Module> modules) {
final ModuleList defaultModules = new ModuleList(baseInjector);
defaultModules.addModules(// New modules should be added after Log4jShutterDownerModule
new Log4jShutterDownerModule(), new DruidAuthModule(), new LifecycleModule(), EmitterModule.class, HttpClientModule.global(), new HttpClientModule("druid.broker.http", Client.class), new CuratorModule(), new AnnouncerModule(), new DruidProcessingModule(), new AWSModule(), new MetricsModule(), new ServerModule(), new StorageNodeModule(), new JettyServerModule(), new QueryableModule(), new QueryRunnerFactoryModule(), new DiscoveryModule(), new ServerViewModule(), new MetadataConfigModule(), new DerbyMetadataStorageDruidModule(), new JacksonConfigManagerModule(), new IndexingServiceDiscoveryModule(), new CoordinatorDiscoveryModule(), new LocalDataStorageDruidModule(), new FirehoseModule(), new ParsersModule(), new JavaScriptModule(), new StartupLoggingModule());
ModuleList actualModules = new ModuleList(baseInjector);
actualModules.addModule(DruidSecondaryModule.class);
for (Object module : modules) {
actualModules.addModule(module);
}
Module intermediateModules = Modules.override(defaultModules.getModules()).with(actualModules.getModules());
ModuleList extensionModules = new ModuleList(baseInjector);
final ExtensionsConfig config = baseInjector.getInstance(ExtensionsConfig.class);
for (DruidModule module : Initialization.getFromExtensions(config, DruidModule.class)) {
extensionModules.addModule(module);
}
return Guice.createInjector(Modules.override(intermediateModules).with(extensionModules.getModules()));
}
Aggregations