Hi Emily,
I disagree, at least it doesn't add any new ambiguous injections. The use-case is specifically to Specialized/Alternative beans. Right now inheritance of managed beans is itself problematic, as injecting the base class can cause these ambiguous resolutions.
The example I sent out actually works correctly (in weld at least), really my propose is to remove the need to have Produces a second time and update the spec to clarify what happens here (FWIW, I don't believe the case is currently described in the spec), hopefully to say that qualifiers and scopes from the base method remain in effect, unless explicitly overridden.
John
@ApplicationScoped
public class Boop {
@Produces
@ApplicationScoped
public Simpler makeSimpler() {
return new Simpler("Boop");
}
}
If I want to override the producer method, I need to declare fully:
@Alternative
@Priority(100)
@ApplicationScoped
public class BoopAlternative extends Boop{
@Override
@Produces
public Simpler makeSimpler() {
return new Simpler("Boop2");
}
}
For some reason, scopes are inherited, but the produces annotation is not. At least in the case of a producer method, it seems like it would be useful for @Produces to be inherited as well.
John
lists.jboss.org
List to discuss the development of CDI (the specification) To see the collection of prior postings to the list, visit the cdi-dev Archives.
|