<p dir="ltr">Hi Nigel,</p>
<p dir="ltr">Check the error message, I think it&#39;s not the same method you referenced it. However I would like to see @WithAnnotations or a similar solution for other Process* types.</p>
<p dir="ltr">Best Regards,</p>
<p dir="ltr">George Gastaldi</p>
<div class="gmail_quote">Em 14/08/2015 09:04, &quot;Nigel Deakin&quot; &lt;<a href="mailto:nigel.deakin@oracle.com">nigel.deakin@oracle.com</a>&gt; escreveu:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I&#39;m writing a portable extension, and my Extension class includes the following observer method<br>
<br>
   public &lt;X&gt; void processInjectionTarget(<br>
       @Observes ProcessInjectionTarget&lt;X&gt; event) {<br>
<br>
When I start the server (Glassfish) I see this warning in the log:<br>
<br>
   WELD-000411: Observer method [BackedAnnotatedMethod] public com.foo.MyExtension.processAnnotatedType(@Observes<br>
ProcessAnnotatedType&lt;Object&gt;) receives events for all annotated types. Consider restricting events using<br>
@WithAnnotations or a generic type with bounds.]]<br>
<br>
I thought &quot;OK, fair enough. I only want to receive ProcessInjectionTarget events for classes that have a specific<br>
annotation. So I&#39;ll do what it suggests and @WithAnnotations to restrict the events received.&quot;<br>
<br>
However if I look up the javadocs for WithAnnotations it says &quot;WithAnnotations may be applied to any portable extension<br>
observer method with an event parameter type of ProcessAnnotatedType to filter the events delivered.&quot;<br>
<br>
And if I try using WithAnnotations on the above method, I indeed get an error at runtime.<br>
<br>
So the warning message WELD-000411 is incorrect, since it suggests doing something that is not allowed.<br>
<br>
@WithAnnotations would have been perfect for my needs. Why is it not allowed when observing ProcessInjectionTarget events?<br>
<br>
So it looks as if I will simply have to receive every such event and check whether it has the required annotation:<br>
<br>
   public &lt;X&gt; void processInjectionTarget(<br>
       @Observes ProcessInjectionTarget&lt;X&gt; event) {<br>
<br>
      if (!event.getAnnotatedType().isAnnotationPresent(MyAnnotation.class)) {<br>
         return;<br>
     }<br>
<br>
This doesn&#39;t look very efficient to me, since there will be a lot of irrelevant events. Is there a better way?<br>
<br>
Nigel<br>
<br>
<br>
_______________________________________________<br>
cdi-dev mailing list<br>
<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
<br>
Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="noreferrer" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.<br>
</blockquote></div>