类com.google.inject.Scopes源码实例Demo

下面列出了怎么用com.google.inject.Scopes的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: presto   文件: RedisConnectorModule.java
@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());
}
 
源代码2 项目: digdag   文件: ServerBootstrap.java
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));
}
 
源代码3 项目: dropwizard-guicey   文件: GuiceScopingVisitor.java
@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;
}
 
源代码4 项目: angulardemorestful   文件: ServerProvider.java
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));
}
 
源代码5 项目: Singularity   文件: SingularityDbModule.java
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()
    );
  }
}
 
源代码6 项目: saga-lib   文件: SagaLibModule.java
/**
 * {@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();
}
 
源代码7 项目: pinpoint   文件: MockApplicationContextModule.java
@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);
}
 
源代码8 项目: ribbon   文件: RxMovieProxyExampleTest.java
@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());
}
 
源代码9 项目: presto-connectors   文件: HbaseModule.java
@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);
}
 
源代码10 项目: presto   文件: RaptorModule.java
@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);
}
 
源代码11 项目: james-project   文件: RabbitMQModule.java
@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);
}
 
源代码12 项目: digdag   文件: Archive.java
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());
    }
}
 
源代码13 项目: presto   文件: FileAuthenticatorFactory.java
@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);
}
 
源代码14 项目: metacat   文件: SnowflakeConnectorModule.java
/**
 * {@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);
}
 
源代码15 项目: biomedicus   文件: BiomedicusScopes.java
@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;
}
 
源代码16 项目: presto   文件: KinesisModule.java
@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);
    }
}
 
源代码17 项目: metacat   文件: MySqlConnectorModule.java
/**
 * {@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);
}
 
源代码18 项目: paraflow   文件: ParaflowModule.java
/**
 * 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);
}
 
源代码19 项目: callerid-for-android   文件: CallerIDModule.java
@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);
	
}
 
源代码20 项目: kubesql   文件: KubeModule.java
@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);

}
 
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);
}
 
源代码22 项目: james-project   文件: JMAPCommonModule.java
@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);
}
 
源代码23 项目: james-project   文件: TaskManagerModule.java
@Override
protected void configure() {
    install(new HostnameModule());
    install(new TaskSerializationModule());

    bind(MemoryTaskManager.class).in(Scopes.SINGLETON);
    bind(TaskManager.class).to(MemoryTaskManager.class);
}
 
源代码24 项目: EDDI   文件: TemplateEngineModule.java
@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);
}
 
源代码25 项目: presto   文件: RedisConnectorFactory.java
@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);
}
 
源代码26 项目: pinpoint   文件: ApplicationContextModule.java
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);
}
 
源代码27 项目: james-project   文件: JMAPModule.java
@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);
}
 
源代码28 项目: presto   文件: PinotModule.java
@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);
}
 
源代码29 项目: staash   文件: PaasModule.java
@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);
    
}
 
源代码30 项目: digdag   文件: WorkflowExecutorModule.java
@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();
}
 
 类所在包
 类方法
 同包方法