Well, I think my issue as that it worked the exact way I needed it to work, so I figured I was fine :-) .  Obviously though, I ran into some limitations with it.<br><br>So just to bounce some ideas off you guys; what would be the correct approach in this case? Assuming that I want it to be taken into account when resolving injection points, do I need to gather metadata around injection points and dynamically build producer method impl&#39;s that are generated at deployment type via an extension that did something like:<br>
<br>1. Scan for any injection points that match the type(s) as well as qualifier(s) that I am interested in.<br>2. Also understand the scope of the object they are being injected into.<br><br>However, it seems like producers are the one thing that you cannot register at runtime/deployment time.  Is this a case where I would need to create bean instances instead of producer instances?<br>
<br>Thanks for the help guys<br><br>John<br><br><div class="gmail_quote">On Thu, Sep 8, 2011 at 3:25 PM, Pete Muir <span dir="ltr">&lt;<a href="mailto:pmuir@redhat.com">pmuir@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
As Mark says ;-) But from the way I read your comment, I think you&#39;ve got @Nonbinding the wrong way up completely.<br>
<div><div></div><div class="h5"><br>
On 8 Sep 2011, at 14:54, Mark Struberg wrote:<br>
<br>
&gt; @Nonbinding is pretty easy to explain:<br>
&gt;<br>
&gt; when comparing Annotations e.g.<br>
&gt;<br>
&gt;<br>
&gt; public Car @Produces @RequestScoped @Status(color=&quot;red&quot;, quality=3) getCarInfo() { return ...<br>
&gt;<br>
&gt; and the injection point<br>
&gt;<br>
&gt; private @Inject @Status(color=&quot;green&quot;, quality=3) Car myCar;<br>
&gt;<br>
&gt;<br>
&gt; then all  the members of the 2 annotations (color and quality) will be checked on equality!<br>
&gt;<br>
&gt; But if you mark some of your annotations members with @Nonbinding, then they will simply get ignored in the comparison!<br>
&gt; So if you only like to carry payload data, then use @Nonbinding.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; This is not only handy for @Qualifier annotations but also e.g. for Interceptors and Decorators!<br>
&gt;<br>
&gt; It is for example very useful when it comes to InterceptorBindings:<br>
&gt;<br>
&gt; Imagine the following annotation:<br>
&gt;<br>
&gt; @InterceptorBinding ...<br>
&gt;<br>
&gt; public @interface Transactional {<br>
&gt;   javax.ejb.TransactionAttributeType transactionAttributeType;<br>
&gt; }<br>
&gt;<br>
&gt;<br>
&gt; And since the transactionAttributeType is NOT annotated @Nonbinding, the following InterceptorBindings are NOT equals!<br>
&gt;<br>
&gt; @Transactional(transactionAttributeType=REQUIRES_NEW)<br>
&gt; @Transactional(transactionAttributeType=NEVER)<br>
&gt;<br>
&gt;<br>
&gt; Which means that you would need to provide 1 interceptor implementation per transactionAttributeType!<br>
&gt;<br>
&gt;<br>
&gt; But if you add @Nonbinding and write<br>
&gt;<br>
&gt; @InterceptorBinding ...<br>
&gt;<br>
&gt; public @interface Transactional {<br>
&gt;   @Nonbinding javax.ejb.TransactionAttributeType transactionAttributeType;<br>
&gt; }<br>
&gt;<br>
&gt; , then 1<br>
&gt; @Interceptor<br>
&gt; @Transactional<br>
&gt; public class MyOnlyOneTransInterceptor {...<br>
&gt;<br>
&gt; is perfectly enough.<br>
&gt;<br>
&gt; got me?<br>
&gt;<br>
&gt; LieGrue,<br>
&gt; strub<br>
&gt;<br>
&gt;<br>
&gt;&gt; ________________________________<br>
&gt;&gt; From: John D. Ament &lt;<a href="mailto:john.d.ament@gmail.com">john.d.ament@gmail.com</a>&gt;<br>
&gt;&gt; To: Pete Muir &lt;<a href="mailto:pmuir@redhat.com">pmuir@redhat.com</a>&gt;<br>
&gt;&gt; Cc: <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt;&gt; Sent: Thursday, September 8, 2011 8:21 PM<br>
&gt;&gt; Subject: Re: [cdi-dev] RequestScoped and Injection Points<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Pete,<br>
&gt;&gt;<br>
&gt;&gt; So, I&#39;ve always treated Nonbinding as not binding against the parameter, treating separate values as separate qualifiers.  When using a producer, you end up needing separate producers for each value that you want to support.  This thought is roughly what I was trying to dive through.<br>

&gt;&gt;<br>
&gt;&gt; John<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Thu, Sep 8, 2011 at 12:19 PM, Pete Muir &lt;<a href="mailto:pmuir@redhat.com">pmuir@redhat.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Oh yes, let me redo it ;-)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; @Retention(RUNTIME)<br>
&gt;&gt;&gt; @interface Foo {<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;  String bar();<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; And use it:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; @RequestScoped<br>
&gt;&gt;&gt; class A {<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;  /// Illegal<br>
&gt;&gt;&gt;  @Inject InjectionPoint ip;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; class B {<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; @Inject @Foo(bar=&quot;baz&quot;) A a;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; class C {<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; @Inject @Foo(bar=&quot;qux&quot;) A a;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; And then let&#39;s say we have:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; @RequestScoped<br>
&gt;&gt;&gt; class D {<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; @Inject C c;<br>
&gt;&gt;&gt; @Inject B b;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On 8 Sep 2011, at 12:15, John D. Ament wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I think something&#39;s wrong with your example, but I think I get what you mean.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; My point is that if Foo were a qualifier and not just an annotation, should they really be the same injected instance?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; If &quot;bar&quot; was binding, it would be a different instance, if bar was non binding, it would be the same instance.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;  It seems like @Nonbinding when used in @RequestScoped is irrelevant,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; It&#39;s not really relevant or irrelevant, it&#39;s just orthogonal. @Nonbinding affects type bean resolution, which is an orthogonal concept to scoping of beans.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; But a non binding attribute is still non binding when used with @RequestScoped.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; but i&#39;m not sure the spec makes this clear (though in actuality I&#39;m against that idea that it wouldn&#39;t work).<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I think we still have a mismatch in understanding here, as really @Nonbinding has nothing to do with scoping, which is why the spec doesn&#39;t call this out.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; On Thu, Sep 8, 2011 at 11:59 AM, Pete Muir &lt;<a href="mailto:pmuir@redhat.com">pmuir@redhat.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt; No.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Continuing my example, I introduce some new annotation (not a qualifier):<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; @Retention(RUNTIME)<br>
&gt;&gt;&gt;&gt; @interface Foo {<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;   String bar();<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; And use it:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; @RequestScoped<br>
&gt;&gt;&gt;&gt; class A {<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;  /// Illegal<br>
&gt;&gt;&gt;&gt;  @Inject InjectionPoint ip;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; class B {<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; @Inject @Bar(&quot;baz&quot;) A a;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; class C {<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; @Inject @Bar(&quot;qux&quot;) A a;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; And then let&#39;s say we have:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; @RequestScoped<br>
&gt;&gt;&gt;&gt; class D {<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; @Inject C c;<br>
&gt;&gt;&gt;&gt; @Inject B b;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; The *same* instance of A will be injected into B &amp; C when D is accessed. The injection points allow access to the Annotated, which reflects two different injection points.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Not gonna work ;-)<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; On 8 Sep 2011, at 11:40, John D. Ament wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Pete, Mark,<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; So I get there is no single injection point, however it should be the case that every injection point is declared the same way, no?  E.g. they&#39;re the &quot;same&quot; in the sense that the line of code is the same, but different in that they exist in different areas.<br>

&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; John<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; On Wed, Sep 7, 2011 at 8:38 AM, Pete Muir &lt;<a href="mailto:pmuir@redhat.com">pmuir@redhat.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt; For a request scoped bean there is not a single injection point, like there is for dependent beans. Say I have a request scoped bean, Bean A.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; I have two other beans, of any scope, Bean B and Bean C.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; If both beans B and C inject A in the same request, then the injection point for A is both Bean B and Bean C.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Furthermore, client proxies mean that bean A is instantiated lazily, to solve the circular injection problem, and so has no knowledge of it&#39;s injection point when actually created.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; On 7 Sep 2011, at 01:10, John D. Ament wrote:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; CDI Experts<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; Was wondering if you could help me understand rationale.  In request scoped objects, when you create a producer method that creates request scoped instances, why is there no access to the underlying injection point?<br>

&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; Let&#39;s say that you have a qualifier with a single String value attribute that is nonbinding; let&#39;s say @JmsDestination.  You have the following injection points:<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; @Inject @JmsDestination(&quot;jms/MyQueue&quot;) MessageProducer queueProducer;<br>
&gt;&gt;&gt;&gt;&gt;&gt; @Inject @JmsDestination(&quot;jms/MyTopic&quot;) MessageProducer topicProducer;<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; In this case, two distinct MessageProducers should be injected.  The CDI container should be able to differentiate the two, since they have different values on the qualifier.  However, CDI disallows this since the producer methods used to create them would not have access to the injection point.  If a second injection point is found, CDI should return the same instance.<br>

&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; I hope it doesn&#39;t sound like I&#39;m babbling, but I wanted to put the question out there to see if it&#39;s something that could be addressed.<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; Regards,<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; John<br>
&gt;&gt;&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt;&gt;&gt; cdi-dev mailing list<br>
&gt;&gt;&gt;&gt;&gt;&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt;&gt;&gt;&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; cdi-dev mailing list<br>
&gt;&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
<br>
</div></div></blockquote></div><br>