如何将工厂绑定到注释合格的注入点? [英] How can I bind a factory to a annotation-qualified injection point?
本文介绍了如何将工厂绑定到注释合格的注入点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我询问,并得到了如何绑定命名注入点的答案.
I asked and got an answer how to bind a named injection point.
我不知道如何将工厂绑定到合格的注入点.
And I don't know how to bind a factory to a qualified injection point.
class SomeResource {
@Inject
@Some // is a @Qualifier, of course.
private MyType qualified;
}
我准备了一家工厂
class SomeFactory extends Factory<MyType> {
}
我坚持要为此创建活页夹
And I stuck on creating a binder for that
class SomeBinder extends AbstractBinder {
@Override protected void configure() {
// @@?
}
}
I actually want to know how to use ServiceBindingBuilder#qualifiedBy.
推荐答案
我需要一个用于限定符注释的实现.
I need an implementation for the qualifier annotation.
public class Some_
extends AnnotationLiteral<Some>
implements Some {
}
以便我可以这样使用.
bindFactory(Someactory.class)
.qualifiedBy(new Some_())
.to(MyType.class);
I really don't understand why ServiceBindingBuilder doesn't have a method taking an annotation class not an instance.
这篇关于如何将工厂绑定到注释合格的注入点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文