My problem is probably best explained with some sample code:
@Named
public class Search {
@Inject @Select(Type.SEARCH)
private Criteria criteria;
}
@Named
public class Selection {
@Inject @Select(Type.SELECTION)
private Criteria criteria;
}
public class Criteria {
private final List<Selection> statics;
private final List<Selection> choosables;
@Inject
public Criteria(
@Any Instance<List<Selection>> statics,
@Select(Type.CHOOSABLE) List<Selection> choosables,
InjectionPoint ip) {
Select sel = ip.getAnnotated().getAnnotation(Select.class);
this.statics = cloneList(statics.select(sel).get());
choosables = cloneList(choosables);
}
}
The idea is that Criteria
has all the logic to deal with lists of Selection
objects, but the actual lists to manage vary depending on the user of the Criteria
class. As it stands, Weld complains about being unable find a class with the matching qualifiers, since Criteria
isn't annotated @Select
. So - can I make Criteria
eligible for injection no matter the @Select
qualifier? Or is there another way to pass that piece of information to the Criteria
class?
Edit: turns out, the question has already been asked in a similar form here.