Search in sources :

Example 26 with FactoryModuleBuilder

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);
}
Also used : DatasetDefinitionRegistryFactory(co.cask.cdap.data2.dataset2.DatasetDefinitionRegistryFactory) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) DefaultPreviewManager(co.cask.cdap.internal.app.preview.DefaultPreviewManager)

Example 27 with FactoryModuleBuilder

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);
}
Also used : AuthorizationContextFactory(co.cask.cdap.security.authorization.AuthorizationContextFactory) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) AuthorizerInstantiator(co.cask.cdap.security.authorization.AuthorizerInstantiator) DynamicDatasetCache(co.cask.cdap.data2.dataset2.DynamicDatasetCache) PrivilegesManager(co.cask.cdap.security.spi.authorization.PrivilegesManager) Admin(co.cask.cdap.api.Admin) DefaultAdmin(co.cask.cdap.internal.app.runtime.DefaultAdmin) Transactional(co.cask.cdap.api.Transactional)

Example 28 with FactoryModuleBuilder

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);
}
Also used : FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder)

Example 29 with FactoryModuleBuilder

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));
}
Also used : Set(java.util.Set) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) BindingFactory(com.google.gwt.inject.rebind.binding.BindingFactory) GeneratorContext(com.google.gwt.core.ext.GeneratorContext) OutputModule(com.google.gwt.inject.rebind.output.OutputModule) ResolutionModule(com.google.gwt.inject.rebind.resolution.ResolutionModule) TreeLogger(com.google.gwt.core.ext.TreeLogger) Ginjector(com.google.gwt.inject.client.Ginjector) BindingFactory(com.google.gwt.inject.rebind.binding.BindingFactory)

Example 30 with FactoryModuleBuilder

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");
}
Also used : FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) AbstractModule(com.google.inject.AbstractModule) Injector(com.google.inject.Injector) Key(com.google.inject.Key) Test(org.junit.Test)

Aggregations

FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)85 AbstractModule (com.google.inject.AbstractModule)20 Injector (com.google.inject.Injector)12 ConfigModule (co.cask.cdap.common.guice.ConfigModule)10 PrivateModule (com.google.inject.PrivateModule)10 DatasetDefinitionRegistry (co.cask.cdap.api.dataset.module.DatasetDefinitionRegistry)8 DefaultDatasetDefinitionRegistry (co.cask.cdap.data2.dataset2.DefaultDatasetDefinitionRegistry)8 InMemoryDatasetFramework (co.cask.cdap.data2.dataset2.InMemoryDatasetFramework)8 TypeLiteral (com.google.inject.TypeLiteral)8 DatasetFramework (co.cask.cdap.data2.dataset2.DatasetFramework)7 DiscoveryRuntimeModule (co.cask.cdap.common.guice.DiscoveryRuntimeModule)6 LocationRuntimeModule (co.cask.cdap.common.guice.LocationRuntimeModule)6 SystemDatasetRuntimeModule (co.cask.cdap.data.runtime.SystemDatasetRuntimeModule)6 DatasetOpExecutor (co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutor)6 DatasetDefinitionRegistryFactory (co.cask.cdap.data2.dataset2.DatasetDefinitionRegistryFactory)6 Singleton (com.google.inject.Singleton)6 TransactionManager (org.apache.tephra.TransactionManager)6 DatasetService (co.cask.cdap.data2.datafabric.dataset.service.DatasetService)5 DatasetAdminOpHTTPHandler (co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetAdminOpHTTPHandler)5 CConfiguration (co.cask.cdap.common.conf.CConfiguration)4