本文整理汇总了Java中com.google.inject.binder.ScopedBindingBuilder.in方法的典型用法代码示例。如果您正苦于以下问题:Java ScopedBindingBuilder.in方法的具体用法?Java ScopedBindingBuilder.in怎么用?Java ScopedBindingBuilder.in使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.inject.binder.ScopedBindingBuilder
的用法示例。
在下文中一共展示了ScopedBindingBuilder.in方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindingModule
import com.google.inject.binder.ScopedBindingBuilder; //导入方法依赖的package包/类
public Module bindingModule() {
return new KeyedManifest.Impl(method) {
@Override
public void configure() {
final Binder binder = binder().withSource(method);
if(!hasReturnValue()) {
binder.addError("Cannot bind this method as a provider because it does not return a value");
return;
}
install(InjectableMethod.this);
final ScopedBindingBuilder builder = binder.bind(providedKey).toProvider(asProvider());
if(scope != null) builder.in(scope);
}
};
}
示例2: bindFutureProvider
import com.google.inject.binder.ScopedBindingBuilder; //导入方法依赖的package包/类
void bindFutureProvider(PrivateBinder binder) {
binder = binder.withSource(source);
ScopedBindingBuilder scoper = binder.bind(bindingKey).toProvider(this);
if (isVoid(method)) {
scoper.asEagerSingleton();
} else {
if (scopeAnnotation != null) {
scoper.in(scopeAnnotation);
}
if (exposedBinding) {
binder.expose(bindingKey);
}
}
}
示例3: configure
import com.google.inject.binder.ScopedBindingBuilder; //导入方法依赖的package包/类
void configure(Binder binder) {
binder = binder.withSource(method);
SecondaryBinder<?, ?> sbinder =
ThrowingProviderBinder.create(binder).bind(checkedProvider, key.getTypeLiteral());
if (key.getAnnotation() != null) {
sbinder = sbinder.annotatedWith(key.getAnnotation());
} else if (key.getAnnotationType() != null) {
sbinder = sbinder.annotatedWith(key.getAnnotationType());
}
sbinder.scopeExceptions(scopeExceptions);
ScopedBindingBuilder sbbuilder = sbinder.toProviderMethod(this);
if (scopeAnnotation != null) {
sbbuilder.in(scopeAnnotation);
}
if (exposed) {
// the cast is safe 'cause the only binder we have implements PrivateBinder. If there's a
// misplaced @Exposed, calling this will add an error to the binder's error queue
((PrivateBinder) binder).expose(sbinder.getKey());
}
CheckedProvideUtils.validateExceptions(
binder, exceptionTypes, sbinder.getExceptionTypes(), checkedProvider);
}
示例4: configure
import com.google.inject.binder.ScopedBindingBuilder; //导入方法依赖的package包/类
void configure(Binder binder) {
binder = binder.withSource(method);
SecondaryBinder<?, ?> sbinder =
ThrowingProviderBinder.create(binder)
.bind(checkedProvider, key.getTypeLiteral());
if(key.getAnnotation() != null) {
sbinder = sbinder.annotatedWith(key.getAnnotation());
} else if(key.getAnnotationType() != null) {
sbinder = sbinder.annotatedWith(key.getAnnotationType());
}
ScopedBindingBuilder sbbuilder = sbinder.toProviderMethod(this);
if(scopeAnnotation != null) {
sbbuilder.in(scopeAnnotation);
}
if (exposed) {
// the cast is safe 'cause the only binder we have implements PrivateBinder. If there's a
// misplaced @Exposed, calling this will add an error to the binder's error queue
((PrivateBinder) binder).expose(sbinder.getKey());
}
CheckedProvideUtils.validateExceptions(
binder, exceptionTypes, sbinder.getExceptionTypes(), checkedProvider);
}
示例5: forAnnotation
import com.google.inject.binder.ScopedBindingBuilder; //导入方法依赖的package包/类
public static Scoping forAnnotation(final Class<? extends Annotation> scopingAnnotation) {
if (scopingAnnotation == Singleton.class
|| scopingAnnotation == javax.inject.Singleton.class) {
return SINGLETON_ANNOTATION;
}
return new Scoping() {
@Override public <V> V acceptVisitor(BindingScopingVisitor<V> visitor) {
return visitor.visitScopeAnnotation(scopingAnnotation);
}
@Override public Class<? extends Annotation> getScopeAnnotation() {
return scopingAnnotation;
}
@Override public String toString() {
return scopingAnnotation.getName();
}
@Override public void applyTo(ScopedBindingBuilder scopedBindingBuilder) {
scopedBindingBuilder.in(scopingAnnotation);
}
};
}
示例6: forInstance
import com.google.inject.binder.ScopedBindingBuilder; //导入方法依赖的package包/类
public static Scoping forInstance(final Scope scope) {
if (scope == Scopes.SINGLETON) {
return SINGLETON_INSTANCE;
}
return new Scoping() {
@Override public <V> V acceptVisitor(BindingScopingVisitor<V> visitor) {
return visitor.visitScope(scope);
}
@Override public Scope getScopeInstance() {
return scope;
}
@Override public String toString() {
return scope.toString();
}
@Override public void applyTo(ScopedBindingBuilder scopedBindingBuilder) {
scopedBindingBuilder.in(scope);
}
};
}
示例7: forAnnotation
import com.google.inject.binder.ScopedBindingBuilder; //导入方法依赖的package包/类
public static Scoping forAnnotation(final Class<? extends Annotation> scopingAnnotation) {
if (scopingAnnotation == Singleton.class
|| scopingAnnotation == javax.inject.Singleton.class) {
return SINGLETON_ANNOTATION;
}
return new Scoping() {
public <V> V acceptVisitor(BindingScopingVisitor<V> visitor) {
return visitor.visitScopeAnnotation(scopingAnnotation);
}
@Override public Class<? extends Annotation> getScopeAnnotation() {
return scopingAnnotation;
}
@Override public String toString() {
return scopingAnnotation.getName();
}
public void applyTo(ScopedBindingBuilder scopedBindingBuilder) {
scopedBindingBuilder.in(scopingAnnotation);
}
};
}
示例8: forInstance
import com.google.inject.binder.ScopedBindingBuilder; //导入方法依赖的package包/类
public static Scoping forInstance(final Scope scope) {
if (scope == Scopes.SINGLETON) {
return SINGLETON_INSTANCE;
}
return new Scoping() {
public <V> V acceptVisitor(BindingScopingVisitor<V> visitor) {
return visitor.visitScope(scope);
}
@Override public Scope getScopeInstance() {
return scope;
}
@Override public String toString() {
return scope.toString();
}
public void applyTo(ScopedBindingBuilder scopedBindingBuilder) {
scopedBindingBuilder.in(scope);
}
};
}
示例9: bindProvidersInScope
import com.google.inject.binder.ScopedBindingBuilder; //导入方法依赖的package包/类
private void bindProvidersInScope(PrivateBinder privateBinder) {
ScopedBindingBuilder scoper = privateBinder.bind(providersClass);
if (scopeAnnotation != null) {
scoper.in(scopeAnnotation);
}
for (EventualProvider<?> p : providers) {
p.bindFutureProvider(privateBinder);
}
}
示例10: forAnnotation
import com.google.inject.binder.ScopedBindingBuilder; //导入方法依赖的package包/类
public static Scoping forAnnotation(final Class<? extends Annotation> scopingAnnotation) {
if (scopingAnnotation == Singleton.class || scopingAnnotation == javax.inject.Singleton.class) {
return SINGLETON_ANNOTATION;
}
return new Scoping() {
@Override
public <V> V acceptVisitor(BindingScopingVisitor<V> visitor) {
return visitor.visitScopeAnnotation(scopingAnnotation);
}
@Override
public Class<? extends Annotation> getScopeAnnotation() {
return scopingAnnotation;
}
@Override
public String toString() {
return scopingAnnotation.getName();
}
@Override
public void applyTo(ScopedBindingBuilder scopedBindingBuilder) {
scopedBindingBuilder.in(scopingAnnotation);
}
};
}
示例11: forInstance
import com.google.inject.binder.ScopedBindingBuilder; //导入方法依赖的package包/类
public static Scoping forInstance(final Scope scope) {
if (scope == Scopes.SINGLETON) {
return SINGLETON_INSTANCE;
} else if (scope == Scopes.NO_SCOPE) {
return EXPLICITLY_UNSCOPED;
}
return new Scoping() {
@Override
public <V> V acceptVisitor(BindingScopingVisitor<V> visitor) {
return visitor.visitScope(scope);
}
@Override
public Scope getScopeInstance() {
return scope;
}
@Override
public String toString() {
return scope.toString();
}
@Override
public void applyTo(ScopedBindingBuilder scopedBindingBuilder) {
scopedBindingBuilder.in(scope);
}
};
}
示例12: applyScope
import com.google.inject.binder.ScopedBindingBuilder; //导入方法依赖的package包/类
private void applyScope(StatisticDescriptor description,
ScopedBindingBuilder binderBuilder) {
if(description.getScope() != null && !description.getScope().equals(StatisticScope.PROTOTYPE)) {
binderBuilder.in(scopes.get(description.getScope()));
}
}
示例13: applyTo
import com.google.inject.binder.ScopedBindingBuilder; //导入方法依赖的package包/类
@Override
public void applyTo(ScopedBindingBuilder scopedBindingBuilder) {
scopedBindingBuilder.in(Scopes.NO_SCOPE);
}
示例14: configure
import com.google.inject.binder.ScopedBindingBuilder; //导入方法依赖的package包/类
@Override
void configure(ScopedBindingBuilder sbb) {
sbb.in(Scopes.SINGLETON);
}
示例15: applyTo
import com.google.inject.binder.ScopedBindingBuilder; //导入方法依赖的package包/类
@Override public void applyTo(ScopedBindingBuilder scopedBindingBuilder) {
scopedBindingBuilder.in(Singleton.class);
}