com.google.inject.assistedinject.FactoryModuleBuilder Java Examples

The following examples show how to use com.google.inject.assistedinject.FactoryModuleBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransactionLocalModule.java    From phoenix-tephra with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
  bind(SnapshotCodecProvider.class).in(Singleton.class);
  bind(TransactionStateStorage.class).annotatedWith(Names.named("persist"))
    .to(LocalFileTransactionStateStorage.class).in(Scopes.SINGLETON);
  bind(TransactionStateStorage.class).toProvider(TransactionStateStorageProvider.class).in(Scopes.SINGLETON);

  bind(TransactionManager.class).in(Scopes.SINGLETON);
  bind(TransactionSystemClient.class).to(InMemoryTxSystemClient.class).in(Singleton.class);
  bind(MetricsCollector.class).to(DefaultMetricsCollector.class);

  bindConstant().annotatedWith(Names.named(TxConstants.CLIENT_ID)).to(clientId);

  install(new FactoryModuleBuilder()
            .implement(TransactionExecutor.class, DefaultTransactionExecutor.class)
            .build(TransactionExecutorFactory.class));
}
 
Example #2
Source File: ConnectionModule.java    From guacamole-client with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {

    // Create the required DirectoryResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryResource<Connection, APIConnection>>() {},
                ConnectionDirectoryResource.class
            )
            .build(new TypeLiteral<DirectoryResourceFactory<Connection, APIConnection>>() {}));

    // Create the required DirectoryObjectResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryObjectResource<Connection, APIConnection>>() {},
                ConnectionResource.class
            )
            .build(new TypeLiteral<DirectoryObjectResourceFactory<Connection, APIConnection>>() {}));

    // Bind translator for converting between Connection and APIConnection
    bind(new TypeLiteral<DirectoryObjectTranslator<Connection, APIConnection>>() {})
            .to(ConnectionObjectTranslator.class);

}
 
Example #3
Source File: LogPersistenceModule.java    From attic-aurora with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
  bind(new TypeLiteral<Amount<Integer, Data>>() { }).annotatedWith(MaxEntrySize.class)
      .toInstance(options.maxLogEntrySize);
  bind(LogManager.class).in(Singleton.class);
  bind(LogPersistence.class).in(Singleton.class);
  bind(Persistence.class).to(LogPersistence.class);
  expose(Persistence.class);
  expose(LogPersistence.class);

  bind(EntrySerializer.class).to(EntrySerializerImpl.class);
  // TODO(ksweeney): We don't need a cryptographic checksum here - assess performance of MD5
  // versus a faster error-detection checksum like CRC32 for large Snapshots.
  @SuppressWarnings("deprecation")
  HashFunction hashFunction = Hashing.md5();
  bind(HashFunction.class).annotatedWith(LogEntryHashFunction.class).toInstance(hashFunction);

  bind(SnapshotDeduplicator.class).to(SnapshotDeduplicatorImpl.class);

  install(new FactoryModuleBuilder()
      .implement(StreamManager.class, StreamManagerImpl.class)
      .build(StreamManagerFactory.class));
}
 
Example #4
Source File: ConnectionGroupModule.java    From guacamole-client with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {

    // Create the required DirectoryResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryResource<ConnectionGroup, APIConnectionGroup>>() {},
                ConnectionGroupDirectoryResource.class
            )
            .build(new TypeLiteral<DirectoryResourceFactory<ConnectionGroup, APIConnectionGroup>>() {}));

    // Create the required DirectoryObjectResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryObjectResource<ConnectionGroup, APIConnectionGroup>>() {},
                ConnectionGroupResource.class
            )
            .build(new TypeLiteral<DirectoryObjectResourceFactory<ConnectionGroup, APIConnectionGroup>>() {}));

    // Bind translator for converting between ConnectionGroup and APIConnectionGroup
    bind(new TypeLiteral<DirectoryObjectTranslator<ConnectionGroup, APIConnectionGroup>>() {})
            .to(ConnectionGroupObjectTranslator.class);

}
 
Example #5
Source File: ActiveConnectionModule.java    From guacamole-client with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {

    // Create the required DirectoryResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryResource<ActiveConnection, APIActiveConnection>>() {},
                ActiveConnectionDirectoryResource.class
            )
            .build(new TypeLiteral<DirectoryResourceFactory<ActiveConnection, APIActiveConnection>>() {}));

    // Create the required DirectoryObjectResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryObjectResource<ActiveConnection, APIActiveConnection>>() {},
                ActiveConnectionResource.class
            )
            .build(new TypeLiteral<DirectoryObjectResourceFactory<ActiveConnection, APIActiveConnection>>() {}));

    // Bind translator for converting between ActiveConnection and APIActiveConnection
    bind(new TypeLiteral<DirectoryObjectTranslator<ActiveConnection, APIActiveConnection>>() {})
            .to(ActiveConnectionObjectTranslator.class);

}
 
Example #6
Source File: UserGroupModule.java    From guacamole-client with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {

    // Create the required DirectoryResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryResource<UserGroup, APIUserGroup>>() {},
                UserGroupDirectoryResource.class
            )
            .build(new TypeLiteral<DirectoryResourceFactory<UserGroup, APIUserGroup>>() {}));

    // Create the required DirectoryObjectResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryObjectResource<UserGroup, APIUserGroup>>() {},
                UserGroupResource.class
            )
            .build(new TypeLiteral<DirectoryObjectResourceFactory<UserGroup, APIUserGroup>>() {}));

    // Bind translator for converting between UserGroup and APIUserGroup
    bind(new TypeLiteral<DirectoryObjectTranslator<UserGroup, APIUserGroup>>() {})
            .to(UserGroupObjectTranslator.class);

}
 
Example #7
Source File: ConnectionGroupModule.java    From guacamole-client with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {

    // Create the required DirectoryResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryResource<ConnectionGroup, APIConnectionGroup>>() {},
                ConnectionGroupDirectoryResource.class
            )
            .build(new TypeLiteral<DirectoryResourceFactory<ConnectionGroup, APIConnectionGroup>>() {}));

    // Create the required DirectoryObjectResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryObjectResource<ConnectionGroup, APIConnectionGroup>>() {},
                ConnectionGroupResource.class
            )
            .build(new TypeLiteral<DirectoryObjectResourceFactory<ConnectionGroup, APIConnectionGroup>>() {}));

    // Bind translator for converting between ConnectionGroup and APIConnectionGroup
    bind(new TypeLiteral<DirectoryObjectTranslator<ConnectionGroup, APIConnectionGroup>>() {})
            .to(ConnectionGroupObjectTranslator.class);

}
 
Example #8
Source File: DefaultKernelControlCenterExtensionsModule.java    From openAGV with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
private void configureControlCenterDependencies() {
  KernelControlCenterConfiguration configuration
      = getConfigBindingProvider().get(KernelControlCenterConfiguration.PREFIX,
                                       KernelControlCenterConfiguration.class);
  bind(KernelControlCenterConfiguration.class).toInstance(configuration);

  Multibinder<org.opentcs.components.kernel.ControlCenterPanel> modellingBinder
      = controlCenterPanelBinderModelling();
  // No extensions for modelling mode, yet.

  Multibinder<org.opentcs.components.kernel.ControlCenterPanel> operatingBinder
      = controlCenterPanelBinderOperating();
  operatingBinder.addBinding().to(DriverGUI.class);

  install(new FactoryModuleBuilder().build(ControlCenterInfoHandlerFactory.class));

  bind(KernelControlCenter.class).in(Singleton.class);
}
 
Example #9
Source File: ConnectionModule.java    From guacamole-client with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {

    // Create the required DirectoryResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryResource<Connection, APIConnection>>() {},
                ConnectionDirectoryResource.class
            )
            .build(new TypeLiteral<DirectoryResourceFactory<Connection, APIConnection>>() {}));

    // Create the required DirectoryObjectResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryObjectResource<Connection, APIConnection>>() {},
                ConnectionResource.class
            )
            .build(new TypeLiteral<DirectoryObjectResourceFactory<Connection, APIConnection>>() {}));

    // Bind translator for converting between Connection and APIConnection
    bind(new TypeLiteral<DirectoryObjectTranslator<Connection, APIConnection>>() {})
            .to(ConnectionObjectTranslator.class);

}
 
Example #10
Source File: UserModule.java    From guacamole-client with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {

    // Create the required DirectoryResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryResource<User, APIUser>>() {},
                UserDirectoryResource.class
            )
            .build(new TypeLiteral<DirectoryResourceFactory<User, APIUser>>() {}));

    // Create the required DirectoryObjectResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryObjectResource<User, APIUser>>() {},
                UserResource.class
            )
            .build(new TypeLiteral<DirectoryObjectResourceFactory<User, APIUser>>() {}));

    // Bind translator for converting between User and APIUser
    bind(new TypeLiteral<DirectoryObjectTranslator<User, APIUser>>() {})
            .to(UserObjectTranslator.class);

}
 
Example #11
Source File: UserModule.java    From guacamole-client with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {

    // Create the required DirectoryResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryResource<User, APIUser>>() {},
                UserDirectoryResource.class
            )
            .build(new TypeLiteral<DirectoryResourceFactory<User, APIUser>>() {}));

    // Create the required DirectoryObjectResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryObjectResource<User, APIUser>>() {},
                UserResource.class
            )
            .build(new TypeLiteral<DirectoryObjectResourceFactory<User, APIUser>>() {}));

    // Bind translator for converting between User and APIUser
    bind(new TypeLiteral<DirectoryObjectTranslator<User, APIUser>>() {})
            .to(UserObjectTranslator.class);

}
 
Example #12
Source File: SharingProfileModule.java    From guacamole-client with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {

    // Create the required DirectoryResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryResource<SharingProfile, APISharingProfile>>() {},
                SharingProfileDirectoryResource.class
            )
            .build(new TypeLiteral<DirectoryResourceFactory<SharingProfile, APISharingProfile>>() {}));

    // Create the required DirectoryObjectResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryObjectResource<SharingProfile, APISharingProfile>>() {},
                SharingProfileResource.class
            )
            .build(new TypeLiteral<DirectoryObjectResourceFactory<SharingProfile, APISharingProfile>>() {}));

    // Bind translator for converting between SharingProfile and APISharingProfile
    bind(new TypeLiteral<DirectoryObjectTranslator<SharingProfile, APISharingProfile>>() {})
            .to(SharingProfileObjectTranslator.class);

}
 
Example #13
Source File: GenericBindingStrategy.java    From seed with Mozilla Public License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void bindKey(Binder binder, FactoryModuleBuilder guiceFactoryBuilder, Type[] params, Key<?> defaultKey) {
    // If a default key is provided use a linked binding to bind it
    if (defaultKey != null) {
        binder.bind(defaultKey.getTypeLiteral()).to((Key) defaultKey);
    }
    // Get the key to bind
    Key<T> key = BindingUtils.resolveKey(injecteeClass, genericImplClass, params);

    // Prepare the Guice provider
    Provider<?> provider = new GenericGuiceProvider<T>(genericImplClass, params);
    binder.requestInjection(provider);
    binder.bind(key).toProvider((Provider) provider);

    // Prepare the factory for assisted injection
    guiceFactoryBuilder.implement(key, (Class) genericImplClass);
}
 
Example #14
Source File: LoopbackCommAdapterModule.java    From openAGV with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
  VirtualVehicleConfiguration configuration
      = getConfigBindingProvider().get(VirtualVehicleConfiguration.PREFIX,
                                       VirtualVehicleConfiguration.class);

  if (!configuration.enable()) {
    LOG.info("Loopback driver disabled by configuration.");
    return;
  }

  bind(VirtualVehicleConfiguration.class)
      .toInstance(configuration);

  install(new FactoryModuleBuilder().build(LoopbackAdapterComponentsFactory.class));
  
  // tag::documentation_createCommAdapterModule[]
  vehicleCommAdaptersBinder().addBinding().to(LoopbackCommunicationAdapterFactory.class);
  // end::documentation_createCommAdapterModule[]
}
 
Example #15
Source File: FactoryModule.java    From googleads-java-lib with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
  // Bind the base Guice factory interface to its typed one.
  install(
      new FactoryModuleBuilder()
          .implement(adsServiceClientTypeLiteral, adsServiceClientTypeLiteral)
          .build(adsServiceClientFactoryTypeLiteral));

  install(
      new FactoryModuleBuilder()
          .implement(adsServiceDescriptorTypeLiteral, adsServiceDescriptorTypeLiteral)
          .build(adsServiceDescriptorFactoryTypeLiteral));
  
  bind(AdsServiceClientFactoryHelper.class).to(factoryHelperClass);
  bind(factoryClass);
}
 
Example #16
Source File: GenericBindingStrategy.java    From seed with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void resolve(Binder binder) {
    // Bind all the possible types for one class or interface.
    // For instance: Repository<Customer,String>, Repository<Order, Long>, etc.
    FactoryModuleBuilder guiceFactoryBuilder = new FactoryModuleBuilder();

    if (constructorParamsMap != null) {
        for (Map.Entry<Type[], Key<?>> entry : constructorParamsMap.entrySet()) {
            bindKey(binder, guiceFactoryBuilder, entry.getKey(), entry.getValue());
        }
    } else {
        for (Type[] params : constructorParams) {
            bindKey(binder, guiceFactoryBuilder, params, null);
        }
    }

    TypeLiteral<?> guiceAssistedFactory = TypeLiteral.get(
            Types.newParameterizedType(DEFAULT_IMPL_FACTORY_CLASS, genericImplClass));
    binder.install(guiceFactoryBuilder.build(guiceAssistedFactory));
}
 
Example #17
Source File: UserGroupModule.java    From guacamole-client with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {

    // Create the required DirectoryResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryResource<UserGroup, APIUserGroup>>() {},
                UserGroupDirectoryResource.class
            )
            .build(new TypeLiteral<DirectoryResourceFactory<UserGroup, APIUserGroup>>() {}));

    // Create the required DirectoryObjectResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryObjectResource<UserGroup, APIUserGroup>>() {},
                UserGroupResource.class
            )
            .build(new TypeLiteral<DirectoryObjectResourceFactory<UserGroup, APIUserGroup>>() {}));

    // Bind translator for converting between UserGroup and APIUserGroup
    bind(new TypeLiteral<DirectoryObjectTranslator<UserGroup, APIUserGroup>>() {})
            .to(UserGroupObjectTranslator.class);

}
 
Example #18
Source File: DefaultFactoryStrategy.java    From business with Mozilla Public License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void resolve(Binder binder) {
    FactoryModuleBuilder guiceFactoryBuilder = new FactoryModuleBuilder();
    for (Map.Entry<Type, Class<?>> classes : typeVariables.entries()) {
        Type producedType = classes.getKey();
        Class<? extends T> producedImplementationType = (Class<? extends T>) classes.getValue();

        Key<T> key = BindingUtils.resolveKey(injecteeClass, producedImplementationType, producedType);
        Provider<T> provider = new GenericGuiceProvider<>(injectedClass, producedImplementationType);
        binder.requestInjection(provider);
        binder.bind(key).toProvider(provider);
        guiceFactoryBuilder.implement(key, injectedClass);
    }

    // Assisted factory should not be bound twice
    if (bindGuiceFactory) {
        TypeLiteral<?> guiceAssistedFactory = TypeLiteral.get(newParameterizedType(FACTORY_CLASS, injectedClass));
        binder.install(guiceFactoryBuilder.build(guiceAssistedFactory));
    }
}
 
Example #19
Source File: ActiveConnectionModule.java    From guacamole-client with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {

    // Create the required DirectoryResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryResource<ActiveConnection, APIActiveConnection>>() {},
                ActiveConnectionDirectoryResource.class
            )
            .build(new TypeLiteral<DirectoryResourceFactory<ActiveConnection, APIActiveConnection>>() {}));

    // Create the required DirectoryObjectResourceFactory implementation
    install(new FactoryModuleBuilder()
            .implement(
                new TypeLiteral<DirectoryObjectResource<ActiveConnection, APIActiveConnection>>() {},
                ActiveConnectionResource.class
            )
            .build(new TypeLiteral<DirectoryObjectResourceFactory<ActiveConnection, APIActiveConnection>>() {}));

    // Bind translator for converting between ActiveConnection and APIActiveConnection
    bind(new TypeLiteral<DirectoryObjectTranslator<ActiveConnection, APIActiveConnection>>() {})
            .to(ActiveConnectionObjectTranslator.class);

}
 
Example #20
Source File: ScoreKBPAgainstERE.java    From tac-kbp-eal with MIT License 6 votes vote down vote up
@Override
protected void configure() {
  bind(Parameters.class).toInstance(params);
  // declare that people can provide scoring observer plugins, even though none are
  // provided by default
  final Binder binder = binder();

  docLevelEventArgObserverBindingSite(binder);
  responseAndLinkingObserverBindingSite(binder);

  try {
    bind(EREToKBPEventOntologyMapper.class)
        .toInstance(EREToKBPEventOntologyMapper.create2016Mapping());
  } catch (IOException ioe) {
    throw new TACKBPEALException(ioe);
  }
  install(new ResponsesAndLinkingFromEREExtractor.Module());
  install(new FactoryModuleBuilder()
      .build(ResponsesAndLinkingFromKBPExtractorFactory.class));
}
 
Example #21
Source File: CheSeleniumMultiUserModule.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void configure() {
  bind(TestMachineServiceClient.class).to(CheTestMachineServiceClient.class);

  bind(DefaultTestUserProvider.class).to(MultiUserCheDefaultTestUserProvider.class);

  bind(TestUser.class).toProvider(TestUserProvider.class);
  bind(TestUserProvider.class).to(MultiUserCheTestUserProvider.class);

  bind(AdminTestUser.class).toProvider(AdminTestUserProvider.class);
  bind(AdminTestUserProvider.class).to(MultiUserCheAdminTestUserProvider.class);

  bind(TestOrganizationServiceClient.class).to(CheTestDefaultOrganizationServiceClient.class);

  install(
      new FactoryModuleBuilder()
          .build(Key.get(new TypeLiteral<TestUserFactory<AdminTestUser>>() {}.getType())));

  install(
      new FactoryModuleBuilder()
          .build(Key.get(new TypeLiteral<TestUserFactory<TestUserImpl>>() {}.getType())));

  install(new FactoryModuleBuilder().build(TestOrganizationServiceClientFactory.class));
}
 
Example #22
Source File: WsMasterModule.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
private void configureJwtProxySecureProvisioner(String infrastructure) {
  install(new FactoryModuleBuilder().build(JwtProxyProvisionerFactory.class));
  if (KubernetesInfrastructure.NAME.equals(infrastructure)) {
    install(
        new FactoryModuleBuilder()
            .build(
                new TypeLiteral<JwtProxySecureServerExposerFactory<KubernetesEnvironment>>() {}));
    MapBinder.newMapBinder(
            binder(),
            new TypeLiteral<String>() {},
            new TypeLiteral<SecureServerExposerFactory<KubernetesEnvironment>>() {})
        .addBinding("jwtproxy")
        .to(new TypeLiteral<JwtProxySecureServerExposerFactory<KubernetesEnvironment>>() {});
  } else {
    install(
        new FactoryModuleBuilder()
            .build(
                new TypeLiteral<JwtProxySecureServerExposerFactory<OpenShiftEnvironment>>() {}));
    MapBinder.newMapBinder(
            binder(),
            new TypeLiteral<String>() {},
            new TypeLiteral<SecureServerExposerFactory<OpenShiftEnvironment>>() {})
        .addBinding("jwtproxy")
        .to(new TypeLiteral<JwtProxySecureServerExposerFactory<OpenShiftEnvironment>>() {});
  }
}
 
Example #23
Source File: CompilerModule.java    From protostuff-compiler with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
    bind(CompilerRegistry.class);
    bind(CompilerUtils.class);
    bind(MarkdownProcessor.class).to(PegDownMarkdownProcessor.class).in(Scopes.SINGLETON);
    install(new FactoryModuleBuilder()
            .implement(ProtoCompiler.class, StCompiler.class)
            .build(StCompilerFactory.class));
    install(new FactoryModuleBuilder()
            .implement(ProtoCompiler.class, ExtensibleStCompiler.class)
            .build(ExtensibleStCompilerFactory.class));
    Multibinder<HtmlCompiler> htmlCompilerBinder = Multibinder.newSetBinder(binder(), HtmlCompiler.class);
    htmlCompilerBinder.addBinding().to(JsonIndexGenerator.class);
    htmlCompilerBinder.addBinding().to(JsonEnumGenerator.class);
    htmlCompilerBinder.addBinding().to(JsonMessageGenerator.class);
    htmlCompilerBinder.addBinding().to(JsonServiceGenerator.class);
    htmlCompilerBinder.addBinding().to(JsonProtoGenerator.class);
    htmlCompilerBinder.addBinding().to(JsonPagesIndexGenerator.class);
    htmlCompilerBinder.addBinding().to(JsonPageGenerator.class);
    MapBinder<String, ProtoCompiler> compilers = newMapBinder(binder(), String.class, ProtoCompiler.class);
    compilers.addBinding(HTML_COMPILER).to(HtmlGenerator.class);
    compilers.addBinding(JAVA_COMPILER).toProvider(JavaCompilerProvider.class);
    compilers.addBinding(ST4_COMPILER).toProvider(St4CompilerProvider.class);
    compilers.addBinding(DUMMY_COMPILER).to(DummyGenerator.class).in(Scopes.SINGLETON);
}
 
Example #24
Source File: CppStdTypeUtilTest.java    From joynr with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
    URL fixtureURL = CppStdTypeUtilTest.class.getResource("CppStdTypeUtil.fidl");
    ModelLoader loader = new ModelLoader(fixtureURL.getPath());
    Resource fixtureResource = loader.getResources().iterator().next();
    cppStdTypeUtil = Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            bindConstant().annotatedWith(Names.named("generationId")).to("");
            bindConstant().annotatedWith(Names.named(JoynrGeneratorExtensions.JOYNR_GENERATOR_CLEAN)).to(false);
            bindConstant().annotatedWith(Names.named(JoynrGeneratorExtensions.JOYNR_GENERATOR_GENERATE)).to(true);
            bindConstant().annotatedWith(Names.named(NamingUtil.JOYNR_GENERATOR_PACKAGEWITHVERSION)).to(false);
            bindConstant().annotatedWith(Names.named(NamingUtil.JOYNR_GENERATOR_NAMEWITHVERSION)).to(false);
            install(new FactoryModuleBuilder().build(CppTemplateFactory.class));
        }
    }).getInstance(CppStdTypeUtil.class);

    model = (FModel) fixtureResource.getContents().get(0);
}
 
Example #25
Source File: WebdriverModule.java    From bobcat with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
  Multibinder.newSetBinder(binder(), WebDriverEventListener.class);

  Multibinder<WebDriverClosedListener> closedListeners = Multibinder
      .newSetBinder(binder(), WebDriverClosedListener.class);
  closedListeners.addBinding().to(FrameSwitcher.class);
  closedListeners.addBinding().to(ProxyCloser.class);

  install(new FactoryModuleBuilder()
      .implement(ClosingAwareWebDriver.class, ClosingAwareWebDriverWrapper.class)
      .build(ClosingAwareWebDriverFactory.class));

  bind(WebDriver.class).toProvider(WebDriverProvider.class);
  bind(Actions.class).toProvider(ActionsProvider.class);
  bind(Capabilities.class).toProvider(CapabilitiesProvider.class);
  bind(JavascriptExecutor.class).toProvider(JavascriptExecutorProvider.class);
}
 
Example #26
Source File: JavaFXApplication.java    From standalone-app with Apache License 2.0 6 votes vote down vote up
@Override
public void init(List<Module> list) throws Exception {
    list.add(
            new AbstractModule() {
                @Override
                protected void configure() {
                    bind(Stage.class).annotatedWith(Names.named("mainStage")).toProvider(PRIMARY_STAGE::get);
                    bind(EditorController.class);
                }
            }
    );
    list.add(new FactoryModuleBuilder()
            .implement(DisassemblerView.class, DisassemblerView.class)
            .build(DisassemblerViewFactory.class)
    );
}
 
Example #27
Source File: TransactionDistributedModule.java    From phoenix-tephra with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
  // some of these classes need to be non-singleton in order to create a new instance during leader() in
  // TransactionService
  bind(SnapshotCodecProvider.class).in(Singleton.class);
  bind(TransactionStateStorage.class).annotatedWith(Names.named("persist")).to(HDFSTransactionStateStorage.class);
  bind(TransactionStateStorage.class).toProvider(TransactionStateStorageProvider.class);

  bindConstant().annotatedWith(Names.named(TxConstants.CLIENT_ID)).to(clientId);

  // to catch issues during configure time
  bind(TransactionManager.class);
  bind(TransactionSystemClient.class).to(TransactionServiceClient.class).in(Scopes.SINGLETON);
  bind(MetricsCollector.class).to(DefaultMetricsCollector.class);

  install(new FactoryModuleBuilder()
      .implement(TransactionExecutor.class, DefaultTransactionExecutor.class)
      .build(TransactionExecutorFactory.class));
}
 
Example #28
Source File: DefaultKernelControlCenterInjectionModule.java    From openAGV with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
  File applicationHome = new File(System.getProperty("opentcs.home", "."));
  bind(File.class)
      .annotatedWith(ApplicationHome.class)
      .toInstance(applicationHome);

  bind(LocalVehicleEntryPool.class)
      .in(Singleton.class);

  bind(KernelClientApplication.class)
      .to(KernelControlCenterApplication.class)
      .in(Singleton.class);

  install(new FactoryModuleBuilder().build(AdapterPanelComponentsFactory.class));

  configureEventBus();
  configureKernelControlCenterDependencies();
  configureExchangeInjectionModules();
}
 
Example #29
Source File: BespokeFormatStoreModule.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void configure() {
  // build Assisted-Inject factory that supplies store instances for this format
  install(new FactoryModuleBuilder().build(factoryKey));

  // create a manager that picks the right DAO class for us (the factory will pick the right store)
  FormatStoreManager storeManager = new FormatStoreManager(getProvider((Key) factoryKey), daoClasses);
  bind(FormatStoreManager.class).annotatedWith(factoryKey.getAnnotation()).toInstance(storeManager);
}
 
Example #30
Source File: CompoundTypeGeneratorTest.java    From joynr with Apache License 2.0 5 votes vote down vote up
@Test
public void testRecursiveStruct() throws Exception {
    FModel model = FrancaFactory.eINSTANCE.createFModel();
    FStructType structType = FrancaFactory.eINSTANCE.createFStructType();
    FTypeCollection typeCollection = FrancaFactory.eINSTANCE.createFTypeCollection();
    typeCollection.getTypes().add(structType);
    model.getTypeCollections().add(typeCollection);
    structType.setName("TestStruct");
    FField field = FrancaFactory.eINSTANCE.createFField();
    field.setName("exampleField");
    field.setArray(true);
    FTypeRef typeRef = FrancaFactory.eINSTANCE.createFTypeRef();
    typeRef.setDerived(structType);
    field.setType(typeRef);
    structType.getElements().add(field);

    JsTemplateFactory templateFactory = Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            install(new FactoryModuleBuilder().build(JsTemplateFactory.class));
            bind(Boolean.class).annotatedWith(Names.named(JoynrGeneratorExtensions.JOYNR_GENERATOR_GENERATE))
                               .toInstance(true);
            bind(Boolean.class).annotatedWith(Names.named(JoynrGeneratorExtensions.JOYNR_GENERATOR_CLEAN))
                               .toInstance(false);
            bind(Boolean.class).annotatedWith(Names.named(NamingUtil.JOYNR_GENERATOR_PACKAGEWITHVERSION))
                               .toInstance(false);
            bind(Boolean.class).annotatedWith(Names.named(NamingUtil.JOYNR_GENERATOR_NAMEWITHVERSION))
                               .toInstance(false);
        }
    }).getInstance(JsTemplateFactory.class);
    CompoundTypeGenerator generator = templateFactory.createCompoundTypeGenerator(structType);
    generator.generate();
}