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 Project: presto   Author: prestosql   File: RedisConnectorModule.java    License: 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 #2
Source Project: digdag   Author: treasure-data   File: ServerBootstrap.java    License: 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 #3
Source Project: dropwizard-guicey   Author: xvik   File: GuiceScopingVisitor.java    License: 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 #4
Source Project: angulardemorestful   Author: draptik   File: ServerProvider.java    License: 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 #5
Source Project: Singularity   Author: HubSpot   File: SingularityDbModule.java    License: 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 #6
Source Project: saga-lib   Author: Domo42   File: SagaLibModule.java    License: 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 #7
Source Project: pinpoint   Author: naver   File: MockApplicationContextModule.java    License: 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 #8
Source Project: ribbon   Author: Netflix   File: RxMovieProxyExampleTest.java    License: 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 #9
Source Project: presto-connectors   Author: harbby   File: HbaseModule.java    License: 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 #10
Source Project: presto   Author: prestosql   File: RaptorModule.java    License: 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 #11
Source Project: james-project   Author: apache   File: RabbitMQModule.java    License: 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 Project: digdag   Author: treasure-data   File: Archive.java    License: 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 #13
Source Project: presto   Author: prestosql   File: FileAuthenticatorFactory.java    License: 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 #14
Source Project: metacat   Author: Netflix   File: SnowflakeConnectorModule.java    License: 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 #15
Source Project: biomedicus   Author: nlpie   File: BiomedicusScopes.java    License: 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 #16
Source Project: presto   Author: prestosql   File: KinesisModule.java    License: 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 #17
Source Project: metacat   Author: Netflix   File: MySqlConnectorModule.java    License: 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 #18
Source Project: paraflow   Author: dbiir   File: ParaflowModule.java    License: 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 #19
Source Project: callerid-for-android   Author: candrews   File: CallerIDModule.java    License: 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 #20
Source Project: kubesql   Author: xuxinkun   File: KubeModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void configure(Binder binder)
{
    configBinder(binder).bindConfig(KubeConfig.class);

    binder.bind(KubeConnector.class).in(Scopes.SINGLETON);
    binder.bind(KubeMetadata.class).in(Scopes.SINGLETON);
    binder.bind(KubeSplitManager.class).in(Scopes.SINGLETON);
    binder.bind(KubeRecordSetProvider.class).in(Scopes.SINGLETON);
    binder.bind(KubeHandleResolver.class).in(Scopes.SINGLETON);
    binder.bind(KubeTables.class).in(Scopes.SINGLETON);

}
 
Example #21
Source Project: Singularity   Author: HubSpot   File: SingularityJsonTranscoderBinder.java    License: Apache License 2.0 5 votes vote down vote up
public <T> void asJson(Class<T> clazz) {
  TypeToken<Transcoder<T>> typeToken = new TypeToken<Transcoder<T>>() {}
  .where(new TypeParameter<T>() {}, clazz);
  @SuppressWarnings("unchecked")
  Key<Transcoder<T>> key = (Key<Transcoder<T>>) Key.get(typeToken.getType());
  binder
    .bind(key)
    .toProvider(new JsonTranscoderProvider<T>(clazz))
    .in(Scopes.SINGLETON);
}
 
Example #22
Source Project: james-project   Author: apache   File: JMAPCommonModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    bind(JamesSignatureHandler.class).in(Scopes.SINGLETON);
    bind(DefaultZonedDateTimeProvider.class).in(Scopes.SINGLETON);
    bind(SignedTokenManager.class).in(Scopes.SINGLETON);
    bind(AccessTokenManagerImpl.class).in(Scopes.SINGLETON);
    bind(MailSpool.class).in(Scopes.SINGLETON);
    bind(MailboxFactory.class).in(Scopes.SINGLETON);

    bind(MessageFullViewFactory.class).in(Scopes.SINGLETON);
    bind(MessageMetadataViewFactory.class).in(Scopes.SINGLETON);
    bind(MessageHeaderViewFactory.class).in(Scopes.SINGLETON);
    bind(MessageFastViewFactory.class).in(Scopes.SINGLETON);

    bind(MessageContentExtractor.class).in(Scopes.SINGLETON);
    bind(SecurityKeyLoader.class).in(Scopes.SINGLETON);

    bind(SignatureHandler.class).to(JamesSignatureHandler.class);
    bind(ZonedDateTimeProvider.class).to(DefaultZonedDateTimeProvider.class);
    bind(SimpleTokenManager.class).to(SignedTokenManager.class);
    bind(SimpleTokenFactory.class).to(SignedTokenFactory.class);

    bindConstant().annotatedWith(Names.named(AccessTokenRepository.TOKEN_EXPIRATION_IN_MS)).to(DEFAULT_TOKEN_EXPIRATION_IN_MS);
    bind(AccessTokenManager.class).to(AccessTokenManagerImpl.class);

    Multibinder.newSetBinder(binder(), MailboxListener.ReactiveGroupMailboxListener.class)
        .addBinding()
        .to(ComputeMessageFastViewProjectionListener.class);

    Multibinder.newSetBinder(binder(), StartUpCheck.class)
        .addBinding().to(JMAPConfigurationStartUpCheck.class);
}
 
Example #23
Source Project: james-project   Author: apache   File: TaskManagerModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    install(new HostnameModule());
    install(new TaskSerializationModule());

    bind(MemoryTaskManager.class).in(Scopes.SINGLETON);
    bind(TaskManager.class).to(MemoryTaskManager.class);
}
 
Example #24
Source Project: EDDI   Author: labsai   File: TemplateEngineModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    bind(ITemplatingEngine.class).to(TemplatingEngine.class).in(Scopes.SINGLETON);

    MapBinder<String, ILifecycleTask> lifecycleTaskPlugins
            = MapBinder.newMapBinder(binder(), String.class, ILifecycleTask.class);
    lifecycleTaskPlugins.addBinding("ai.labs.templating").to(OutputTemplateTask.class);
}
 
Example #25
Source Project: presto   Author: prestosql   File: RedisConnectorFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context)
{
    requireNonNull(catalogName, "catalogName is null");
    requireNonNull(config, "config is null");

    Bootstrap app = new Bootstrap(
            new JsonModule(),
            new RedisConnectorModule(),
            binder -> {
                binder.bind(TypeManager.class).toInstance(context.getTypeManager());
                binder.bind(NodeManager.class).toInstance(context.getNodeManager());

                if (tableDescriptionSupplier.isPresent()) {
                    binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, RedisTableDescription>>>() {}).toInstance(tableDescriptionSupplier.get());
                }
                else {
                    binder.bind(new TypeLiteral<Supplier<Map<SchemaTableName, RedisTableDescription>>>() {})
                            .to(RedisTableDescriptionSupplier.class)
                            .in(Scopes.SINGLETON);
                }
            });

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

    return injector.getInstance(RedisConnector.class);
}
 
Example #26
Source Project: pinpoint   Author: naver   File: ApplicationContextModule.java    License: Apache License 2.0 5 votes vote down vote up
private void bindServiceComponent() {
    bind(SimpleCacheFactory.class).toProvider(SimpleCacheFactoryProvider.class).in(Scopes.SINGLETON);
    bind(StringMetaDataService.class).toProvider(StringMetadataServiceProvider.class).in(Scopes.SINGLETON);
    bind(ApiMetaDataService.class).toProvider(ApiMetaDataServiceProvider.class).in(Scopes.SINGLETON);
    bind(SqlMetaDataService.class).toProvider(SqlMetadataServiceProvider.class).in(Scopes.SINGLETON);
    bind(PredefinedMethodDescriptorRegistry.class).to(DefaultPredefinedMethodDescriptorRegistry.class).in(Scopes.SINGLETON);
}
 
Example #27
Source Project: james-project   Author: apache   File: JMAPModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    install(new JMAPCommonModule());
    install(new DraftMethodsModule());
    install(new RFC8621MethodsModule());
    install(binder -> binder
        .bind(CamelMailetContainerModule.DefaultProcessorsConfigurationSupplier.class)
        .toInstance(DEFAULT_JMAP_PROCESSORS_CONFIGURATION_SUPPLIER));

    bind(JMAPServer.class).in(Scopes.SINGLETON);
    bind(RequestHandler.class).in(Scopes.SINGLETON);
    bind(JsoupHtmlTextExtractor.class).in(Scopes.SINGLETON);

    bind(HtmlTextExtractor.class).to(JsoupHtmlTextExtractor.class);
    Multibinder.newSetBinder(binder(), StartUpCheck.class).addBinding().to(RequiredCapabilitiesStartUpCheck.class);

    Multibinder<CamelMailetContainerModule.TransportProcessorCheck> transportProcessorChecks = Multibinder.newSetBinder(binder(), CamelMailetContainerModule.TransportProcessorCheck.class);
    transportProcessorChecks.addBinding().toInstance(VACATION_MAILET_CHECK);
    transportProcessorChecks.addBinding().toInstance(FILTERING_MAILET_CHECK);

    bind(MailQueueItemDecoratorFactory.class).to(PostDequeueDecoratorFactory.class).in(Scopes.SINGLETON);

    Multibinder.newSetBinder(binder(), MailboxListener.GroupMailboxListener.class).addBinding().to(PropagateLookupRightListener.class);

    Multibinder<Version> supportedVersions = Multibinder.newSetBinder(binder(), Version.class);
    supportedVersions.addBinding().toInstance(Version.DRAFT);
    supportedVersions.addBinding().toInstance(Version.RFC8621);
}
 
Example #28
Source Project: presto   Author: prestosql   File: PinotModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void configure(Binder binder)
{
    configBinder(binder).bindConfig(PinotConfig.class);
    binder.bind(PinotConnector.class).in(Scopes.SINGLETON);
    binder.bind(PinotMetadata.class).in(Scopes.SINGLETON);
    binder.bind(PinotSplitManager.class).in(Scopes.SINGLETON);
    binder.bind(PinotPageSourceProvider.class).in(Scopes.SINGLETON);
    binder.bind(PinotClient.class).in(Scopes.SINGLETON);
    binder.bind(Executor.class).annotatedWith(ForPinot.class)
            .toInstance(newCachedThreadPool(threadsNamed("pinot-metadata-fetcher-" + catalogName)));

    binder.bind(PinotSessionProperties.class).in(Scopes.SINGLETON);
    binder.bind(PinotNodePartitioningProvider.class).in(Scopes.SINGLETON);
    httpClientBinder(binder).bindHttpClient("pinot", ForPinot.class)
            .withConfigDefaults(cfg -> {
                cfg.setIdleTimeout(new Duration(300, SECONDS));
                cfg.setConnectTimeout(new Duration(300, SECONDS));
                cfg.setRequestTimeout(new Duration(300, SECONDS));
                cfg.setMaxConnectionsPerServer(250);
                cfg.setMaxContentLength(DataSize.of(32, MEGABYTE));
                cfg.setSelectorCount(10);
                cfg.setTimeoutThreads(8);
                cfg.setTimeoutConcurrency(4);
            });

    jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
    jsonBinder(binder).addDeserializerBinding(DataSchema.class).to(DataSchemaDeserializer.class);
    PinotClient.addJsonBinders(jsonCodecBinder(binder));
    binder.bind(MBeanServer.class).toInstance(new RebindSafeMBeanServer(getPlatformMBeanServer()));
    binder.bind(TypeManager.class).toInstance(typeManager);
    binder.bind(NodeManager.class).toInstance(nodeManager);
    binder.bind(PinotMetrics.class).in(Scopes.SINGLETON);
    newExporter(binder).export(PinotMetrics.class).as(generatedNameOf(PinotMetrics.class, catalogName));
    binder.bind(ConnectorNodePartitioningProvider.class).to(PinotNodePartitioningProvider.class).in(Scopes.SINGLETON);
}
 
Example #29
Source Project: staash   Author: Netflix   File: PaasModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    LOG.info("Loading PaasModule");
    
    bind(EventBus.class).toInstance(eventBus);
    bindListener(Matchers.any(), new TypeListener() {
        public <I> void hear(TypeLiteral<I> typeLiteral, TypeEncounter<I> typeEncounter) {
            typeEncounter.register(new InjectionListener<I>() {
                public void afterInjection(I i) {
                    eventBus.register(i);
                }
            });
        }
    });

    bind(TaskManager.class).to(InlineTaskManager.class);

    // Constants
    bind(String.class).annotatedWith(Names.named("namespace")).toInstance("com.netflix.pass.");
    bind(String.class).annotatedWith(Names.named("appname"  )).toInstance("paas");
    
    bind(AbstractConfiguration.class).toInstance(ConfigurationManager.getConfigInstance());

    // Configuration
    bind(PaasConfiguration.class).to(ArchaeusPaasConfiguration.class).in(Scopes.SINGLETON);
    
    // Stuff
    bind(ScheduledExecutorService.class).annotatedWith(Names.named("tasks")).toInstance(Executors.newScheduledThreadPool(10));
    
    bind(DaoProvider.class).in(Scopes.SINGLETON);
    
    // Rest resources
    bind(DataResource.class).in(Scopes.SINGLETON);
    bind(SchemaAdminResource.class).to(JerseySchemaAdminResourceImpl.class).in(Scopes.SINGLETON);
    bind(SchemaService.class).to(DaoSchemaService.class).in(Scopes.SINGLETON);
    
}
 
Example #30
Source Project: digdag   Author: treasure-data   File: WorkflowExecutorModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void configure(Binder binder)
{
    binder.bind(WorkflowExecutor.class).in(Scopes.SINGLETON);
    binder.bind(SlaCalculator.class).in(Scopes.SINGLETON);
    binder.bind(AttemptBuilder.class).in(Scopes.SINGLETON);

    // session
    binder.bind(SessionMonitorExecutor.class).asEagerSingleton();
}