<div dir="ltr">Hi,<br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 19, 2015 at 8:43 PM, Mark Struberg <span dir="ltr">&lt;<a href="mailto:struberg@yahoo.de" target="_blank">struberg@yahoo.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Imagine you write some business code and your Observer needs a @RequestScoped LoggedInUser.<br>
The event gets fired by some cool library you use.<br>
<br>
Now this cool library updates to CDI-2.0 and uses fireAsync from now on. But your code still needs the @RequestScoped LoggedInUser on the same thread -&gt; booooom.<br></blockquote><div><br></div><div>You are right that this would indeed break, and that&#39;s of course bad.</div><div><br></div><div>This particular situation might be prevented though by having an @RequestScoped producer for LoggedInUser, that fetches the application specific representation of the user based on the user/caller principal. If the request scope is not propagated to async observers, but the security context is, then the code would keep working and only behind the scenes will cause the producer method to be called again.</div><div><br></div><div>But that&#39;s just for this particular situation. Any dependency on other kinds of request scoped beans would still fail of course.</div><div><br></div><div>Kind regards,</div><div>Arjan Tijms</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
LieGrue,<br>
strub<br>
<br>
&gt; Am 19.03.2015 um 18:17 schrieb José Paumard &lt;<a href="mailto:jose.paumard@gmail.com">jose.paumard@gmail.com</a>&gt;:<br>
<div class=""><div class="h5">&gt;<br>
&gt; I see the situation as being :<br>
&gt; - CDI 1.x : I call event.fireEvent(...), there is an observer that is called. Currently it is called in the same thread.<br>
&gt; - CDI 2.0 : I call event.fireEvent(...), there is an observer that is called. It will be called in the same thread.<br>
&gt;<br>
&gt; So what is the backward compatibility issue here ? From what I understand it just works the same.<br>
&gt;<br>
&gt; José<br>
&gt;<br>
&gt;<br>
&gt; 2015-03-19 17:19 GMT+01:00 Antoine Sabot-Durand &lt;<a href="mailto:antoine@sabot-durand.net">antoine@sabot-durand.net</a>&gt;:<br>
&gt; The killer argument is that nobody succeed to provide a way to prevent opt-in and keep backward compaibility. The problem comes from the fact that producer and consumer can be in different jar compiled with different version of CDI  and running on CDI 2.0 preventing using opt-out.<br>
&gt; If you have the solution without opt-in I’m all ears.<br>
&gt;<br>
&gt;<br>
&gt;&gt; Le 19 mars 2015 à 16:52, José Paumard &lt;<a href="mailto:jose.paumard@gmail.com">jose.paumard@gmail.com</a>&gt; a écrit :<br>
&gt;&gt;<br>
&gt;&gt; &gt; So it seems impossible to avoid opt-in on the observer side<br>
&gt;&gt; What is the &quot;killer&quot; argument for that ?<br>
&gt;&gt;<br>
&gt;&gt; José<br>
&gt;&gt;<br>
&gt;&gt; 2015-03-19 16:44 GMT+01:00 Antoine Sabot-Durand &lt;<a href="mailto:antoine@sabot-durand.net">antoine@sabot-durand.net</a>&gt;:<br>
&gt;&gt;<br>
&gt;&gt;&gt; Le 19 mars 2015 à 15:51, Romain Manni-Bucau &lt;<a href="mailto:rmannibucau@gmail.com">rmannibucau@gmail.com</a>&gt; a écrit :<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; sounds like a quick and dirty solution to me. @Async will arrive<br>
&gt;&gt;<br>
&gt;&gt; Yes like in “Async is coming” ;)<br>
&gt;&gt;<br>
&gt;&gt;&gt; - maybe too early today - but adding @ObservesAsync just cause we dont have yet @Async will make this API obselete pretty quickly isn&#39;t it (already cause of EJB actually).<br>
&gt;&gt;<br>
&gt;&gt; and if we add an @Async in our spec you think it’s better ?<br>
&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Do we really want this feature at this price?<br>
&gt;&gt;<br>
&gt;&gt; #1 requested feature by users.<br>
&gt;&gt;<br>
&gt;&gt;&gt; If yes AsyncObserves sounds an acceptable compromise but still will mess up the API IMO.<br>
&gt;&gt;<br>
&gt;&gt; The question is “Is it more or less messy than @Async @Observes?&quot;  I don’t know… It has pros and cons as I listed...<br>
&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Romain Manni-Bucau<br>
&gt;&gt;&gt; @rmannibucau |  Blog | Github | LinkedIn | Tomitriber<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; 2015-03-19 15:36 GMT+01:00 Antoine Sabot-Durand &lt;<a href="mailto:antoine@sabot-durand.net">antoine@sabot-durand.net</a>&gt;:<br>
&gt;&gt;&gt; Hi guys,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; So it seems impossible to avoid opt-in on the observer side for the sake of awkward compatibility.<br>
&gt;&gt;&gt; Adding a member to @Observes could also be a source of issues when old CDI lib will be used with CDI 2.0 runtime. Some of us (including me) don’t want to add an @Async annotation to CDI spec, so perhaps we should add an async alternative to @Observes with an @AsyncObserves or @ObservesAsync ?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; So it would be<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; public void myObserver(@AsyncObserves payload) {}<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; instead of<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; @Async<br>
&gt;&gt;&gt; public void myObserver(@Observes payload) {}<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Pros :<br>
&gt;&gt;&gt; - it’s a cleaner way to manage the opt-in than to put 2 annotations or add a member to an existing one<br>
&gt;&gt;&gt; - it could have new members related to async behavior (context propagation, concurrent scenario, etc…)<br>
&gt;&gt;&gt; - As it won’t be in legacy code no risk to see old observers called asynchronously<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Cons :<br>
&gt;&gt;&gt; - Still not clear for users when fire() is called to see @AsyncObserves launched synchronously<br>
&gt;&gt;&gt; - Yet another annotation added<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; wdyt ?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Antoine<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; cdi-dev mailing list<br>
&gt;&gt;&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&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;<br>
&gt;&gt;&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" 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>
&gt;&gt;&gt;<br>
&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; 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" 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>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Java le soir Cours Java en ligne<br>
&gt;&gt; Twitter Paris JUG Devoxx France<br>
&gt;&gt; M : <a href="tel:%2B33%206%2076%2082%2091%2047" value="+33676829147">+33 6 76 82 91 47</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Java le soir Cours Java en ligne<br>
&gt; Twitter Paris JUG Devoxx France<br>
&gt; M : <a href="tel:%2B33%206%2076%2082%2091%2047" value="+33676829147">+33 6 76 82 91 47</a><br>
&gt; _______________________________________________<br>
&gt; cdi-dev mailing list<br>
&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">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" 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>
<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" 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" 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.</div></div></blockquote></div><br></div></div>