问题
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;
}
I prepared a factory
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.
回答1:
I need an implementation for the qualifier annotation.
public class Some_
extends AnnotationLiteral<Some>
implements Some {
}
So that I can use like this.
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.
来源:https://stackoverflow.com/questions/29767581/how-can-i-bind-a-factory-to-a-annotation-qualified-injection-point