类com.google.inject.name.Names源码实例Demo

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

源代码1 项目: spoofax   文件: SpoofaxExtensionModule.java
@Override protected void configure() {
    autoClosableBinder = Multibinder.newSetBinder(binder(), AutoCloseable.class);
    spoofaxPrimitiveLibrary = Multibinder.newSetBinder(binder(), AbstractPrimitive.class, Names.named(SpoofaxPrimitiveLibrary.name));
    legacySpoofaxPrimitiveLibrary = Multibinder.newSetBinder(binder(), AbstractPrimitive.class, Names.named(LegacySpoofaxPrimitiveLibrary.name));

    bindAutoClosableSpoofaxPrimitive(LanguageSpecificationPrimitive.class);
    bindAutoClosableSpoofaxPrimitive(LanguageSpecSrcGenDirectory.class);
    bindAutoClosableSpoofaxPrimitive(LanguageSpecPpNamePrimitive.class);
    bindAutoClosableSpoofaxPrimitive(CheckSdf2TablePrimitive.class);
    bindAutoClosableSpoofaxPrimitive(PlaceholderCharsPrimitive.class);
    bindAutoClosableSpoofaxPrimitive(StrategoPieAnalyzePrimitive.class);
    bindSpoofaxPrimitive(LayoutSensitivePrettyPrinterPrimitive.class);
    bindSpoofaxPrimitive(GetContextualGrammarPrimitive.class);

    bindAutoClosableLegacySpoofaxPrimitive(LegacyLanguageSpecNamePrimitive.class);
    
    install(new StrIncrModule());
    install(new GuiceTaskDefsModule());
}
 
源代码2 项目: examples-javafx-repos1   文件: OldScoresModule.java
@Override
protected void configure() {

    String mathRecenteredJSONFile = MATH_RECENTERED_JSON_FILE;
    String verbalRecenteredJSONFile = VERBAL_RECENTERED_JSON_FILE;
    String settingsFileName = SETTINGS_FILE_NAME;

    bind(BuilderFactory.class).to(JavaFXBuilderFactory.class);

    bind(String.class).annotatedWith(Names.named("mathRecenteredJSONFile")).toInstance(mathRecenteredJSONFile);
    bind(String.class).annotatedWith(Names.named("verbalRecenteredJSONFile")).toInstance(verbalRecenteredJSONFile);
    bind(String.class).annotatedWith(Names.named("settingsFileName")).toInstance(settingsFileName);

    bind(SettingsDAO.class).to(SettingsDAOImpl.class).asEagerSingleton();
    bind(RecenteredDAO.class).to(RecenteredDAOImpl.class).asEagerSingleton();

    bindInterceptor(Matchers.subclassesOf(ManagedDataSource.class), Matchers.any(), new ManagedDataSourceInterceptor());
}
 
源代码3 项目: james-project   文件: ReIndexingModule.java
@Override
protected void configure() {
    Multibinder.newSetBinder(binder(), TaskRegistration.class, Names.named(USER_MAILBOXES_OPERATIONS_INJECTION_KEY))
        .addBinding()
        .to(UserReIndexingTaskRegistration.class);

    Multibinder.newSetBinder(binder(), TaskRegistration.class, Names.named(ALL_MAILBOXES_TASKS))
        .addBinding()
        .to(MailboxesRoutes.ReIndexAllMailboxesTaskRegistration.class);

    Multibinder.newSetBinder(binder(), TaskRegistration.class, Names.named(ONE_MAILBOX_TASKS))
        .addBinding()
        .to(MailboxesRoutes.ReIndexOneMailboxTaskRegistration.class);

    Multibinder.newSetBinder(binder(), TaskRegistration.class, Names.named(ONE_MAIL_TASKS))
        .addBinding()
        .to(MailboxesRoutes.ReIndexOneMailTaskRegistration.class);
}
 
源代码4 项目: incubator-gobblin   文件: FlowStatusTest.java
@BeforeClass
public void setUp() throws Exception {
  JobStatusRetriever jobStatusRetriever = new TestJobStatusRetriever();
  final FlowStatusGenerator flowStatusGenerator =
      FlowStatusGenerator.builder().jobStatusRetriever(jobStatusRetriever).build();

  Injector injector = Guice.createInjector(new Module() {
     @Override
     public void configure(Binder binder) {
       binder.bind(FlowStatusGenerator.class).annotatedWith(Names.named(FlowStatusResource.FLOW_STATUS_GENERATOR_INJECT_NAME))
           .toInstance(flowStatusGenerator);
     }
  });

  _server = EmbeddedRestliServer.builder().resources(
      Lists.<Class<? extends BaseResource>>newArrayList(FlowStatusResource.class)).injector(injector).build();

  _server.startAsync();
  _server.awaitRunning();

  _client =
      new FlowStatusClient(String.format("http://localhost:%s/", _server.getPort()));
}
 
源代码5 项目: n4js   文件: N4JSClusteringBuilderConfiguration.java
@Override
protected void configure() {
	bind(IResourceClusteringPolicy.class).to(VerboseClusteringPolicy.class);
	bind(XtextBuilder.class).to(N4JSBuildTypeTrackingBuilder.class);
	bind(IBuilderState.class).to(N4JSGenerateImmediatelyBuilderState.class).in(Scopes.SINGLETON);
	bind(IMarkerUpdater.class).to(N4JSMarkerUpdater.class);
	bind(IStorage2UriMapper.class).to(N4JSStorage2UriMapper.class);
	bind(PersistedStateProvider.class).to(ContributingResourceDescriptionPersister.class);
	bind(IBuildLogger.class).annotatedWith(BuilderState.class).to(BuilderStateLogger.class);
	bind(DirtyStateManager.class).to(PrevStateAwareDirtyStateManager.class);
	bind(IResourceLoader.class).annotatedWith(
			Names.named(ClusteringBuilderState.RESOURCELOADER_GLOBAL_INDEX)).toProvider(
					new BuildScopeAwareParallelLoaderProvider());
	bind(BuilderStateDiscarder.class);
	bind(SharedStateContributionRegistryImpl.class).to(DefaultSharedContributionOverridingRegistry.class);
	binder().install(new MyReferenceSearchResultContentProviderCustomModule());
}
 
源代码6 项目: attic-rave   文件: OAuthGuiceModule.java
/**
 * {@inheritDoc}
 */
@Override
protected void configure() {
    bind(BlobCrypter.class).annotatedWith(Names.named(OAuthFetcherConfig.OAUTH_STATE_CRYPTER))
            .toProvider(OAuthModule.OAuthCrypterProvider.class);
    bind(OAuthRequest.class).toProvider(OAuthModule.OAuthRequestProvider.class);

    //Required for SampleOAuthDataStore
    bind(String.class).annotatedWith(Names.named("shindig.canonical.json.db"))
        .toInstance("sampledata/canonicaldb.json");
    bind(OAuthDataStore.class).to(SampleOAuthDataStore.class);
}
 
@Test
public void test_encryption_service_collect_with_qualifier() {
    prepareMock();

    EncryptionServiceBindingFactory collector = new EncryptionServiceBindingFactory();
    Map<Key<EncryptionService>, EncryptionService> encryptionServiceMap = collector.createBindings(
            prepareKeyPairWithQualifier("foo"),
            keyStores);
    Assertions.assertThat(encryptionServiceMap).hasSize(1);
    Assertions.assertThat(encryptionServiceMap).containsKey(Key.get(EncryptionService.class, Names.named("foo")));
    Assertions.assertThat(encryptionServiceMap).containsValue(encryptionService);
}
 
源代码8 项目: act-platform   文件: AbstractEndpointTest.java
@Override
protected void configure() {
  install(new TiRestModule());
  bind(ThreatIntelligenceService.class).toInstance(tiService);
  bind(String.class).annotatedWith(Names.named("act.api.server.port")).toInstance(String.valueOf(port));
  bind(String.class).annotatedWith(Names.named("act.api.cors.allowed.origins")).toInstance("http://www.example.org");
}
 
源代码9 项目: Orienteer   文件: OUsersCommonUtils.java
public static List<IOAuth2Provider> getOAuth2Providers() {
    OrienteerWebApplication app = OrienteerWebApplication.lookupApplication();
    if (app == null) {
        return Collections.emptyList();
    }
    Named named = Names.named("orienteer.oauth2.providers");
    Key<List<IOAuth2Provider>> key = Key.get(new TypeLiteral<List<IOAuth2Provider>>() {}, named);
    return app.getInjector().getInstance(key);
}
 
源代码10 项目: attic-stratos   文件: GCEIaas.java
private Operation waitGCEOperationDone(Operation operation) {
    IaasProvider iaasInfo = getIaasProvider();
    Injector injector = ContextBuilder.newBuilder(iaasInfo.getProvider())
            .credentials(iaasInfo.getIdentity(), iaasInfo.getCredential())
            .buildInjector();
    Predicate<AtomicReference<Operation>> zoneOperationDonePredicate =
            injector.getInstance(Key.get(new TypeLiteral<Predicate<AtomicReference<Operation>>>() {
            }, Names.named("zone")));
    AtomicReference<Operation> operationReference = Atomics.newReference(operation);
    retry(zoneOperationDonePredicate, MAX_WAIT_TIME, 1, SECONDS).apply(operationReference);

    return operationReference.get();
}
 
源代码11 项目: arcusplatform   文件: AbstractIpcdServerModule.java
@Override
protected final void configure() {
   bind(BridgeServerConfig.class);
   bind(TrustConfig.class);
   bind(BridgeServerTlsContext.class).to(BridgeServerTlsContextImpl.class);
   bind(BridgeServerTrustManagerFactory.class).to(SimpleTrustManagerFactoryImpl.class);
   bind(ProtocolBusService.class).to(ProtocolBusServiceImpl.class).asEagerSingleton();
   bindSetOf(ProtocolBusListener.class).addBinding().to(IpcdProtocolBusListener.class);
   bind(PlatformBusService.class).to(IpcdPlatformBusServiceImpl.class).asEagerSingleton();
   Multibinder<PlatformBusListener> platformListenerBinder = bindSetOf(PlatformBusListener.class);
   platformListenerBinder.addBinding().to(IpcdServiceEventListener.class);      
   bindMessageHandler();
   bind(Authenticator.class).to(NoopAuthenticator.class);
   bind(ClientFactory.class).to(IpcdClientFactory.class);
   bind(new TypeLiteral<ChannelInitializer<SocketChannel>>(){}).to(Bridge10ChannelInitializer.class);
   bind(ChannelInboundHandler.class).toProvider(Text10WebSocketServerHandlerProvider.class);
   bindSessionFactory();
   bind(SessionRegistry.class).to(DefaultSessionRegistryImpl.class);
   bindSessionSupplier();
   bind(SessionHeartBeater.class);

   bind(DefaultIpcdDeliveryStrategy.class);
   bindDeliveryStrategies();
   bind(RequestMatcher.class).annotatedWith(Names.named("WebSocketUpgradeMatcher")).to(WebSocketUpgradeMatcher.class);
   bind(RequestAuthorizer.class).annotatedWith(Names.named("SessionAuthorizer")).to(AlwaysAllow.class);

   Multibinder<SessionListener> slBindings = Multibinder.newSetBinder(binder(), SessionListener.class);
   bindSessionListener(slBindings);

   Multibinder<RequestHandler> rhBindings = Multibinder.newSetBinder(binder(), RequestHandler.class);
   rhBindings.addBinding().to(RootRedirect.class);
   bindHttpHandlers(rhBindings);
}
 
源代码12 项目: flux   文件: TestModule.java
@Override
protected void configure() {
    bind(SessionFactoryContext.class).toInstance(context);
    bind(Session.class).annotatedWith(Names.named("shardedReadWriteSession")).
            toInstance(shardedReadWriteSession);
    bind(Session.class).annotatedWith(Names.named("shardedReadOnlySession")).
            toInstance(shardedReadOnlySession);
    bind(Session.class).annotatedWith(Names.named("schedulerSession")).
            toInstance(schedulerSession);
    bind(InterceptedClass.class);
    bindInterceptor(Matchers.subclassesOf(InterceptedClass.class), Matchers.annotatedWith(Transactional.class), new TransactionInterceptor(() -> context));
}
 
源代码13 项目: che   文件: KubernetesDevfileBindings.java
/**
 * Any workspace environments based on Kubernetes recipes need to register the binding using this
 * method so that the {@link KubernetesComponentProvisioner} and {@link
 * KubernetesEnvironmentProvisioner} can work properly with these environments.
 *
 * @param baseBinder the binder available in the Guice module calling this method.
 * @param environmentTypes the environment types to be registered as handled by Kubernetes recipes
 */
public static void addKubernetesBasedEnvironmentTypeBindings(
    Binder baseBinder, String... environmentTypes) {
  Multibinder<String> binder =
      Multibinder.newSetBinder(
          baseBinder, String.class, Names.named(KUBERNETES_BASED_ENVIRONMENTS_KEY_NAME));
  for (String envType : environmentTypes) {
    binder.addBinding().toInstance(envType);
  }
}
 
源代码14 项目: vespa   文件: ServerRepositoryIntegrationTest.java
@Override
protected void configure() {
    bind(CountDownLatch.class).annotatedWith(Names.named("Init")).toInstance(init);
    bind(CountDownLatch.class).annotatedWith(Names.named("Start")).toInstance(start);
    bind(CountDownLatch.class).annotatedWith(Names.named("Close")).toInstance(close);
    bind(CountDownLatch.class).annotatedWith(Names.named("Destroy")).toInstance(destroy);
}
 
public void configureFileExtensions(Binder binder) {
	if (properties == null || properties.getProperty(Constants.FILE_EXTENSIONS) == null)
		binder.bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).toInstance("serializationbug269362testlanguage");
}
 
源代码16 项目: xtext-core   文件: ValidatorTester.java
public ValidatorTester(T validator, Injector injector) {
	this(validator,
		injector.getInstance(EValidatorRegistrar.class),
		injector.getInstance(Key.get(String.class, Names.named(Constants.LANGUAGE_NAME))));
}
 
public void configureLanguageName(Binder binder) {
	binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.eclipse.xtext.resource.LiveContainerTestLanguage");
}
 
源代码18 项目: sarl   文件: AbstractSARLUiModule.java
public void configureContentAssistLexer(Binder binder) {
	binder.bind(Lexer.class)
		.annotatedWith(Names.named(LexerIdeBindings.CONTENT_ASSIST))
		.to(InternalSARLLexer.class);
}
 
public void configureRuntimeLexer(Binder binder) {
	binder.bind(Lexer.class)
		.annotatedWith(Names.named(LexerBindings.RUNTIME))
		.to(InternalBmTestLanguageLexer.class);
}
 
public void configureFileExtensions(Binder binder) {
	if (properties == null || properties.getProperty(Constants.FILE_EXTENSIONS) == null)
		binder.bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).toInstance("locationprovidertestlanguage");
}
 
public void configureLanguageName(Binder binder) {
	binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.eclipse.xtext.testlanguages.FowlerDslTestLanguage");
}
 
public void configureIScopeProviderDelegate(Binder binder) {
	binder.bind(IScopeProvider.class).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(ImportedNamespaceAwareLocalScopeProvider.class);
}
 
public void configureFileExtensions(Binder binder) {
	if (properties == null || properties.getProperty(Constants.FILE_EXTENSIONS) == null)
		binder.bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).toInstance("simplebeelangtestlanguage");
}
 
public void configureRuntimeLexer(Binder binder) {
	binder.bind(Lexer.class)
		.annotatedWith(Names.named(LexerBindings.RUNTIME))
		.to(InternalRefactoringTestLanguageLexer.class);
}
 
源代码25 项目: phoenix-omid   文件: VoidLeaseManagementModule.java
@Override
protected void configure() {
    LOG.info(this.toString());
    bindConstant().annotatedWith(Names.named(HBaseTimestampStorageConfig.TIMESTAMP_STORAGE_TABLE_NAME_KEY)).to(tableName);
    install(new HBaseConfigModule(principal, keytab));
}
 
public void configureRuntimeLexer(Binder binder) {
	binder.bind(Lexer.class)
		.annotatedWith(Names.named(LexerBindings.RUNTIME))
		.to(InternalIgnoreCaseImportsTestLanguageLexer.class);
}
 
public void configureIScopeProviderDelegate(Binder binder) {
	binder.bind(IScopeProvider.class).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(ImportedNamespaceAwareLocalScopeProvider.class);
}
 
public void configureRuntimeLexer(Binder binder) {
	binder.bind(Lexer.class)
		.annotatedWith(Names.named(LexerBindings.RUNTIME))
		.to(InternalLiveContainerTestLanguageLexer.class);
}
 
public void configureIScopeProviderDelegate(Binder binder) {
	binder.bind(IScopeProvider.class).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(ImportedNamespaceAwareLocalScopeProvider.class);
}
 
public void configureHighlightingTokenDefProvider(Binder binder) {
	binder.bind(ITokenDefProvider.class)
		.annotatedWith(Names.named(LexerIdeBindings.HIGHLIGHTING))
		.to(AntlrTokenDefProvider.class);
}
 
 类所在包
 同包方法