當前位置: 首頁>>代碼示例>>Java>>正文


Java Scopes類代碼示例

本文整理匯總了Java中com.google.inject.Scopes的典型用法代碼示例。如果您正苦於以下問題:Java Scopes類的具體用法?Java Scopes怎麽用?Java Scopes使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Scopes類屬於com.google.inject包,在下文中一共展示了Scopes類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: bindDriftClient

import com.google.inject.Scopes; //導入依賴的package包/類
private <T> DriftClientBindingBuilder bindDriftClient(Class<T> clientInterface, String configPrefix, Class<? extends Annotation> annotation)
{
    Annotation clientAnnotation = getDriftClientAnnotation(clientInterface, annotation);

    configBinder(binder).bindConfig(DriftClientConfig.class, clientAnnotation, configPrefix);

    TypeLiteral<DriftClient<T>> typeLiteral = driftClientTypeLiteral(clientInterface);

    Provider<T> instanceProvider = new DriftClientInstanceProvider<>(clientAnnotation, Key.get(typeLiteral, annotation));
    Provider<DriftClient<T>> factoryProvider = new DriftClientProvider<>(clientInterface, clientAnnotation);

    binder.bind(Key.get(clientInterface, annotation)).toProvider(instanceProvider).in(Scopes.SINGLETON);
    binder.bind(Key.get(typeLiteral, annotation)).toProvider(factoryProvider).in(Scopes.SINGLETON);

    if (annotation == DefaultClient.class) {
        binder.bind(Key.get(clientInterface)).toProvider(instanceProvider).in(Scopes.SINGLETON);
        binder.bind(Key.get(typeLiteral)).toProvider(factoryProvider).in(Scopes.SINGLETON);
    }

    return new DriftClientBindingBuilder(binder, clientAnnotation, configPrefix);
}
 
開發者ID:airlift,項目名稱:drift,代碼行數:22,代碼來源:DriftClientBinder.java

示例2: configure

import com.google.inject.Scopes; //導入依賴的package包/類
/**
 * Contributes bindings and other configurations for this module to {@code binder}.
 *
 * @param binder binder
 */
@Override
public void configure(Binder binder)
{
    binder.bind(HDFSConnectorId.class).toInstance(new HDFSConnectorId(connectorId));
    binder.bind(TypeManager.class).toInstance(typeManager);

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

    binder.bind(HDFSMetadataFactory.class).in(Scopes.SINGLETON);
    binder.bind(HDFSMetadata.class).in(Scopes.SINGLETON);
    binder.bind(FSFactory.class).in(Scopes.SINGLETON);
    binder.bind(HDFSConnector.class).in(Scopes.SINGLETON);
    binder.bind(HDFSSplitManager.class).in(Scopes.SINGLETON);
    binder.bind(HDFSPageSourceProvider.class).in(Scopes.SINGLETON);
    binder.bind(ClassLoader.class).toInstance(HDFSPlugin.getClassLoader());
}
 
開發者ID:dbiir,項目名稱:paraflow,代碼行數:22,代碼來源:HDFSModule.java

示例3: configure

import com.google.inject.Scopes; //導入依賴的package包/類
protected void configure() {

        bindConstant().annotatedWith(Names.named("executable.graphviz"))
                      .to(locality.getValue("executable.graphviz", "dot"));

        bind(OSWfConfiguration.class).toInstance(oswfConfiguration);
        
        // Service implementations are singletons
        bind(OSWfServiceImpl.class).in(Scopes.SINGLETON);
        bind(GraphvizServiceImpl.class).in(Scopes.SINGLETON);
        bind(WfDefinitionServiceImpl.class).in(Scopes.SINGLETON);

        // Bind interfaces to implementation classes
        bind(OSWfService.class).to(OSWfServiceImpl.class);
        bind(WfDefinitionService.class).to(WfDefinitionServiceImpl.class);
        bind(GraphvizService.class).to(GraphvizServiceImpl.class);
    }
 
開發者ID:will-gilbert,項目名稱:OSWf-OSWorkflow-fork,代碼行數:18,代碼來源:ServiceModule.java

示例4: configure

import com.google.inject.Scopes; //導入依賴的package包/類
@Override
public void configure(Binder binder)
{
    log.info("INFORMATION: AmpoolMetadata configure() called.");

    binder.bind(TypeManager.class).toInstance(typeManager);
    binder.bind(AmpoolConnectorID.class).toInstance(new AmpoolConnectorID(connectorId));
    binder.bind(AmpoolConnector.class).in(Scopes.SINGLETON);
    binder.bind(AmpoolMetadata.class).in(Scopes.SINGLETON);
    binder.bind(AmpoolClient.class).in(Scopes.SINGLETON);
    binder.bind(AmpoolSplitManager.class).in(Scopes.SINGLETON);
    binder.bind(AmpoolRecordSetProvider.class).in(Scopes.SINGLETON);
    //configBinder(binder).bindConfig(AmpoolConfig.class);

    /*
    jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
    jsonCodecBinder(binder).bindMapJsonCodec(String.class, listJsonCodec(AmpoolTable.class));
    */
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:20,代碼來源:AmpoolModule.java

示例5: configure

import com.google.inject.Scopes; //導入依賴的package包/類
@Override
protected void configure() {

    // Bind core implementations of guacamole-ext classes
    bind(AuthenticationProvider.class).toInstance(authProvider);
    bind(Environment.class).toInstance(environment);

    // Bind services
    bind(ConfigurationService.class);
    bind(UserDataService.class);

    // Bind singleton ObjectMapper for JSON serialization/deserialization
    bind(ObjectMapper.class).in(Scopes.SINGLETON);

    // Bind singleton Jersey REST client
    bind(Client.class).toInstance(Client.create(CLIENT_CONFIG));

}
 
開發者ID:glyptodon,項目名稱:guacamole-auth-callback,代碼行數:19,代碼來源:CallbackAuthenticationProviderModule.java

示例6: configure

import com.google.inject.Scopes; //導入依賴的package包/類
@Override
protected void configure()
{
	bind(Datastore.class).to(CassandraDatastore.class).in(Scopes.SINGLETON);
	bind(CassandraDatastore.class).in(Scopes.SINGLETON);
	bind(IncreaseMaxBufferSizesJob.class).in(Scopes.SINGLETON);
	bind(CleanRowKeyCache.class).in(Scopes.SINGLETON);
	bind(HectorConfiguration.class).in(Scopes.SINGLETON);
	bind(CassandraConfiguration.class).in(Scopes.SINGLETON);

	bind(new TypeLiteral<List<RowKeyListener>>()
	{
	}).toProvider(RowKeyListenerProvider.class);

	bind(new TypeLiteral<Map<String, String>>(){}).annotatedWith(Names.named(CASSANDRA_AUTH_MAP))
			.toInstance(m_authMap);

	bind(new TypeLiteral<Map<String, Object>>(){}).annotatedWith(Names.named(CASSANDRA_HECTOR_MAP))
			.toInstance(m_hectorMap);
}
 
開發者ID:quqiangsheng,項目名稱:abhot,代碼行數:21,代碼來源:CassandraModule.java

示例7: setup

import com.google.inject.Scopes; //導入依賴的package包/類
@Override
protected void setup(Binder binder)
{
    binder.disableCircularProxies();

    binder.bind(AgentMap.class).to(DiscoveryAgentMap.class).in(Scopes.SINGLETON);
    binder.bind(RequestDispatcher.class).in(Scopes.SINGLETON);
    binder.bind(Client.class).to(JerseyClient.class).in(Scopes.SINGLETON);
    binder.bind(ResponseWrapper.class);

    jaxrsBinder(binder).bind(ControllerConfigAPI.class);
    jaxrsBinder(binder).bind(ControllerConnectorAPI.class);
    jaxrsBinder(binder).bind(ControllerLogsAPI.class);
    jaxrsBinder(binder).bind(ControllerPackageAPI.class);
    jaxrsBinder(binder).bind(ControllerControlAPI.class);
    jaxrsBinder(binder).bind(InstantConverterProvider.class);

    discoveryBinder(binder).bindSelector("presto-manager");
}
 
開發者ID:prestodb,項目名稱:presto-manager,代碼行數:20,代碼來源:ControllerServerModule.java

示例8: module

import com.google.inject.Scopes; //導入依賴的package包/類
public static <C> PrivateModule module(final PropertyIdentifier propertyIdentifier, final ConfigDescriptor desc)
{
    return new PrivateModule()
    {
        @Override
        protected void configure()
        {
            // Alias the private module scoped bindings for the un-annotated ConstantValuePropertyAccessor and PropertyIdentifier to globally scoped and annotated ones.
            // Intent here is to make the implementation of this nice and guicified but support a number of different instances.
            bind(ConstantValuePropertyAccessor.class).to(Key.get(ConstantValuePropertyAccessor.class, propertyIdentifier));
            bind(PropertyIdentifier.class).to(Key.get(PropertyIdentifier.class, propertyIdentifier));

            TypeLiteral<PropertyAccessor<C>> accessorType = (TypeLiteral<PropertyAccessor<C>>) TypeLiteral.get(Types.newParameterizedType(PropertyAccessor.class, desc.getConfigType()));
            bind(Key.get(accessorType, propertyIdentifier)).to(accessorType).in(Scopes.SINGLETON);
            expose(Key.get(accessorType, propertyIdentifier));
        }
    };
}
 
開發者ID:kikinteractive,項目名稱:ice,代碼行數:19,代碼來源:PropertyAccessor.java

示例9: configure

import com.google.inject.Scopes; //導入依賴的package包/類
@Override
protected void configure() {
  bind(RequestHelper.class).in(Scopes.SINGLETON);

  bind(MetadataManager.class).in(Scopes.SINGLETON);
  bind(StateManager.class).in(Scopes.SINGLETON);
  bind(TaskManager.class).in(Scopes.SINGLETON);
  bind(DeployManager.class).in(Scopes.SINGLETON);
  bind(RackManager.class).in(Scopes.SINGLETON);
  bind(RequestManager.class).in(Scopes.SINGLETON);
  bind(SlaveManager.class).in(Scopes.SINGLETON);
  bind(TaskRequestManager.class).in(Scopes.SINGLETON);
  bind(SandboxManager.class).in(Scopes.SINGLETON);
  bind(SingularityValidator.class).in(Scopes.SINGLETON);

  bind(ExecutorIdGenerator.class).in(Scopes.SINGLETON);
  bind(WebhookManager.class).in(Scopes.SINGLETON);
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Mesos,代碼行數:19,代碼來源:SingularityDataModule.java

示例10: configure

import com.google.inject.Scopes; //導入依賴的package包/類
@Override
protected void configure() {
  bind(ObjectMapper.class).toInstance(JavaUtils.newObjectMapper());
  bind(MetricRegistry.class).toInstance(new MetricRegistry());

  SingularityRunnerBaseLogging.quietEagerLogging();
  bind(Validator.class).toInstance(Validation.buildDefaultValidatorFactory().getValidator());
  bind(SingularityRunnerExceptionNotifier.class).in(Scopes.SINGLETON);

  final Optional<String> consolidatedConfigFilename = Optional.fromNullable(Strings.emptyToNull(System.getProperty(CONFIG_PROPERTY)));
  final ConfigurationBinder configurationBinder = ConfigurationBinder.newBinder(binder());

  configurationBinder.bindPrimaryConfiguration(primaryConfigurationClass, consolidatedConfigFilename);
  for (Class<? extends BaseRunnerConfiguration> additionalConfigurationClass : additionalConfigurationClasses) {
    configurationBinder.bindConfiguration(additionalConfigurationClass, consolidatedConfigFilename);
  }

  if (!additionalConfigurationClasses.contains(SingularityRunnerBaseConfiguration.class)) {
    configurationBinder.bindConfiguration(SingularityRunnerBaseConfiguration.class, consolidatedConfigFilename);
  }

  bind(SingularityRunnerBaseLogging.class).asEagerSingleton();

  bind(new TypeLiteral<Optional<String>>(){}).annotatedWith(Names.named(CONSOLIDATED_CONFIG_FILENAME)).toInstance(consolidatedConfigFilename);
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Mesos,代碼行數:26,代碼來源:SingularityRunnerBaseModule.java

示例11: configure

import com.google.inject.Scopes; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
protected void configure() {
    this.bind(DataSource.class)
        .toInstance(DataSourceManager.get().load(this.name, this.configuration).get(this.name));
    this.bind(JdbcTypeConverter.class).to(PostgreSqlTypeConverter.class).in(Scopes.SINGLETON);
    this.bind(JdbcExceptionMapper.class).to(PostgreSqlExceptionMapper.class).in(Scopes.SINGLETON);
    this.bind(ConnectorDatabaseService.class)
        .to(ConnectorUtils.getDatabaseServiceClass(this.configuration, PostgreSqlConnectorDatabaseService.class))
        .in(Scopes.SINGLETON);
    this.bind(ConnectorTableService.class)
        .to(ConnectorUtils.getTableServiceClass(this.configuration, JdbcConnectorTableService.class))
        .in(Scopes.SINGLETON);
    this.bind(ConnectorPartitionService.class)
        .to(ConnectorUtils.getPartitionServiceClass(this.configuration, JdbcConnectorPartitionService.class))
        .in(Scopes.SINGLETON);
}
 
開發者ID:Netflix,項目名稱:metacat,代碼行數:20,代碼來源:PostgreSqlConnectorModule.java

示例12: configure

import com.google.inject.Scopes; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
protected void configure() {
    this.bind(DataSource.class)
        .toInstance(DataSourceManager.get().load(this.name, this.configuration).get(this.name));
    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, JdbcConnectorTableService.class))
        .in(Scopes.SINGLETON);
    this.bind(ConnectorPartitionService.class)
        .to(ConnectorUtils.getPartitionServiceClass(this.configuration, JdbcConnectorPartitionService.class))
        .in(Scopes.SINGLETON);
}
 
開發者ID:Netflix,項目名稱:metacat,代碼行數:20,代碼來源:MySqlConnectorModule.java

示例13: configure

import com.google.inject.Scopes; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
protected void configure() {
    this.bind(DataSource.class)
        .toInstance(DataSourceManager.get().load(this.name, this.configuration).get(this.name));
    this.bind(JdbcTypeConverter.class).to(RedshiftTypeConverter.class).in(Scopes.SINGLETON);
    this.bind(JdbcExceptionMapper.class).to(RedshiftExceptionMapper.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, RedshiftConnectorTableService.class))
        .in(Scopes.SINGLETON);
    this.bind(ConnectorPartitionService.class)
        .to(ConnectorUtils.getPartitionServiceClass(this.configuration, JdbcConnectorPartitionService.class))
        .in(Scopes.SINGLETON);
}
 
開發者ID:Netflix,項目名稱:metacat,代碼行數:20,代碼來源:RedshiftConnectorModule.java

示例14: configure

import com.google.inject.Scopes; //導入依賴的package包/類
@Override
public void configure(Binder binder) {
	binder.bind(AlarmDao.class).to(AlarmDaoAllImpl.class).in(Scopes.SINGLETON);

	binder.bind(AlarmService.class).to(AlarmServiceImpl.class).in(Scopes.SINGLETON);

	binder.bind(RobotDao.class).to(RobotDaoHttpImpl.class).in(Scopes.SINGLETON);
	binder.bind(RobotService.class).to(RobotServiceImpl.class).in(Scopes.SINGLETON);

	// binder.bind(Jdbc.class).to(JdbcH2Impl.class).in(Scopes.SINGLETON);
	// binder.bind(SqlSession.class).to(SqlSessionH2Impl.class).in(Scopes.SINGLETON);
	// binder.bind(H2Dao.class).to(H2DaoImpl.class).in(Scopes.SINGLETON);
	//
	// binder.bind(DataSource.class).toProvider(DataSourceProvider.class).in(Scopes.SINGLETON);
	//
	// binder.bind(JedisTestnbImpl.class).toInstance(new JedisTestnbImpl());
	// binder.bind(TransactionTestnbImpl.class).toInstance(new TransactionTestnbImpl());
}
 
開發者ID:tanhaichao,項目名稱:leopard,代碼行數:19,代碼來源:AlarmModule.java

示例15: configure

import com.google.inject.Scopes; //導入依賴的package包/類
@Override
protected void configure() {
    bind(IBehaviorDeserialization.class).to(BehaviorDeserialization.class).in(Scopes.SINGLETON);
    MapBinder<String, ILifecycleTask> lifecycleTaskPlugins
            = MapBinder.newMapBinder(binder(), String.class, ILifecycleTask.class);
    lifecycleTaskPlugins.addBinding("ai.labs.behavior").to(BehaviorRulesEvaluationTask.class);

    MapBinder<String, IBehaviorExtension> behaviorExtensionPlugins
            = MapBinder.newMapBinder(binder(), String.class, IBehaviorExtension.class);
    behaviorExtensionPlugins.addBinding("ai.labs.behavior.extension.inputmatcher").
            to(InputMatcher.class);
    behaviorExtensionPlugins.addBinding("ai.labs.behavior.extension.actionmatcher").
            to(ActionMatcher.class);
    behaviorExtensionPlugins.addBinding("ai.labs.behavior.extension.contextmatcher").
            to(ContextMatcher.class);
    behaviorExtensionPlugins.addBinding("ai.labs.behavior.extension.connector").
            to(Connector.class);
    behaviorExtensionPlugins.addBinding("ai.labs.behavior.extension.dependency").
            to(Dependency.class);
    behaviorExtensionPlugins.addBinding("ai.labs.behavior.extension.negation").
            to(Negation.class);
    behaviorExtensionPlugins.addBinding("ai.labs.behavior.extension.occurrence").
            to(Occurrence.class);
    behaviorExtensionPlugins.addBinding("ai.labs.behavior.extension.resultsize").
            to(ResultSize.class);
}
 
開發者ID:labsai,項目名稱:EDDI,代碼行數:27,代碼來源:BehaviorModule.java


注:本文中的com.google.inject.Scopes類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。