public void annotatedWith(Annotation annotation) { guiceBuilder.annotatedWith(annotation); } }
public void annotatedWith(Class<? extends Annotation> annotationType) { guiceBuilder.annotatedWith(annotationType); }
@Override public LinkedBindingBuilder<T> annotatedWith(final Annotation annotation) { this.expose.annotatedWith(annotation); return this.bind.annotatedWith(annotation); } }
@Override public LinkedBindingBuilder<T> annotatedWith(final Class<? extends Annotation> annotationType) { this.expose.annotatedWith(annotationType); return this.bind.annotatedWith(annotationType); }
protected void configure() { for (Map.Entry<String, Session> mailSession : sessions.entrySet()) { bind(Session.class).annotatedWith(Names.named(mailSession.getKey())).toInstance(mailSession.getValue()); expose(Session.class).annotatedWith(Names.named(mailSession.getKey())); } }
@Override protected void configureShiro() { bind(SecurityManager.class).annotatedWith(Names.named(SHELL_SECURITY_MANAGER)).to(Key.get(SecurityManager.class)); expose(SecurityManager.class).annotatedWith(Names.named(SHELL_SECURITY_MANAGER)); } }
@Override protected void configure() { bind( Foo.class ).annotatedWith( Names.named( "A" ) ).to( PrivateFoo.class ); bindConstant().annotatedWith( Names.named( "port" ) ).to( 1234 ); expose( Foo.class ).annotatedWith( Names.named( "A" ) ); } } );
@Override protected void configure() { bind(CompactionControlSource.class).annotatedWith(LocalCompactionControl.class).to(DefaultCompactionControlSource.class).asEagerSingleton(); expose(CompactionControlSource.class).annotatedWith(LocalCompactionControl.class); bind(CompactionControlSource.class).annotatedWith(DelegateCompactionControl.class).to(DelegateCompactionControlSource.class).asEagerSingleton(); expose(CompactionControlSource.class).annotatedWith(DelegateCompactionControl.class); }
@Override protected void configure() { bind( Foo.class ).annotatedWith( Names.named( "B" ) ).to( PrivateFoo.class ); bindConstant().annotatedWith( Names.named( "port" ) ).to( 4321 ); expose( Foo.class ).annotatedWith( Names.named( "B" ) ); } } );
private void bindUnit(String name, EntityManagerFactory entityManagerFactory, EntityManagerLink entityManagerLink) { Class<? extends JpaExceptionHandler> unitExceptionHandlerClass = jpaExceptionHandlerClasses.get(name); if (unitExceptionHandlerClass != null) { bind(JpaExceptionHandler.class).annotatedWith(Names.named(name)).to(unitExceptionHandlerClass); } else { bind(JpaExceptionHandler.class).annotatedWith(Names.named(name)).toProvider(Providers.of(null)); } expose(JpaExceptionHandler.class).annotatedWith(Names.named(name)); JpaTransactionHandler transactionHandler = new JpaTransactionHandler(entityManagerLink, entityManagerFactory); bind(JpaTransactionHandler.class).annotatedWith(Names.named(name)).toInstance(transactionHandler); expose(JpaTransactionHandler.class).annotatedWith(Names.named(name)); }
@Override protected void configureShiro() { try { bind(SecurityManager.class) .annotatedWith(Names.named(SHELL_SECURITY_MANAGER)) .toConstructor(DefaultSecurityManager.class.getConstructor(Collection.class)) .asEagerSingleton(); } catch (NoSuchMethodException e) { throw new RuntimeException("Internal error", e); } expose(SecurityManager.class).annotatedWith(Names.named(SHELL_SECURITY_MANAGER)); } }
/** * binds and exposes a concrete class with an annotation * * @param <T> * @param clazz */ protected <T> void bindConcreteClassWithQualifier(Class<T> clazz) { bind(clazz).annotatedWith(qualifier) .to(clazz); expose(clazz).annotatedWith(qualifier); }
private void bindGraph(String name, com.tinkerpop.blueprints.Graph graph, GraphLink graphLink) { Class<? extends GraphExceptionHandler> graphExceptionHandlerClass = graphExceptionHandlerClasses.get(name); if (graphExceptionHandlerClass != null) { bind(GraphExceptionHandler.class).annotatedWith(Names.named(name)).to(graphExceptionHandlerClass); } else { bind(GraphExceptionHandler.class).annotatedWith(Names.named(name)).toProvider(Providers.<GraphExceptionHandler>of(null)); } GraphTransactionHandler transactionHandler = new GraphTransactionHandler(graphLink, graph); bind(GraphTransactionHandler.class).annotatedWith(Names.named(name)).toInstance(transactionHandler); expose(GraphExceptionHandler.class).annotatedWith(Names.named(name)); expose(GraphTransactionHandler.class).annotatedWith(Names.named(name)); } }
@Override protected void configure() { // Create data tree manager on top of non-persisting config data tree bind(ModifiableDataManager.class).toProvider(ModifiableDTDelegInitProvider.class).in(Singleton.class); // Wrap as DOMDataBroker bind(DOMDataBroker.class).toProvider(HoneycombDOMDataBrokerProvider.class).in(Singleton.class); // Wrap as BA data broker bind(DataBroker.class).annotatedWith(Names.named(HONEYCOMB_INITIALIZER)) .toProvider(BindingDataBrokerProvider.class).in(Singleton.class); expose(DataBroker.class).annotatedWith(Names.named(HONEYCOMB_INITIALIZER)); // Create initializer registry so that plugins can provide their initializers bind(InitializerRegistry.class).annotatedWith(Names.named(HONEYCOMB_INITIALIZER)) .toProvider(InitializerRegistryAdapterProvider.class).in(Singleton.class); expose(InitializerRegistry.class).annotatedWith(Names.named(HONEYCOMB_INITIALIZER)); } }
/** * helper to expose a binding with annotation added. * * @param type the type to expose. * @param <T> the type to expose. */ private <T> void bindAndExposedAnnotated( Class<T> type ) { bind( type ).annotatedWith( config.getAnnotation() ).to( Key.get( type ) ); expose( type ).annotatedWith( config.getAnnotation() ); }
@Override protected void configureShiroWeb() { super.configureShiroWeb(); /* * ----------------------------------------------------------------------------------------------------------- * Expose an explicit binding to replace the old stateless and stateful "nexus" RealmSecurityManager with the * default RealmSecurityManager, since we now use the "noSessionCreation" filter in Shiro 1.2 on all services * except the login service. * ----------------------------------------------------------------------------------------------------------- * The NexusWebRealmSecurityManager is still available (if necessary) under the "stateless-and-stateful" hint. * ----------------------------------------------------------------------------------------------------------- */ Named nexus = Names.named("nexus"); bind(RealmSecurityManager.class).annotatedWith(nexus).to(RealmSecurityManager.class); expose(RealmSecurityManager.class).annotatedWith(nexus); } }
@Override protected void configure() { JdbiDataSourceConfiguration theConfig = this.config.get(); if (theConfig != null) { bind(JdbiDataSourceConfiguration.class).toInstance(theConfig); } else if (propertiesPath != null) { bind(JdbiDataSourceConfiguration.class).toProvider( new ConfigurationProvider<JdbiDataSourceConfiguration>(name, JdbiDataSourceConfiguration.class, propertiesPath, true)); } else { bind(JdbiDataSourceConfiguration.class).to( Key.get(JdbiDataSourceConfiguration.class, Names.named(name))); } bind(Lifecycle.class).to(Key.get(Lifecycle.class, Names.named(name))); bind(DataSource.class).annotatedWith(Names.named(name)) .toProvider(BoneCPDataSourceProvider.class).in(Scopes.SINGLETON); expose(DataSource.class).annotatedWith(Names.named(name)); if (additionalNames != null) { for (String otherName : additionalNames) { bind(DataSource.class).annotatedWith(Names.named(otherName)).to( Key.get(DataSource.class, Names.named(name))); expose(DataSource.class).annotatedWith(Names.named(otherName)); } } }
@Override protected void configure() { JdbiDataSourceConfiguration theConfig = this.config.get(); if (theConfig != null) { bind(JdbiDataSourceConfiguration.class).toInstance(theConfig); } else if (propertiesPath != null) { bind(JdbiDataSourceConfiguration.class).toProvider( new ConfigurationProvider<JdbiDataSourceConfiguration>(name, JdbiDataSourceConfiguration.class, propertiesPath, true)); } else { bind(JdbiDataSourceConfiguration.class).to( Key.get(JdbiDataSourceConfiguration.class, Names.named(name))); } bind(Lifecycle.class).to(Key.get(Lifecycle.class, Names.named(name))); bind(DataSource.class).annotatedWith(Names.named(name)).toProvider(H2DataSourceProvider.class) .in(Scopes.SINGLETON); expose(DataSource.class).annotatedWith(Names.named(name)); if (additionalNames != null) { for (String otherName : additionalNames) { bind(DataSource.class).annotatedWith(Names.named(otherName)).to( Key.get(DataSource.class, Names.named(name))); expose(DataSource.class).annotatedWith(Names.named(otherName)); } } }
/** * Rebinds and exposes the default connection handlers with the qualifier * * @param qualifier * @param clazz * @param <T> */ public <T> void rebind(Class<? extends Annotation> qualifier, Class<T> clazz) { bind(clazz).annotatedWith(qualifier) .toProvider(binder().getProvider(clazz)); expose(clazz).annotatedWith(qualifier); }
@Override protected void configure() { // Bind the classes that implement intra- and cross-data center cache validation. bind(InvalidationServiceEndPointAdapter.class).asEagerSingleton(); bind(EndPointProvider.class).annotatedWith(LocalDataCenter.class).to(LocalDataCenterEndPointProvider.class).asEagerSingleton(); bind(EndPointProvider.class).annotatedWith(ForeignDataCenters.class).to(ForeignDataCenterEndPointProvider.class).asEagerSingleton(); bind(RemoteInvalidationClient.class).to(DropwizardInvalidationClient.class).asEagerSingleton(); bind(RemoteInvalidationProvider.class).to(DefaultInvalidationProvider.class).asEagerSingleton(); bind(RemoteInvalidationListener.class).asEagerSingleton(); bind(DropwizardInvalidationTask.class).asEagerSingleton(); bind(DropwizardInvalidationClient.class).asEagerSingleton(); // Bind the CacheRegistry instance that the rest of the application will consume. bind(CacheRegistry.class).to(DefaultCacheRegistry.class).asEagerSingleton(); expose(CacheRegistry.class); // Expose the Ostrich cache manager endpoint so EmoService can start it once everything else is initialized. expose(ManagedRegistration.class).annotatedWith(InvalidationService.class); }