<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. 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 <mkouba@redhat.com><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> </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>
"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."<br>
<br>
I think it wouldn't hurt to add:<br>
<br>
"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."<br>
<br>
Weld throws a DefinitionException.<br>
<br>
Martin<br>
<br>
Dne 6.3.2017 v 07:55 Tomas Remes napsal(a):<br>
><br>
> Hi John,<br>
><br>
> 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>
><br>
> Tom<br>
><br>
> ----- Original Message -----<br>
> From: "John Ament" <john.ament@spartasystems.com><br>
> To: "cdi-dev" <cdi-dev@lists.jboss.org><br>
> Sent: Monday, March 6, 2017 1:42:09 AM<br>
> Subject: [cdi-dev] Can an observer be both async and sync?<br>
><br>
><br>
><br>
> Section 10.4.4 has the following section which got me thinking<br>
><br>
><br>
><br>
><br>
><br>
> public void refreshOnDocumentUpdate(@Observes(notifyObserver=IF_EXISTS) @Updated Document doc) { ... }<br>
><br>
> public void asyncRefreshOnDocumentUpdate(@ObservesAsync(notifyObserver=IF_EXISTS) @Updated Document doc) { ... }<br>
><br>
><br>
><br>
><br>
><br>
> I'm wondering, is it OK to have an observer method defined like this?<br>
><br>
><br>
><br>
><br>
><br>
> public void asyncRefreshOnDocumentUpdate( @Observes(notifyObserver=IF_EXISTS) @ObservesAsync(notifyObserver=IF_EXISTS) @Updated Document doc) { ... }<br>
><br>
><br>
><br>
><br>
><br>
> 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>
><br>
><br>
><br>
><br>
> John<br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
> 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>
><br>
> _______________________________________________<br>
> cdi-dev mailing list<br>
> cdi-dev@lists.jboss.org<br>
> <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" id="LPlnk372983">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">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>
><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>