<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p>I'll put in a ticket to update the spec. &nbsp;I agree that it was intended to be forbidden, but I couldn't find anything saying it was.</p>
<p><br>
</p>
<p>John</p>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<div style="color:rgb(33,33,33); font-size:15px; margin:0px"><br>
</div>
<p></p>
</div>
</div>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Martin Kouba &lt;mkouba@redhat.com&gt;<br>
<b>Sent:</b> Monday, March 6, 2017 4:15 AM<br>
<b>To:</b> Tomas Remes; John Ament<br>
<b>Cc:</b> cdi-dev<br>
<b>Subject:</b> Re: [cdi-dev] Can an observer be both async and sync?</font>
<div>&nbsp;</div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Well, it's not 100% clear but I believe it should be forbidden. The spec
<br>
only states:<br>
<br>
&quot;An observer method may be declared by annotating a parameter <br>
@javax.enterprise.event.Observes OR <br>
@javax.enterprise.event.ObservesAsync of a default-access, public, <br>
protected or private method. That parameter is the event parameter.&quot;<br>
<br>
I think it wouldn't hurt to add:<br>
<br>
&quot;If an event parameter is annotated with both @Observes and <br>
@ObservesAsync, the container automatically detects the problem and <br>
treats it as a definition error.&quot;<br>
<br>
Weld throws a DefinitionException.<br>
<br>
Martin<br>
<br>
Dne 6.3.2017 v 07:55 Tomas Remes napsal(a):<br>
&gt;<br>
&gt; Hi John,<br>
&gt;<br>
&gt; No it shouldn't. The problematic and confusing case would be when there is some other param (injection point) in this observer method and this param resolves to let's say @SessionScoped bean. How does it work then? Once it fails (since there's no context
 propagation for async event), once it works (sync event)? Therefore this was forbidden.<br>
&gt;<br>
&gt; Tom<br>
&gt;<br>
&gt; ----- Original Message -----<br>
&gt; From: &quot;John Ament&quot; &lt;john.ament@spartasystems.com&gt;<br>
&gt; To: &quot;cdi-dev&quot; &lt;cdi-dev@lists.jboss.org&gt;<br>
&gt; Sent: Monday, March 6, 2017 1:42:09 AM<br>
&gt; Subject: [cdi-dev] Can an observer be both async and sync?<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Section 10.4.4 has the following section which got me thinking<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; public void refreshOnDocumentUpdate(@Observes(notifyObserver=IF_EXISTS) @Updated Document doc) { ... }<br>
&gt;<br>
&gt; public void asyncRefreshOnDocumentUpdate(@ObservesAsync(notifyObserver=IF_EXISTS) @Updated Document doc) { ... }<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; I'm wondering, is it OK to have an observer method defined like this?<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; public void asyncRefreshOnDocumentUpdate( @Observes(notifyObserver=IF_EXISTS) @ObservesAsync(notifyObserver=IF_EXISTS) @Updated Document doc) { ... }<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; I don't see anything against this in the spec, but I suspect most people are going to think this shouldn't work. So I'm asking the question - should it work?<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; John<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; NOTICE: This e-mail message and any attachments may contain confidential, proprietary, and/or privileged information which should be treated accordingly. If you are not the intended recipient, please notify the sender immediately by return e-mail, delete
 this message, and destroy all physical and electronic copies. Thank you.<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; cdi-dev mailing list<br>
&gt; cdi-dev@lists.jboss.org<br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" id="LPlnk372983">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;<br>
&gt; 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">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>
&gt;<br>
<br>
-- <br>
Martin Kouba<br>
Senior Software Engineer<br>
Red Hat, Czech Republic<br>
</div>
</span></font></div>
</div>
<hr>
NOTICE: This e-mail message and any attachments may contain confidential, proprietary, and/or privileged information which should be treated accordingly. If you are not the intended recipient, please notify the sender immediately by return e-mail, delete this
 message, and destroy all physical and electronic copies. Thank you.
</body>
</html>