use of com.google.inject.PrivateModule in project cdap by caskdata.
the class DataSetServiceModules method getStandaloneModules.
@Override
public Module getStandaloneModules() {
return new AbstractModule() {
@Override
protected void configure() {
// Add the system dataset runtime module as public binding so that adding bindings could be added
install(new SystemDatasetRuntimeModule().getStandaloneModules());
install(new PrivateModule() {
@Override
protected void configure() {
install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class, DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
bind(DatasetFramework.class).annotatedWith(Names.named("datasetMDS")).toProvider(DatasetMdsProvider.class).in(Singleton.class);
expose(DatasetFramework.class).annotatedWith(Names.named("datasetMDS"));
Multibinder.newSetBinder(binder(), DatasetMetricsReporter.class).addBinding().to(LevelDBDatasetMetricsReporter.class);
bind(DatasetService.class);
expose(DatasetService.class);
Named datasetUserName = Names.named(Constants.Service.DATASET_EXECUTOR);
Multibinder<HttpHandler> handlerBinder = Multibinder.newSetBinder(binder(), HttpHandler.class, datasetUserName);
CommonHandlers.add(handlerBinder);
handlerBinder.addBinding().to(DatasetAdminOpHTTPHandler.class);
bind(DatasetOpExecutorService.class).in(Scopes.SINGLETON);
expose(DatasetOpExecutorService.class);
bind(DatasetOpExecutor.class).to(LocalDatasetOpExecutor.class);
expose(DatasetOpExecutor.class);
}
});
}
};
}
use of com.google.inject.PrivateModule in project cdap by caskdata.
the class DataSetServiceModules method getDistributedModules.
@Override
public Module getDistributedModules() {
return new AbstractModule() {
@Override
protected void configure() {
// Add the system dataset runtime module as public binding so that adding bindings could be added
install(new SystemDatasetRuntimeModule().getDistributedModules());
install(new PrivateModule() {
@Override
protected void configure() {
install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class, DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
bind(DatasetFramework.class).annotatedWith(Names.named("datasetMDS")).toProvider(DatasetMdsProvider.class).in(Singleton.class);
expose(DatasetFramework.class).annotatedWith(Names.named("datasetMDS"));
Multibinder.newSetBinder(binder(), DatasetMetricsReporter.class).addBinding().to(HBaseDatasetMetricsReporter.class);
// NOTE: this cannot be a singleton, because MasterServiceMain needs to obtain a new instance
// every time it becomes leader and starts a dataset service.
bind(DatasetService.class);
expose(DatasetService.class);
Named datasetUserName = Names.named(Constants.Service.DATASET_EXECUTOR);
Multibinder<HttpHandler> handlerBinder = Multibinder.newSetBinder(binder(), HttpHandler.class, datasetUserName);
CommonHandlers.add(handlerBinder);
handlerBinder.addBinding().to(DatasetAdminOpHTTPHandler.class);
bind(DatasetOpExecutorService.class).in(Scopes.SINGLETON);
expose(DatasetOpExecutorService.class);
bind(DatasetOpExecutor.class).to(YarnDatasetOpExecutor.class);
expose(DatasetOpExecutor.class);
}
});
}
};
}
use of com.google.inject.PrivateModule in project cdap by caskdata.
the class DataSetsModules method getInMemoryModules.
@Override
public Module getInMemoryModules() {
return new PrivateModule() {
@Override
protected void configure() {
install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class, DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
bind(MetadataStore.class).to(NoOpMetadataStore.class);
expose(MetadataStore.class);
bind(DatasetFramework.class).annotatedWith(Names.named(BASE_DATASET_FRAMEWORK)).to(InMemoryDatasetFramework.class).in(Scopes.SINGLETON);
bind(LineageStoreReader.class).to(LineageStore.class);
bind(LineageStoreWriter.class).to(LineageStore.class);
// Need to expose LineageStoreReader as it's being used by the LineageHandler (through LineageAdmin)
expose(LineageStoreReader.class);
bind(LineageWriter.class).to(BasicLineageWriter.class);
expose(LineageWriter.class);
bind(UsageRegistry.class).to(DefaultUsageRegistry.class).in(Scopes.SINGLETON);
expose(UsageRegistry.class);
bind(RuntimeUsageRegistry.class).to(DefaultUsageRegistry.class).in(Scopes.SINGLETON);
expose(RuntimeUsageRegistry.class);
bind(DefaultUsageRegistry.class).in(Scopes.SINGLETON);
bind(DatasetFramework.class).to(LineageWriterDatasetFramework.class);
expose(DatasetFramework.class);
bind(DefaultOwnerStore.class).in(Scopes.SINGLETON);
bind(OwnerStore.class).to(DefaultOwnerStore.class);
expose(OwnerStore.class);
}
};
}
use of com.google.inject.PrivateModule in project cdap by caskdata.
the class InMemoryMetricsTableTest method setup.
@BeforeClass
public static void setup() throws Exception {
Injector injector = Guice.createInjector(new ConfigModule(), new NonCustomLocationUnitTestModule().getModule(), new DiscoveryRuntimeModule().getInMemoryModules(), new DataFabricModules().getInMemoryModules(), new TransactionMetricsModule(), new SystemDatasetRuntimeModule().getInMemoryModules(), new PrivateModule() {
@Override
protected void configure() {
install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class, DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
bind(DatasetFramework.class).to(InMemoryDatasetFramework.class);
expose(DatasetFramework.class);
}
});
dsFramework = injector.getInstance(DatasetFramework.class);
}
use of com.google.inject.PrivateModule in project guice by google.
the class ModuleAnnotatedMethodScannerTest method testPrivateModuleWithinPrivateModule.
public void testPrivateModuleWithinPrivateModule() {
Injector injector = Guice.createInjector(NamedMunger.module(), new PrivateModule() {
@Override
protected void configure() {
expose(Key.get(String.class, named("foo-munged")));
install(new PrivateModule() {
@Override
protected void configure() {
}
@Exposed
@TestProvides
@Named("foo")
String foo() {
return "foo";
}
});
}
});
assertMungedBinding(injector, String.class, "foo", "foo");
}
Aggregations