<div dir="ltr">Yes, really good point : Extended Persistence Context....<div><br></div><div>Hum....</div><div><br></div><div>Antonio</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Dec 28, 2014 at 5:45 PM, Romain Manni-Bucau <span dir="ltr">&lt;<a href="mailto:rmannibucau@gmail.com" target="_blank">rmannibucau@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">you surely forgot a detail only @Stateful handle: extended PC. That&#39;s<br>
where stateful makes sense and @Transactional doesn&#39;t help. Then there<br>
is nowhere else ATM where passivation is defined (even not in CDI with<br>
passivable things). Do you plan to specify it in CDI?<br>
<span class="im HOEnZb"><br>
<br>
Romain Manni-Bucau<br>
@rmannibucau<br>
<a href="http://www.tomitribe.com" target="_blank">http://www.tomitribe.com</a><br>
<a href="http://rmannibucau.wordpress.com" target="_blank">http://rmannibucau.wordpress.com</a><br>
<a href="https://github.com/rmannibucau" target="_blank">https://github.com/rmannibucau</a><br>
<br>
<br>
</span><div class="HOEnZb"><div class="h5">2014-12-28 17:42 GMT+01:00 Antonio Goncalves &lt;<a href="mailto:antonio.goncalves@gmail.com">antonio.goncalves@gmail.com</a>&gt;:<br>
&gt; I should have explained my PoV a bit better. I&#39;m trying to take the EJB<br>
&gt; services, extract them, see if they could benefit for other components, if<br>
&gt; yes, in which spec could they go.<br>
&gt;<br>
&gt; Today, there is less and less difference between :<br>
&gt;<br>
&gt; @Stateful<br>
&gt; @SessionScoped<br>
&gt; public class MySessionBean {<br>
&gt;   @PersistenceContext<br>
&gt;   EntityManager em;<br>
&gt;   ...<br>
&gt; }<br>
&gt;<br>
&gt; And :<br>
&gt;<br>
&gt; @Transactional<br>
&gt; @SessionScoped<br>
&gt; public class MySessionBean {<br>
&gt;   @PersistenceContext<br>
&gt;   EntityManager em;<br>
&gt;   ...<br>
&gt; }<br>
&gt;<br>
&gt; So I wonder if it would make sense to bother with @PostActivate,<br>
&gt; @PrePassivate. I could see the benefit of @Remove though.<br>
&gt;<br>
&gt; Antonio<br>
&gt;<br>
&gt;<br>
&gt; On Sun, Dec 28, 2014 at 5:21 PM, arjan tijms &lt;<a href="mailto:arjan.tijms@gmail.com">arjan.tijms@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; On Sun, Dec 28, 2014 at 1:52 PM, John D. Ament &lt;<a href="mailto:john.d.ament@gmail.com">john.d.ament@gmail.com</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; EJBs work off of a pool of objects and these life cycle methods are<br>
&gt;&gt;&gt; typically used (from the use cases I&#39;ve dealt with them) to initiate or<br>
&gt;&gt;&gt; destroy some end user data for the context in which they are used.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; @PrePassivate/@PostActivate are used with @Stateful beans, which being<br>
&gt;&gt; unique instances are far less likely to be pooled. Pools are mostly used for<br>
&gt;&gt; @Stateless beans (if pools are used at all, the spec doesn&#39;t mandate those).<br>
&gt;&gt;<br>
&gt;&gt; Kind regards,<br>
&gt;&gt; Arjan Tijms<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I think you might be thinking of PostConstruct/PreDestroy which match to<br>
&gt;&gt;&gt; the CDI/ManagedBean paradigm better.  There&#39;s no pool of these objects<br>
&gt;&gt;&gt; around, they simply get created and destroyed when done.  For each of the<br>
&gt;&gt;&gt; scopes you mentioned, I would use a PostConstruct/PreDestroy method to do<br>
&gt;&gt;&gt; the same thing.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; John<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Sun Dec 28 2014 at 7:39:14 AM Antonio Goncalves<br>
&gt;&gt;&gt; &lt;<a href="mailto:antonio.goncalves@gmail.com">antonio.goncalves@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Hi all,<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I was playing with @SessionScoped beans... and wondered if<br>
&gt;&gt;&gt;&gt; @PostActivate, @PrePassivate and @Remove would make sense in JSR 250 ?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; At the moment these annotations belong to the javax.ejb package and are<br>
&gt;&gt;&gt;&gt; only used in @Stateful EJBs. With CDI scopes, we end up with a few<br>
&gt;&gt;&gt;&gt; &quot;stateful&quot; scopes (@SessionScoped, but also @ConversationScoped,<br>
&gt;&gt;&gt;&gt; @ViewScoped...) so why not having the same functionality in CDI ?<br>
&gt;&gt;&gt;&gt; @PreDestroy and @PostConstruct are already part of JSR 250. So why not<br>
&gt;&gt;&gt;&gt; having @PostActivate and @PrePassivate as well so they could be used in<br>
&gt;&gt;&gt;&gt; every bean ?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; BTW, while I was playing with @SessionScoped beans, I asked Antoine to<br>
&gt;&gt;&gt;&gt; show me how to remove a bean from the session. It&#39;s only a few lines of<br>
&gt;&gt;&gt;&gt; code, but again, why not having a @Remove annotation that does that (the<br>
&gt;&gt;&gt;&gt; exact same one of javax.ejb.Remove) ?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; To summarize, why not taking some of those stateful EJB concerns back to<br>
&gt;&gt;&gt;&gt; JSR 250 so they could be used anywhere ?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Any thoughts ?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; --<br>
&gt;&gt;&gt;&gt; Antonio Goncalves<br>
&gt;&gt;&gt;&gt; Software architect, Java Champion and Pluralsight author<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Web site | Twitter | LinkedIn | Pluralsight | Paris JUG | Devoxx France<br>
&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt; cdi-dev mailing list<br>
&gt;&gt;&gt;&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt;&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;&gt;<br>
&gt;&gt;&gt;&gt; Note that for all code provided on this list, the provider licenses the<br>
&gt;&gt;&gt;&gt; code under the Apache License, Version 2<br>
&gt;&gt;&gt;&gt; (<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<br>
&gt;&gt;&gt;&gt; provided on this list, the provider waives all patent and other intellectual<br>
&gt;&gt;&gt;&gt; property rights inherent in such information.<br>
&gt;&gt;&gt;<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<br>
&gt;&gt;&gt; code under the Apache License, Version 2<br>
&gt;&gt;&gt; (<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<br>
&gt;&gt;&gt; provided on this list, the provider waives all patent and other intellectual<br>
&gt;&gt;&gt; property rights inherent in such information.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Antonio Goncalves<br>
&gt; Software architect, Java Champion and Pluralsight author<br>
&gt;<br>
&gt; Web site | Twitter | LinkedIn | Pluralsight | Paris JUG | Devoxx France<br>
&gt;<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<br>
&gt; under the Apache License, Version 2<br>
&gt; (<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<br>
&gt; provided on this list, the provider waives all patent and other intellectual<br>
&gt; property rights inherent in such information.<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Antonio Goncalves <br>Software architect, Java Champion and Pluralsight author<br><br><a href="http://www.antoniogoncalves.org" target="_blank">Web site</a> | <a href="http://twitter.com/agoncal" target="_blank">Twitter</a> | <a href="http://www.linkedin.com/in/agoncal" target="_blank">LinkedIn</a> | <a href="http://pluralsight.com/training/Authors/Details/antonio-goncalves" target="_blank">Pluralsight</a> | <a href="http://www.parisjug.org" target="_blank">Paris JUG</a> | <a href="http://www.devoxx.fr" target="_blank">Devoxx France</a></div></div>
</div>