com.google.inject.Scopes Java Examples

The following examples show how to use com.google.inject.Scopes. 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: CallerIDModule.java    From callerid-for-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void configure() {
	bind(String.class).annotatedWith(SharedPreferencesName.class).toProvider(PreferencesNameProvider.class).in(Scopes.SINGLETON);
	bind(ContactsHelper.class).toProvider(ContactsHelperProvider.class).in(Scopes.SINGLETON);
	bind(CallerIDLookup.class).to(HttpCallerIDLookup.class).in(Scopes.SINGLETON);
	bind(Geocoder.class).toProvider(GeocoderHelperProvider.class).in(Scopes.SINGLETON);
	bind(NominatimGeocoder.class).in(Scopes.SINGLETON);
	bind(VersionInformationHelper.class).in(Scopes.SINGLETON);
	bind(TextToSpeechHelper.class).in(Scopes.SINGLETON);
	bind(CountryDetector.class).in(Scopes.SINGLETON);
	
	final ObjectMapper jsonObjectMapper = new ObjectMapper();
	jsonObjectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	bind(ObjectMapper.class).annotatedWith(Names.named(("jsonObjectMapper"))).toInstance(jsonObjectMapper);
	bind(RestTemplate.class).toProvider(RestTemplateProvider.class).in(Scopes.SINGLETON);
	
}
 
Example #2
Source File: RedisConnectorModule.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(Binder binder)
{
    binder.bind(RedisConnector.class).in(Scopes.SINGLETON);

    binder.bind(RedisMetadata.class).in(Scopes.SINGLETON);
    binder.bind(RedisSplitManager.class).in(Scopes.SINGLETON);
    binder.bind(RedisRecordSetProvider.class).in(Scopes.SINGLETON);

    binder.bind(RedisJedisManager.class).in(Scopes.SINGLETON);

    configBinder(binder).bindConfig(RedisConnectorConfig.class);

    jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
    jsonCodecBinder(binder).bindJsonCodec(RedisTableDescription.class);

    binder.install(new RedisDecoderModule());
}
 
Example #3
Source File: FileAuthenticatorFactory.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public PasswordAuthenticator create(Map<String, String> config)
{
    Bootstrap app = new Bootstrap(
            binder -> {
                configBinder(binder).bindConfig(FileConfig.class);
                binder.bind(FileAuthenticator.class).in(Scopes.SINGLETON);
            });

    Injector injector = app
            .strictConfig()
            .doNotInitializeLogging()
            .setRequiredConfigurationProperties(config)
            .initialize();

    return injector.getInstance(FileAuthenticator.class);
}
 
Example #4
Source File: Archive.java    From digdag with Apache License 2.0 6 votes vote down vote up
private void archive()
        throws Exception
{
    ConfigElement systemConfig = ConfigElement.fromJson("{ \"database.migrate\" : false } }");

    try (DigdagEmbed digdag = new DigdagEmbed.Bootstrap()
            .setSystemConfig(systemConfig)
            .withWorkflowExecutor(false)
            .withScheduleExecutor(false)
            .withLocalAgent(false)
            .withTaskQueueServer(false)
            .addModules(binder -> {
                binder.bind(YamlMapper.class).in(Scopes.SINGLETON);
                binder.bind(Archiver.class).in(Scopes.SINGLETON);
                binder.bind(PrintStream.class).annotatedWith(StdOut.class).toInstance(out);
                binder.bind(PrintStream.class).annotatedWith(StdErr.class).toInstance(err);
            })
            .initializeWithoutShutdownHook()) {
        archive(digdag.getInjector());
    }
}
 
Example #5
Source File: ServerBootstrap.java    From digdag with Apache License 2.0 6 votes vote down vote up
protected DigdagEmbed.Bootstrap digdagBootstrap()
{
    return new DigdagEmbed.Bootstrap()
        .setEnvironment(serverConfig.getEnvironment())
        .setSystemConfig(serverConfig.getSystemConfig())
        .setSystemPlugins(systemPlugins)
        .overrideModulesWith((binder) -> {
            binder.bind(WorkspaceManager.class).to(ExtractArchiveWorkspaceManager.class).in(Scopes.SINGLETON);
            binder.bind(Version.class).toInstance(version);
        })
        .addModules((binder) -> {
            binder.bind(ServerRuntimeInfoWriter.class).asEagerSingleton();
            binder.bind(ServerConfig.class).toInstance(serverConfig);
            binder.bind(WorkflowExecutorLoop.class).asEagerSingleton();
            binder.bind(WorkflowExecutionTimeoutEnforcer.class).asEagerSingleton();
            binder.bind(ClientVersionChecker.class).toProvider(ClientVersionCheckerProvider.class);

            binder.bind(ErrorReporter.class).to(JmxErrorReporter.class).in(Scopes.SINGLETON);
            newExporter(binder).export(ErrorReporter.class).withGeneratedName();
        })
        .addModules(new ServerModule(serverConfig));
}
 
Example #6
Source File: GuiceScopingVisitor.java    From dropwizard-guicey with MIT License 6 votes vote down vote up
@Override
public Class<? extends Annotation> visitScope(final Scope scope) {
    Class<? extends Annotation> res = null;
    if (scope == Scopes.SINGLETON) {
        res = javax.inject.Singleton.class;
    }
    if (scope == Scopes.NO_SCOPE) {
        res = Prototype.class;
    }
    if (scope == ServletScopes.REQUEST) {
        res = RequestScoped.class;
    }
    if (scope == ServletScopes.SESSION) {
        res = SessionScoped.class;
    }
    // not supporting custom scopes
    return res;
}
 
Example #7
Source File: BiomedicusScopes.java    From biomedicus with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
protected <T> T get(Key<T> key, Provider<T> unscoped) {
  T t = (T) objectsMap.get(key);
  if (t == null) {
    synchronized (lock) {
      t = (T) objectsMap.get(key);
      if (t == null) {
        t = unscoped.get();
        if (!Scopes.isCircularProxy(t)) {
          objectsMap.put(key, t);
        }
      }
    }
  }
  return t;
}
 
Example #8
Source File: KinesisModule.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(Binder binder)
{
    // Note: handle resolver handled separately, along with several other classes.
    binder.bind(KinesisConnector.class).in(Scopes.SINGLETON);

    binder.bind(KinesisMetadata.class).in(Scopes.SINGLETON);
    binder.bind(KinesisSplitManager.class).in(Scopes.SINGLETON);
    binder.bind(KinesisRecordSetProvider.class).in(Scopes.SINGLETON);
    binder.bind(S3TableConfigClient.class).in(Scopes.SINGLETON);
    binder.bind(KinesisSessionProperties.class).in(Scopes.SINGLETON);

    configBinder(binder).bindConfig(KinesisConfig.class);

    jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
    jsonCodecBinder(binder).bindJsonCodec(KinesisStreamDescription.class);

    binder.install(new DecoderModule());

    for (KinesisInternalFieldDescription internalFieldDescription : KinesisInternalFieldDescription.values()) {
        bindInternalColumn(binder, internalFieldDescription);
    }
}
 
Example #9
Source File: ServerProvider.java    From angulardemorestful with MIT License 6 votes vote down vote up
public void createServer() throws IOException {
    System.out.println("Starting grizzly...");

    Injector injector = Guice.createInjector(new ServletModule() {
        @Override
        protected void configureServlets() {
            bind(UserService.class).to(UserServiceImpl.class);
            bind(UserRepository.class).to(UserMockRepositoryImpl.class);
            bind(DummyService.class).to(DummyServiceImpl.class);
            bind(DummyRepository.class).to(DummyMockRepositoryImpl.class);

            // hook Jackson into Jersey as the POJO <-> JSON mapper
            bind(JacksonJsonProvider.class).in(Scopes.SINGLETON);
        }
    });

    ResourceConfig rc = new PackagesResourceConfig("ngdemo.web");
    IoCComponentProviderFactory ioc = new GuiceComponentProviderFactory(rc, injector);
    server = GrizzlyServerFactory.createHttpServer(BASE_URI + "web/", rc, ioc);

    System.out.println(String.format("Jersey app started with WADL available at "
            + "%srest/application.wadl\nTry out %sngdemo\nHit enter to stop it...",
            BASE_URI, BASE_URI));
}
 
Example #10
Source File: MySqlConnectorModule.java    From metacat with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void configure() {
    this.bind(DataSource.class).toInstance(DataSourceManager.get()
        .load(this.catalogShardName, this.configuration).get(this.catalogShardName));
    this.bind(JdbcTypeConverter.class).to(MySqlTypeConverter.class).in(Scopes.SINGLETON);
    this.bind(JdbcExceptionMapper.class).to(MySqlExceptionMapper.class).in(Scopes.SINGLETON);
    this.bind(ConnectorDatabaseService.class)
        .to(ConnectorUtils.getDatabaseServiceClass(this.configuration, MySqlConnectorDatabaseService.class))
        .in(Scopes.SINGLETON);
    this.bind(ConnectorTableService.class)
        .to(ConnectorUtils.getTableServiceClass(this.configuration, MySqlConnectorTableService.class))
        .in(Scopes.SINGLETON);
    this.bind(ConnectorPartitionService.class)
        .to(ConnectorUtils.getPartitionServiceClass(this.configuration, JdbcConnectorPartitionService.class))
        .in(Scopes.SINGLETON);
}
 
Example #11
Source File: RabbitMQModule.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
    bind(EnqueuedMailsDAO.class).in(Scopes.SINGLETON);
    bind(DeletedMailsDAO.class).in(Scopes.SINGLETON);
    bind(BrowseStartDAO.class).in(Scopes.SINGLETON);
    bind(CassandraMailQueueBrowser.class).in(Scopes.SINGLETON);
    bind(CassandraMailQueueMailDelete.class).in(Scopes.SINGLETON);
    bind(CassandraMailQueueMailStore.class).in(Scopes.SINGLETON);

    Multibinder<CassandraModule> cassandraModuleBinder = Multibinder.newSetBinder(binder(), CassandraModule.class);
    cassandraModuleBinder.addBinding().toInstance(CassandraMailQueueViewModule.MODULE);

    bind(EventsourcingConfigurationManagement.class).in(Scopes.SINGLETON);
    Multibinder<EventDTOModule<? extends Event, ? extends EventDTO>> eventDTOModuleBinder = Multibinder.newSetBinder(binder(), new TypeLiteral<EventDTOModule<? extends Event, ? extends EventDTO>>() {});
    eventDTOModuleBinder.addBinding().toInstance(CassandraMailQueueViewConfigurationModule.MAIL_QUEUE_VIEW_CONFIGURATION);

    Multibinder.newSetBinder(binder(), HealthCheck.class).addBinding().to(RabbitMQHealthCheck.class);
}
 
Example #12
Source File: SnowflakeConnectorModule.java    From metacat with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void configure() {
    this.bind(DataSource.class).toInstance(DataSourceManager.get()
        .load(this.catalogShardName, this.configuration).get(this.catalogShardName));
    this.bind(JdbcTypeConverter.class).to(SnowflakeTypeConverter.class).in(Scopes.SINGLETON);
    this.bind(JdbcExceptionMapper.class).to(SnowflakeExceptionMapper.class).in(Scopes.SINGLETON);
    this.bind(ConnectorDatabaseService.class)
        .to(ConnectorUtils.getDatabaseServiceClass(this.configuration, JdbcConnectorDatabaseService.class))
        .in(Scopes.SINGLETON);
    this.bind(ConnectorTableService.class)
        .to(ConnectorUtils.getTableServiceClass(this.configuration, SnowflakeConnectorTableService.class))
        .in(Scopes.SINGLETON);
    this.bind(ConnectorPartitionService.class)
        .to(ConnectorUtils.getPartitionServiceClass(this.configuration, JdbcConnectorPartitionService.class))
        .in(Scopes.SINGLETON);
}
 
Example #13
Source File: ParaflowModule.java    From paraflow with Apache License 2.0 6 votes vote down vote up
/**
 * Contributes bindings and other configurations for this module to {@code binder}.
 *
 * @param binder binder
 */
@Override
public void configure(Binder binder)
{
    binder.bind(ParaflowConnectorId.class).toInstance(new ParaflowConnectorId(connectorId));
    binder.bind(TypeManager.class).toInstance(typeManager);

    configBinder(binder).bindConfig(ParaflowPrestoConfig.class);

    binder.bind(ParaflowMetadataFactory.class).in(Scopes.SINGLETON);
    binder.bind(ParaflowMetadata.class).in(Scopes.SINGLETON);
    binder.bind(ParaflowMetaDataReader.class).in(Scopes.SINGLETON);
    binder.bind(FSFactory.class).in(Scopes.SINGLETON);
    binder.bind(ParaflowConnector.class).in(Scopes.SINGLETON);
    binder.bind(ParaflowSplitManager.class).in(Scopes.SINGLETON);
    binder.bind(ParaflowPageSourceProvider.class).in(Scopes.SINGLETON);
    binder.bind(ClassLoader.class).toInstance(ParaflowPlugin.getClassLoader());

    jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
}
 
Example #14
Source File: HbaseModule.java    From presto-connectors with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(Binder binder)
{
    configBinder(binder).bindConfig(HbaseConfig.class);

    binder.bind(HbaseClient.class).in(Scopes.SINGLETON);

    binder.bind(HbaseConnector.class).in(Scopes.SINGLETON);
    binder.bind(HbaseMetadata.class).in(Scopes.SINGLETON);
    binder.bind(HbaseSplitManager.class).in(Scopes.SINGLETON);
    binder.bind(HbaseRecordSetProvider.class).in(Scopes.SINGLETON);
    binder.bind(HbasePageSinkProvider.class).in(Scopes.SINGLETON);

    binder.bind(ZooKeeperMetadataManager.class).in(Scopes.SINGLETON);
    binder.bind(HbaseTableProperties.class).in(Scopes.SINGLETON);
    binder.bind(HbaseSessionProperties.class).in(Scopes.SINGLETON);
    binder.bind(HbaseTableManager.class).in(Scopes.SINGLETON);

    binder.bind(Connection.class).toProvider(ConnectionProvider.class).in(Scopes.SINGLETON);
}
 
Example #15
Source File: RxMovieProxyExampleTest.java    From ribbon with Apache License 2.0 6 votes vote down vote up
@Test
public void testTransportFactoryWithInjection() {
    Injector injector = Guice.createInjector(
            new AbstractModule() {
                @Override
                protected void configure() {
                    bind(ClientConfigFactory.class).to(MyClientConfigFactory.class).in(Scopes.SINGLETON);
                    bind(RibbonTransportFactory.class).to(DefaultRibbonTransportFactory.class).in(Scopes.SINGLETON);
                }
            }
    );

    RibbonTransportFactory transportFactory = injector.getInstance(RibbonTransportFactory.class);
    HttpClient<ByteBuf, ByteBuf> client = transportFactory.newHttpClient("myClient");
    IClientConfig config = ((LoadBalancingHttpClient) client).getClientConfig();
    assertEquals("MyConfig", config.getNameSpace());
}
 
Example #16
Source File: MockApplicationContextModule.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
    logger.info("configure {}", this.getClass().getSimpleName());

    bind(TraceDataFormatVersion.class).toInstance(TraceDataFormatVersion.V1);
    bind(StorageFactory.class).to(TestSpanStorageFactory.class);

    ServerMetaDataRegistryService serverMetaDataRegistryService = newServerMetaDataRegistryService();
    bind(ServerMetaDataRegistryService.class).toInstance(serverMetaDataRegistryService);

    ClassLoader defaultClassLoader = ClassLoaderUtils.getDefaultClassLoader();
    bind(ClassLoader.class).annotatedWith(PluginClassLoader.class).toInstance(defaultClassLoader);
    bind(PluginSetup.class).toProvider(MockPluginSetupProvider.class).in(Scopes.SINGLETON);
    bind(ProfilerPluginContextLoader.class).toProvider(MockProfilerPluginContextLoaderProvider.class).in(Scopes.SINGLETON);
    bind(PluginContextLoadResult.class).toProvider(MockPluginContextLoadResultProvider.class).in(Scopes.SINGLETON);
}
 
Example #17
Source File: SagaLibModule.java    From saga-lib with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void configure() {
    bindIfNotNull(StateStorage.class, stateStorage, Scopes.SINGLETON);
    bindIfNotNull(TimeoutManager.class, timeoutManager, Scopes.SINGLETON);
    bindIfNotNull(TypeScanner.class, scanner, Scopes.SINGLETON);
    bindIfNotNull(SagaProviderFactory.class, providerFactory, Scopes.SINGLETON);
    bindIfNotNull(StrategyFinder.class, strategyFinder, Scopes.SINGLETON);
    bindIfNotNull(HandlerInvoker.class, invoker, Scopes.SINGLETON);
    bindIfNotNull(ModuleCoordinatorFactory.class, coordinatorFactory, Scopes.SINGLETON);

    bindIfNotNull(CurrentExecutionContext.class, executionContext);
    bind(ExecutionContext.class).toProvider(binder().getProvider(CurrentExecutionContext.class));

    bind(SagaInstanceCreator.class).in(Singleton.class);
    bind(SagaInstanceFactory.class).in(Singleton.class);
    bind(InstanceResolver.class).to(StrategyInstanceResolver.class).in(Singleton.class);
    bind(MessageStream.class).to(SagaMessageStream.class).in(Singleton.class);
    bind(KeyExtractor.class).to(SagaKeyReaderExtractor.class).in(Singleton.class);

    bindModules();
    bindExecutor();
    bindInterceptors();
}
 
Example #18
Source File: RaptorModule.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(Binder binder)
{
    binder.bind(RaptorConnectorId.class).toInstance(new RaptorConnectorId(connectorId));
    binder.bind(RaptorConnector.class).in(Scopes.SINGLETON);
    binder.bind(RaptorMetadataFactory.class).in(Scopes.SINGLETON);
    binder.bind(RaptorSplitManager.class).in(Scopes.SINGLETON);
    binder.bind(RaptorPageSourceProvider.class).in(Scopes.SINGLETON);
    binder.bind(RaptorPageSinkProvider.class).in(Scopes.SINGLETON);
    binder.bind(RaptorHandleResolver.class).in(Scopes.SINGLETON);
    binder.bind(RaptorNodePartitioningProvider.class).in(Scopes.SINGLETON);
    binder.bind(RaptorSessionProperties.class).in(Scopes.SINGLETON);
    binder.bind(RaptorTableProperties.class).in(Scopes.SINGLETON);

    Multibinder<SystemTable> tableBinder = newSetBinder(binder, SystemTable.class);
    tableBinder.addBinding().to(ShardMetadataSystemTable.class).in(Scopes.SINGLETON);
    tableBinder.addBinding().to(TableMetadataSystemTable.class).in(Scopes.SINGLETON);
    tableBinder.addBinding().to(TableStatsSystemTable.class).in(Scopes.SINGLETON);
}
 
Example #19
Source File: SingularityDbModule.java    From Singularity with Apache License 2.0 6 votes vote down vote up
private void bindSpecificDatabase() {
  if (isPostgres(configuration)) {
    bind(HistoryJDBI.class)
      .toProvider(PostgresHistoryJDBIProvider.class)
      .in(Scopes.SINGLETON);
    bind(TaskUsageJDBI.class)
      .toProvider(PostgresTaskUsageJDBIProvider.class)
      .in(Scopes.SINGLETON);
    // Currently many unit tests use h2
  } else if (isMySQL(configuration) || isH2(configuration)) {
    bind(HistoryJDBI.class)
      .toProvider(MySQLHistoryJDBIProvider.class)
      .in(Scopes.SINGLETON);
    bind(TaskUsageJDBI.class)
      .toProvider(MySQLTaskUsageJDBIProvider.class)
      .in(Scopes.SINGLETON);
  } else {
    throw new IllegalStateException(
      "Unknown driver class present " + configuration.get().getDriverClass()
    );
  }
}
 
Example #20
Source File: ConversationMemoryModule.java    From EDDI with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    bind(IConversationDescriptorStore.class).to(ConversationDescriptorStore.class).in(Scopes.SINGLETON);
    bind(IConversationMemoryStore.class).to(ConversationMemoryStore.class).in(Scopes.SINGLETON);
    bind(IMemoryItemConverter.class).to(MemoryItemConverter.class).in(Scopes.SINGLETON);
    bind(IDataFactory.class).to(DataFactory.class).in(Scopes.SINGLETON);
}
 
Example #21
Source File: InconsistencySolvingRoutesModule.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    bind(CassandraMappingsRoutes.class).in(Scopes.SINGLETON);
    bind(CassandraMappingsService.class).in(Scopes.SINGLETON);

    Multibinder<Routes> routesMultibinder = Multibinder.newSetBinder(binder(), Routes.class);
    routesMultibinder.addBinding().to(CassandraMappingsRoutes.class);
}
 
Example #22
Source File: InjectionStore.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
public <T> T provide(Key<T> key, Provider<T> provider) {
    T t = (T) map.get(key);
    if(t != null) return t;

    t = provider.get();
    if(!Scopes.isCircularProxy(t)) {
        store(key, t);
    }

    return t;
}
 
Example #23
Source File: SharedContributionWithJDT.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void configure(Binder binder) {
	binder.bind(JarEntryLocator.class);
	
	binder.bind(JavaProjectClasspathChangeAnalyzer.class);
	binder.bind(ProjectClasspathChangeListener.class);
	binder.bind(SimpleProjectDependencyGraph.class);
	
	binder.bind(JavaProjectsStateHelper.class);
	binder.bind(JavaProjectsState.class);
	binder.bind(StrictJavaProjectsState.class);
	
	binder.bind(IEagerContribution.class).to(JavaCoreListenerRegistrar.class);
	
	binder.bind(IStorage2UriMapperJdtExtensions.class).to(Storage2UriMapperJavaImpl.class);
	binder.bind(IStorage2UriMapperContribution.class).to(Storage2UriMapperJavaImpl.class);
	binder.bind(Storage2UriMapperJavaImpl.class).in(Scopes.SINGLETON);
	
	binder.bind(IStorageAwareTraceContribution.class).to(JarEntryAwareTrace.class);
	
	binder.bind(IResourceSetInitializer.class).to(JavaProjectResourceSetInitializer.class);
	
	binder.bind(IToBeBuiltComputerContribution.class).to(JdtToBeBuiltComputer.class);
	binder.bind(IQueuedBuildDataContribution.class).to(JdtQueuedBuildData.class);
	binder.bind(TypeURIHelper.class);
	binder.bind(ModificationStampCache.class);
	
}
 
Example #24
Source File: SieveJPARepositoryModules.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    bind(JPASieveRepository.class).in(Scopes.SINGLETON);

    bind(SieveRepository.class).to(JPASieveRepository.class);
    bind(SieveQuotaRepository.class).to(JPASieveRepository.class);
}
 
Example #25
Source File: BlobStoreCacheModulesChooser.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    bind(CassandraBlobStoreCache.class).in(Scopes.SINGLETON);
    bind(BlobStoreCache.class).to(CassandraBlobStoreCache.class);

    Multibinder.newSetBinder(binder(), CassandraModule.class, Names.named(InjectionNames.CACHE))
        .addBinding()
        .toInstance(CassandraBlobCacheModule.MODULE);
}
 
Example #26
Source File: MemoryDataModule.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    install(new SieveFileRepositoryModule());

    bind(EventSourcingDLPConfigurationStore.class).in(Scopes.SINGLETON);
    bind(DLPConfigurationStore.class).to(EventSourcingDLPConfigurationStore.class);

    bind(MemoryDomainList.class).in(Scopes.SINGLETON);
    bind(DomainList.class).to(MemoryDomainList.class);

    bind(MemoryRecipientRewriteTable.class).in(Scopes.SINGLETON);
    bind(RecipientRewriteTable.class).to(MemoryRecipientRewriteTable.class);

    bind(AliasReverseResolverImpl.class).in(Scopes.SINGLETON);
    bind(AliasReverseResolver.class).to(AliasReverseResolverImpl.class);

    bind(CanSendFromImpl.class).in(Scopes.SINGLETON);
    bind(CanSendFrom.class).to(CanSendFromImpl.class);

    bind(MemoryMailRepositoryUrlStore.class).in(Scopes.SINGLETON);
    bind(MailRepositoryUrlStore.class).to(MemoryMailRepositoryUrlStore.class);

    bind(EventSourcingDLPConfigurationStore.class).in(Scopes.SINGLETON);
    bind(DLPConfigurationStore.class).to(EventSourcingDLPConfigurationStore.class);

    bind(UsersRepository.class).to(MemoryUsersRepository.class);

    bind(MailStoreRepositoryModule.DefaultItemSupplier.class).toInstance(() -> MEMORY_MAILREPOSITORY_DEFAULT_DECLARATION);
}
 
Example #27
Source File: StorageModule.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(Binder binder)
{
    configBinder(binder).bindConfig(StorageManagerConfig.class);
    configBinder(binder).bindConfig(BucketBalancerConfig.class);
    configBinder(binder).bindConfig(ShardCleanerConfig.class);
    configBinder(binder).bindConfig(MetadataConfig.class);

    binder.bind(Ticker.class).toInstance(Ticker.systemTicker());

    binder.bind(StorageManager.class).to(OrcStorageManager.class).in(Scopes.SINGLETON);
    binder.bind(StorageService.class).to(FileStorageService.class).in(Scopes.SINGLETON);
    binder.bind(ShardManager.class).to(DatabaseShardManager.class).in(Scopes.SINGLETON);
    binder.bind(ShardRecorder.class).to(DatabaseShardRecorder.class).in(Scopes.SINGLETON);
    binder.bind(DatabaseShardManager.class).in(Scopes.SINGLETON);
    binder.bind(DatabaseShardRecorder.class).in(Scopes.SINGLETON);
    binder.bind(ShardRecoveryManager.class).in(Scopes.SINGLETON);
    binder.bind(BackupManager.class).in(Scopes.SINGLETON);
    binder.bind(ShardCompactionManager.class).in(Scopes.SINGLETON);
    binder.bind(ShardOrganizationManager.class).in(Scopes.SINGLETON);
    binder.bind(ShardOrganizer.class).in(Scopes.SINGLETON);
    binder.bind(JobFactory.class).to(OrganizationJobFactory.class).in(Scopes.SINGLETON);
    binder.bind(ShardCompactor.class).in(Scopes.SINGLETON);
    binder.bind(ShardEjector.class).in(Scopes.SINGLETON);
    binder.bind(ShardCleaner.class).in(Scopes.SINGLETON);
    binder.bind(BucketBalancer.class).in(Scopes.SINGLETON);
    binder.bind(AssignmentLimiter.class).in(Scopes.SINGLETON);
    binder.bind(TemporalFunction.class).in(Scopes.SINGLETON);

    newExporter(binder).export(ShardRecoveryManager.class).withGeneratedName();
    newExporter(binder).export(BackupManager.class).withGeneratedName();
    newExporter(binder).export(StorageManager.class).as(generator -> generator.generatedNameOf(OrcStorageManager.class));
    newExporter(binder).export(ShardCompactionManager.class).withGeneratedName();
    newExporter(binder).export(ShardOrganizer.class).withGeneratedName();
    newExporter(binder).export(ShardCompactor.class).withGeneratedName();
    newExporter(binder).export(ShardEjector.class).withGeneratedName();
    newExporter(binder).export(ShardCleaner.class).withGeneratedName();
    newExporter(binder).export(BucketBalancer.class).withGeneratedName();
    newExporter(binder).export(JobFactory.class).withGeneratedName();
}
 
Example #28
Source File: SourceFolderCustomImplTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected com.google.inject.Module getServerModule() {
	com.google.inject.Module defaultModule = super.getServerModule();
	com.google.inject.Module customModule = new AbstractModule() {
		@Override
		protected void configure() {
			bind(IMultiRootWorkspaceConfigFactory.class)
					.to(SourceFolderCustomImplTest.CustomWorkspaceConfigFactory.class);
			bind(WorkspaceManager.class).in(Scopes.SINGLETON);
		}
	};
	return Modules2.mixin(defaultModule, customModule);
}
 
Example #29
Source File: ServerModule.java    From conductor with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    install(new CoreModule());
    install(new ValidationModule());
    install(new ArchaiusModule());
    install(new HealthModule());
    install(new JettyModule());
    install(new GRPCModule());

    bindInterceptor(Matchers.any(), Matchers.annotatedWith(Service.class), new ServiceInterceptor(getProvider(Validator.class)));
    bind(Configuration.class).to(SystemPropertiesDynomiteConfiguration.class);
    bind(ExecutorService.class).toProvider(ExecutorServiceProvider.class).in(Scopes.SINGLETON);
    bind(WorkflowSweeper.class).asEagerSingleton();
    bind(WorkflowMonitor.class).asEagerSingleton();
}
 
Example #30
Source File: SMTPServerModule.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    install(new JSPFModule());
    bind(SMTPServerFactory.class).in(Scopes.SINGLETON);
    bind(OioSMTPServerFactory.class).in(Scopes.SINGLETON);

    Multibinder.newSetBinder(binder(), GuiceProbe.class).addBinding().to(SmtpGuiceProbe.class);
}