com.google.inject.name.Names Java Examples

The following examples show how to use com.google.inject.name.Names. 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: OldScoresModule.java    From examples-javafx-repos1 with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example #2
Source File: N4JSClusteringBuilderConfiguration.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@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());
}
 
Example #3
Source File: SpoofaxExtensionModule.java    From spoofax with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example #4
Source File: FlowStatusTest.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
@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()));
}
 
Example #5
Source File: ReIndexingModule.java    From james-project with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #6
Source File: AbstractEndpointTest.java    From act-platform with ISC License 5 votes vote down vote up
@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");
}
 
Example #7
Source File: ServerRepositoryIntegrationTest.java    From vespa with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #8
Source File: KubernetesDevfileBindings.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * 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);
  }
}
 
Example #9
Source File: GCEIaas.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #10
Source File: OUsersCommonUtils.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #11
Source File: TestModule.java    From flux with Apache License 2.0 5 votes vote down vote up
@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));
}
 
Example #12
Source File: AbstractIpcdServerModule.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #13
Source File: EncryptionServiceBindingFactoryTest.java    From seed with Mozilla Public License 2.0 5 votes vote down vote up
@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);
}
 
Example #14
Source File: OAuthGuiceModule.java    From attic-rave with Apache License 2.0 5 votes vote down vote up
/**
 * {@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);
}
 
Example #15
Source File: AbstractParameterizedExpressionsTestLanguageRuntimeModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureLanguageName(Binder binder) {
	binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.eclipse.xtext.ui.tests.editor.contentassist.ParameterizedExpressionsTestLanguage");
}
 
Example #16
Source File: AbstractGamlUiModule.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
public void configureCompareViewerTitle(Binder binder) {
	binder.bind(String.class).annotatedWith(Names.named(UIBindings.COMPARE_VIEWER_TITLE)).toInstance("Gaml Compare");
}
 
Example #17
Source File: AbstractQualifiedNameTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void configureRuntimeLexer(Binder binder) {
	binder.bind(Lexer.class)
		.annotatedWith(Names.named(LexerBindings.RUNTIME))
		.to(InternalQualifiedNameTestLanguageLexer.class);
}
 
Example #18
Source File: AbstractBacktrackingContentAssistTestLanguageRuntimeModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureLanguageName(Binder binder) {
	binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.eclipse.xtext.ui.tests.editor.contentassist.BacktrackingContentAssistTestLanguage");
}
 
Example #19
Source File: AbstractEnumRulesUiTestLanguageRuntimeModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureRuntimeLexer(Binder binder) {
	binder.bind(Lexer.class)
		.annotatedWith(Names.named(LexerBindings.RUNTIME))
		.to(InternalEnumRulesUiTestLanguageLexer.class);
}
 
Example #20
Source File: AbstractArithmeticsRuntimeModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIScopeProviderDelegate(Binder binder) {
	binder.bind(IScopeProvider.class).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(ImportedNamespaceAwareLocalScopeProvider.class);
}
 
Example #21
Source File: AbstractBaseInheritanceTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
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("baseinheritancetestlanguage");
}
 
Example #22
Source File: AbstractActionTestLanguage3RuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void configureLanguageName(Binder binder) {
	binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.eclipse.xtext.testlanguages.ActionTestLanguage3");
}
 
Example #23
Source File: AbstractExBeeLangTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
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("exbeelangtestlanguage");
}
 
Example #24
Source File: AbstractEObjectAtOffsetTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void configureRuntimeLexer(Binder binder) {
	binder.bind(Lexer.class)
		.annotatedWith(Names.named(LexerBindings.RUNTIME))
		.to(InternalEObjectAtOffsetTestLanguageLexer.class);
}
 
Example #25
Source File: AbstractMetamodelRefTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void configureLanguageName(Binder binder) {
	binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("org.eclipse.xtext.metamodelreferencing.tests.MetamodelRefTestLanguage");
}
 
Example #26
Source File: AbstractEnumRulesTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
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("enumrulestestlanguage");
}
 
Example #27
Source File: AbstractTerminalRulesTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
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("terminalrulestestlanguage");
}
 
Example #28
Source File: SingularityClientModule.java    From Singularity with Apache License 2.0 4 votes vote down vote up
public static LinkedBindingBuilder<List<String>> bindHosts(Binder binder) {
  return binder
    .bind(new TypeLiteral<List<String>>() {})
    .annotatedWith(Names.named(HOSTS_PROPERTY_NAME));
}
 
Example #29
Source File: AbstractEnumAndReferenceTestLanguageRuntimeModule.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public void configureRuntimeLexer(Binder binder) {
	binder.bind(Lexer.class)
		.annotatedWith(Names.named(LexerBindings.RUNTIME))
		.to(InternalEnumAndReferenceTestLanguageLexer.class);
}
 
Example #30
Source File: AbstractXtextGrammarTestLanguageIdeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void configureContentAssistLexer(Binder binder) {
	binder.bind(Lexer.class)
		.annotatedWith(Names.named(LexerIdeBindings.CONTENT_ASSIST))
		.to(InternalXtextGrammarTestLanguageLexer.class);
}