[webbeans-dev] producer method trumps raw dependent type?
Dan Allen
dan.j.allen at gmail.com
Tue Jul 21 22:18:46 EDT 2009
After the recent revisions of the JSR-299 spec, I'm finding that I'm a tad
confused about the bean selection algorithm when a producer method exists.
Consider the following:
class PotatoChip {
}
class SnackFactory() {
public @Produces PotatoChip createPotatoChip() {
return new PotatoChip();
}
}
1) Does the produced PotatoChip take precedence over the raw dependent type
when being selected for injection?
2) How do I get the Bean<PotatoChip> that represents the producer method?
BeanManager#getBeans(PotatoChip.class) returns two beans that are
indistinguishable from the public API.
3) What if the producer method is @RequestScoped? How do I get the
request-scoped produce instead of the dependent bean?
Bean<PotatoChip> potatoChipBean = null;
for (Bean<PotatoChip> candidate : getBeans(PotatoChip.class))
{
if (candidate.getScopeType().equals(RequestScoped.class))
{
potatoChipBean = candidate;
break;
}
}
Sorry if this sounds like a dumb question. The spec has changed a lot and my
memory is getting mixed in with the current set of facts.
-Dan
--
Dan Allen
Senior Software Engineer, Red Hat | Author of Seam in Action
Registered Linux User #231597
http://mojavelinux.com
http://mojavelinux.com/seaminaction
http://in.relation.to/Bloggers/Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20090721/8b5dbb2d/attachment.html
More information about the weld-dev
mailing list