<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
George,<br>
<br>
Yes, you're right. That warning refers to a different method of the
same extension (which is obvious now). Thanks for pointing that out.
So the WELD message is correct.<br>
<br>
So that just leaves me asking whether it would be desirable to
support @WithAnnotations with ProcessInjectionTarget events, to
avoid the need to call isAnnotationPresent() on every injection
target.<br>
<br>
Nigel<br>
<br>
<div class="moz-cite-prefix">On 14/08/2015 13:52, George Gastaldi
wrote:<br>
</div>
<blockquote
cite="mid:CAMmsnJgYgrdKo2mOo2DABVOKhoi6gEyZDW_hpgwp0HDK-rsraQ@mail.gmail.com"
type="cite">
<p dir="ltr">Hi Nigel,</p>
<p dir="ltr">Check the error message, I think it'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, "Nigel Deakin" <<a
moz-do-not-send="true" href="mailto:nigel.deakin@oracle.com">nigel.deakin@oracle.com</a>>
escreveu:<br type="attribution">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">I'm writing
a portable extension, and my Extension class includes the
following observer method<br>
<br>
public <X> void processInjectionTarget(<br>
@Observes ProcessInjectionTarget<X> 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<Object>) receives events for all
annotated types. Consider restricting events using<br>
@WithAnnotations or a generic type with bounds.]]<br>
<br>
I thought "OK, fair enough. I only want to receive
ProcessInjectionTarget events for classes that have a specific<br>
annotation. So I'll do what it suggests and @WithAnnotations
to restrict the events received."<br>
<br>
However if I look up the javadocs for WithAnnotations it says
"WithAnnotations may be applied to any portable extension<br>
observer method with an event parameter type of
ProcessAnnotatedType to filter the events delivered."<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 <X> void processInjectionTarget(<br>
@Observes ProcessInjectionTarget<X> event) {<br>
<br>
if
(!event.getAnnotatedType().isAnnotationPresent(MyAnnotation.class))
{<br>
return;<br>
}<br>
<br>
This doesn'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 moz-do-not-send="true"
href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<a moz-do-not-send="true"
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
moz-do-not-send="true"
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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
cdi-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/cdi-dev">https://lists.jboss.org/mailman/listinfo/cdi-dev</a>
Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (<a class="moz-txt-link-freetext" href="http://www.apache.org/licenses/LICENSE-2.0.html">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.</pre>
</blockquote>
<br>
</body>
</html>