resolve((Class)e); annotations.put(key,a); bind(key).in(scope); } else { Class extType;
@Override public void in(Scope scope) { linkedBindingBuilder.in(scope); }
@Override public void in(Class<? extends Annotation> scopeAnnotation) { base.in(scopeAnnotation); }
@Override public void in(Scope scope) { base.in(scope); }
@Override public void in(Class<? extends Annotation> scopeAnnotation) { linkedBindingBuilder.in(scopeAnnotation); }
public void bindCustomThriftCodec(Key<? extends ThriftCodec<?>> thriftCodecKey) { Preconditions.checkNotNull(thriftCodecKey, "thriftCodecKey is null"); // bind the custom codec type to the internal thrift codec set newSetBinder(binder, new TypeLiteral<ThriftCodec<?>>() {}, InternalThriftCodec.class).addBinding().to(thriftCodecKey); // make the custom codec available to user code for binding binder.bind(thriftCodecKey).in(Scopes.SINGLETON); }
public void bindCustomThriftCodec(Key<? extends ThriftCodec<?>> thriftCodecKey) { requireNonNull(thriftCodecKey, "thriftCodecKey is null"); // bind the custom codec type to the internal thrift codec set newSetBinder(binder, new TypeLiteral<ThriftCodec<?>>() {}, InternalThriftCodec.class).addBinding().to(thriftCodecKey); // make the custom codec available to user code for binding binder.bind(thriftCodecKey).in(Scopes.SINGLETON); }
public void bind(Key<?> targetKey) { binder.bind(targetKey).in(SINGLETON); resourceBinder.addBinding().to(targetKey).in(SINGLETON); registerJaxRsBinding(targetKey); }
public void bind(Key<?> targetKey) { binder.bind(targetKey).in(SINGLETON); resourceBinder.addBinding().to(targetKey).in(SINGLETON); registerJaxRsBinding(targetKey); }
@Override public void in(Class<? extends Annotation> scopeAnnotation) { linkedBindingBuilder().in(scopeAnnotation); }
@Override default void in(final Class<? extends Annotation> scopeAnnotation) { this.builder().in(scopeAnnotation); }
@Override default void in(final Scope scope) { this.builder().in(scope); }
@Override public void in(Scope scope) { linkedBindingBuilder().in(scope); }
protected void doClassBinding(Binder binder, Class<?> value) { Type key = getKeyType(); final Key<Object> type = (Key<Object>) Key.get(key); LinkedBindingBuilder<Object> bind = binder.bind(type); if (!key.equals(value)) { bind.to(value); } if (isSingleton()) { bind.in(Scopes.SINGLETON); } }
@Override public void bind(Binder binder) { if (serviceName == null) { binder.bind(implementionType).in(ScopeConverter.toGuiceScope(life)); } else { binder.bind(Key.get(implementionType, Names.named(serviceName))).in(ScopeConverter.toGuiceScope(life)); } }
protected <T> void bind(Class<T> implementationClass, Annotation annotation, Scope scope) { BindingJob job = new ImplementationBindingJob(scope, annotation, implementationClass.getName()); if (!tracer.contains(job)) { LinkedBindingBuilder<T> builder; synchronized (_binder) { builder = _binder.bind(implementationClass); if (annotation != null) { builder = ((AnnotatedBindingBuilder<T>) builder).annotatedWith(annotation); } if (scope != null) { builder.in(scope); } } tracer.add(job); } else { if (_logger.isLoggable(Level.INFO)) { _logger.log(Level.INFO, "Ignoring BindingJob \"" + job.toString() + "\", because it was already bound.", new Exception()); } else if (_logger.isLoggable(Level.WARNING)) { _logger.log(Level.WARNING, "Ignoring BindingJob \"" + job.toString() + "\", because it was already bound."); } } } }
protected <T> void bind(Class<T> implementationClass, Annotation annotation, Class<? extends Annotation> scope) { BindingJob job = new ImplementationBindingJob(scope, annotation, implementationClass.getName()); if (!tracer.contains(job)) { LinkedBindingBuilder<T> builder; synchronized (_binder) { builder = _binder.bind(implementationClass); if (annotation != null) { builder = ((AnnotatedBindingBuilder<T>) builder).annotatedWith(annotation); } if (scope != null) { builder.in(scope); } } tracer.add(job); } else { if (_logger.isLoggable(Level.INFO)) { _logger.log(Level.INFO, "Ignoring BindingJob \"" + job.toString() + "\", because it was already bound.", new Exception()); } else if (_logger.isLoggable(Level.WARNING)) { _logger.log(Level.WARNING, "Ignoring BindingJob \"" + job.toString() + "\", because it was already bound."); } } } }
private <T> void bindIfConcrete(Set<Key<?>> keysObserved, Key<T> key, boolean asTestSingleton) { TypeLiteral<?> typeToBind = key.getTypeLiteral(); Class<?> rawType = typeToBind.getRawType(); if (!keysObserved.contains(key) && canBeInjected(typeToBind) && !shouldForceMock(rawType) && !isAssistedInjection(key)) { // If an @Singleton annotation is present, force the bind as TestSingleton if (asTestSingleton || rawType.getAnnotation(Singleton.class) != null) { bind(key).in(TestScope.SINGLETON); } else { bind(key); } keysObserved.add(key); keysNeedingTransitiveDependencies.add(key); } }
private <T> void bindIfConcrete(Set<Key<?>> keysObserved, Key<T> key, boolean asTestSingleton) { TypeLiteral<?> typeToBind = key.getTypeLiteral(); Class<?> rawType = typeToBind.getRawType(); if (!keysObserved.contains(key) && canBeInjected(typeToBind) && !shouldForceMock(rawType) && !isAssistedInjection(key)) { // If an @Singleton annotation is present, force the bind as TestSingleton if (asTestSingleton || rawType.getAnnotation(Singleton.class) != null) { bind(key).in(TestScope.SINGLETON); } else { bind(key); } keysObserved.add(key); keysNeedingTransitiveDependencies.add(key); } }
bind.asEagerSingleton(); } else if (isSingleton()) { bind.in(Scopes.SINGLETON);