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.<br><br>Consider the following:<br><br>class PotatoChip {<br>}<br>
<br>class SnackFactory() {<br> public @Produces PotatoChip createPotatoChip() {<br> return new PotatoChip();<br> }<br>}<br><br>1) Does the produced PotatoChip take precedence over the raw dependent type when being selected for injection?<br>
<br>2) How do I get the Bean<PotatoChip> that represents the producer method?<br><br>BeanManager#getBeans(PotatoChip.class) returns two beans that are indistinguishable from the public API.<br><br>3) What if the producer method is @RequestScoped? How do I get the request-scoped produce instead of the dependent bean?<br>
<br> Bean<PotatoChip> potatoChipBean = null;<br> for (Bean<PotatoChip> candidate : getBeans(PotatoChip.class))<br> {<br> if (candidate.getScopeType().equals(RequestScoped.class))<br> {<br>
potatoChipBean = candidate;<br> break;<br> }<br> }<br><br>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.<br>
<br>-Dan<br clear="all"><br>-- <br>Dan Allen<br>Senior Software Engineer, Red Hat | Author of Seam in Action<br>Registered Linux User #231597<br><br><a href="http://mojavelinux.com">http://mojavelinux.com</a><br><a href="http://mojavelinux.com/seaminaction">http://mojavelinux.com/seaminaction</a><br>
<a href="http://in.relation.to/Bloggers/Dan">http://in.relation.to/Bloggers/Dan</a><br>