Java Code Examples for com.google.inject.binder.AnnotatedBindingBuilder#to()

The following examples show how to use com.google.inject.binder.AnnotatedBindingBuilder#to() . 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: BindingDefinition.java    From seed with Mozilla Public License 2.0 6 votes vote down vote up
void apply(Binder binder) {
    if (from != null) {
        AnnotatedBindingBuilder<T> bind = binder.bind(from);
        if (!from.isAssignableFrom(target)) {
            throw SeedException.createNew(CoreErrorCode.INVALID_BINDING)
                    .put("key", from)
                    .put("target", target);
        }
        if (qualifier != null) {
            LOGGER.debug("Binding {} annotated with {} to {}", from.getName(), qualifier, target.getName());
            bind.annotatedWith(qualifier).to(target);
        } else {
            LOGGER.debug("Binding {} to {}", from.getName(), target.getName());
            bind.to(target);
        }
    } else {
        if (qualifier != null) {
            LOGGER.debug("Binding {} annotated with {} to itself", target.getName(), qualifier);
            binder.bind(target).annotatedWith(qualifier);
        } else {
            LOGGER.debug("Binding {} to itself", target.getName());
            binder.bind(target);
        }
    }
}
 
Example 2
Source File: WebSecurityModule.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void bindWebSecurityManager(final AnnotatedBindingBuilder<? super WebSecurityManager> bind) {
  bind(NexusWebSecurityManager.class).asEagerSingleton();

  // bind RealmSecurityManager and WebSecurityManager to _same_ component
  bind(RealmSecurityManager.class).to(NexusWebSecurityManager.class);
  bind.to(NexusWebSecurityManager.class);

  // bindings used by external modules
  expose(RealmSecurityManager.class);
  expose(WebSecurityManager.class);
}
 
Example 3
Source File: PersonDAOSecurityModule.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
@Override
protected void bindAuthenticationDAO(AnnotatedBindingBuilder<AuthenticationDAO> bind) {
   bind.to(PersonDAOImpl.class);
}
 
Example 4
Source File: SecurityModule.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
protected void bindSessionDAO(AnnotatedBindingBuilder<SessionDAO> bind) {
   bind.to(GuicedCassandraSessionDAO.class);
}
 
Example 5
Source File: SecurityModule.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
protected void bindCacheManager(AnnotatedBindingBuilder<CacheManager> bind) {
   bind.to(MemoryConstrainedCacheManager.class);
}
 
Example 6
Source File: SecurityModule.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
protected void bindAuthorizationDAO(AnnotatedBindingBuilder<AuthorizationDAO> bind) {
   bind.to(NoopAuthorizationDAOImpl.class);
}
 
Example 7
Source File: SecurityModule.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
protected void bindPrincipalResolver(AnnotatedBindingBuilder<PrincipalResolver> bind) {
   bind.to(DefaultPrincipalResolver.class);
}
 
Example 8
Source File: SecurityModule.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
protected void bindCredentialsHashingStrategy(AnnotatedBindingBuilder<CredentialsHashingStrategy> bind) {
   bind.to(Sha256CredentialsHashingStrategy.class);
}
 
Example 9
Source File: KaryonBootstrapModule.java    From karyon with Apache License 2.0 4 votes vote down vote up
private static void bindHealthCheckInvocationStrategy(AnnotatedBindingBuilder<HealthCheckInvocationStrategy> bindingBuilder) {
    bindingBuilder.to(SyncHealthCheckInvocationStrategy.class);
}