use of com.google.inject.assistedinject.FactoryModuleBuilder in project cdap by caskdata.
the class PreviewHttpModule method configure.
@Override
protected void configure() {
install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class, DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
bind(DatasetFramework.class).annotatedWith(Names.named(DataSetsModules.BASE_DATASET_FRAMEWORK)).to(RemoteDatasetFramework.class);
bind(PreviewManager.class).to(DefaultPreviewManager.class).in(Scopes.SINGLETON);
expose(PreviewManager.class);
}
use of com.google.inject.assistedinject.FactoryModuleBuilder in project cdap by caskdata.
the class AuthorizationModule method configure.
@Override
protected void configure() {
bind(DynamicDatasetCache.class).toProvider(DynamicDatasetCacheProvider.class).in(Scopes.SINGLETON);
bind(DatasetContext.class).to(DynamicDatasetCache.class).in(Scopes.SINGLETON);
bind(Admin.class).toProvider(AdminProvider.class);
bind(Transactional.class).toProvider(TransactionalProvider.class);
install(new FactoryModuleBuilder().implement(AuthorizationContext.class, DefaultAuthorizationContext.class).build(AuthorizationContextFactory.class));
bind(AuthorizerInstantiator.class).in(Scopes.SINGLETON);
expose(AuthorizerInstantiator.class);
bind(PrivilegesManager.class).to(DelegatingPrivilegeManager.class);
expose(PrivilegesManager.class);
}
use of com.google.inject.assistedinject.FactoryModuleBuilder in project google-gin by gwtplus.
the class OutputModule method configure.
public void configure() {
install(new FactoryModuleBuilder().build(FragmentPackageName.Factory.class));
install(new FactoryModuleBuilder().implement(InjectorWriteContext.class, GinjectorFragmentContext.class).build(GinjectorFragmentContext.Factory.class));
install(new FactoryModuleBuilder().build(GinjectorFragmentOutputter.Factory.class));
bind(GinjectorImplOutputter.class);
bind(ReachabilityAnalyzer.class).in(Singleton.class);
expose(FragmentPackageName.Factory.class);
expose(GinjectorImplOutputter.class);
}
use of com.google.inject.assistedinject.FactoryModuleBuilder in project google-gin by gwtplus.
the class GinjectorGeneratorModule method configure.
@Override
protected void configure() {
install(new ResolutionModule());
install(new OutputModule());
bind(TreeLogger.class).toInstance(logger);
bind(GeneratorContext.class).toInstance(ctx);
bind(new TypeLiteral<Class<? extends Ginjector>>() {
}).annotatedWith(GinjectorInterfaceType.class).toInstance(ginjectorInterface);
bind(GinjectorBindings.class).annotatedWith(RootBindings.class).to(GinjectorBindings.class).in(Singleton.class);
bind(BindingIndex.class).to(Key.get(GinjectorBindings.class, RootBindings.class)).in(Singleton.class);
install(new FactoryModuleBuilder().build(GuiceElementVisitor.GuiceElementVisitorFactory.class));
bind(new TypeLiteral<Set<Class<? extends GinModule>>>() {
}).annotatedWith(ModuleClasses.class).toInstance(moduleClasses);
bind(BindingFactory.class).to(BindingFactoryImpl.class);
install(new FactoryModuleBuilder().build(SourceWriteUtil.Factory.class));
}
use of com.google.inject.assistedinject.FactoryModuleBuilder in project guice by google.
the class SubpackageTest method testGeneratedDefaultMethodsForwardCorrectly.
@Test
public void testGeneratedDefaultMethodsForwardCorrectly() throws Exception {
// This test requires above java 1.8.
// 1.8's reflection capability is tested via "testReflectionFallbackWorks".
assumeTrue(JAVA_VERSION > 1.8);
final Key<AbstractAssisted.Factory<ConcreteAssisted, String>> concreteKey = new Key<AbstractAssisted.Factory<ConcreteAssisted, String>>() {
};
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
install(new FactoryModuleBuilder().withLookups(LOOKUPS).build(ConcreteAssistedWithOverride.Factory.class));
install(new FactoryModuleBuilder().withLookups(LOOKUPS).build(ConcreteAssistedWithOverride.Factory2.class));
install(new FactoryModuleBuilder().build(ConcreteAssistedWithoutOverride.Factory.class));
install(new FactoryModuleBuilder().build(Public.Factory.class));
install(new FactoryModuleBuilder().build(concreteKey));
}
});
assertThat(logRecords).isEmpty();
ConcreteAssistedWithOverride.Factory factory1 = injector.getInstance(ConcreteAssistedWithOverride.Factory.class);
factory1.create("foo");
AbstractAssisted.Factory<ConcreteAssistedWithOverride, String> factory1Abstract = factory1;
factory1Abstract.create("foo");
ConcreteAssistedWithOverride.Factory2 factory2 = injector.getInstance(ConcreteAssistedWithOverride.Factory2.class);
factory2.create("foo");
factory2.create(new StringBuilder("foo"));
AbstractAssisted.Factory<ConcreteAssistedWithOverride, String> factory2Abstract = factory2;
factory2Abstract.create("foo");
ConcreteAssistedWithoutOverride.Factory factory3 = injector.getInstance(ConcreteAssistedWithoutOverride.Factory.class);
factory3.create("foo");
AbstractAssisted.Factory<ConcreteAssistedWithoutOverride, String> factory3Abstract = factory3;
factory3Abstract.create("foo");
Public.Factory factory4 = injector.getInstance(Public.Factory.class);
factory4.create("foo");
factory4.create(new StringBuilder("foo"));
AbstractAssisted.Factory<Public, String> factory4Abstract = factory4;
factory4Abstract.create("foo");
AbstractAssisted.Factory<ConcreteAssisted, String> factory5 = injector.getInstance(concreteKey);
factory5.create("foo");
}
Aggregations