<div dir="ltr">I should have explained my PoV a bit better. I'm trying to take the EJB services, extract them, see if they could benefit for other components, if yes, in which spec could they go.<div><br></div><div>Today, there is less and less difference between :</div><div><br></div><div><font face="monospace, monospace">@Stateful</font></div><div><font face="monospace, monospace">@SessionScoped</font></div><div><font face="monospace, monospace">public class MySessionBean {</font></div><div><font face="monospace, monospace"> @PersistenceContext</font></div><div><font face="monospace, monospace"> EntityManager em;</font></div><div><font face="monospace, monospace"> ...</font></div><div><font face="monospace, monospace">}<br></font></div><div><br></div><div>And :</div><div><br></div><div><div><font face="monospace, monospace">@Transactional</font></div><div><font face="monospace, monospace">@SessionScoped</font></div><div><span style="font-family:monospace,monospace">public class </span><span style="font-family:monospace,monospace">MySessionBean</span><span style="font-family:monospace,monospace"> {</span><br></div><div><font face="monospace, monospace"> @PersistenceContext</font></div><div><font face="monospace, monospace"> EntityManager em;</font></div><div><font face="monospace, monospace"> ...</font></div><div><font face="monospace, monospace">}<br></font></div></div><div><br></div><div>So I wonder if it would make sense to bother with @PostActivate, @PrePassivate. I could see the benefit of @Remove though.</div><div><br></div><div>Antonio</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Dec 28, 2014 at 5:21 PM, arjan tijms <span dir="ltr"><<a href="mailto:arjan.tijms@gmail.com" target="_blank">arjan.tijms@gmail.com</a>></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"><div dir="ltr">Hi,<br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Sun, Dec 28, 2014 at 1:52 PM, John D. Ament <span dir="ltr"><<a href="mailto:john.d.ament@gmail.com" target="_blank">john.d.ament@gmail.com</a>></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">EJBs work off of a pool of objects and these life cycle methods are typically used (from the use cases I've dealt with them) to initiate or destroy some end user data for the context in which they are used.<br></blockquote><div><br></div></span><div>@PrePassivate/@PostActivate are used with @Stateful beans, which being unique instances are far less likely to be pooled. Pools are mostly used for @Stateless beans (if pools are used at all, the spec doesn't mandate those).</div><div><br></div><div>Kind regards,</div><div>Arjan Tijms</div><span class=""><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"><div><br></div><div>I think you might be thinking of PostConstruct/PreDestroy which match to the CDI/ManagedBean paradigm better. There's no pool of these objects around, they simply get created and destroyed when done. For each of the scopes you mentioned, I would use a PostConstruct/PreDestroy method to do the same thing.</div><div><br></div><div>John</div><br><div class="gmail_quote"><div><div>On Sun Dec 28 2014 at 7:39:14 AM Antonio Goncalves <<a href="mailto:antonio.goncalves@gmail.com" target="_blank">antonio.goncalves@gmail.com</a>> wrote:<br></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"><div><div><div dir="ltr">Hi all,<div><br></div><div>I was playing with @SessionScoped beans... and wondered if @PostActivate, @PrePassivate and @Remove would make sense in JSR 250 ?</div><div><br></div><div>At the moment these annotations belong to the javax.ejb package and are only used in @Stateful EJBs. With CDI scopes, we end up with a few "stateful" scopes (@SessionScoped, but also @ConversationScoped, @ViewScoped...) so why not having the same functionality in CDI ? @PreDestroy and @PostConstruct are already part of JSR 250. So why not having @PostActivate and @PrePassivate as well so they could be used in every bean ? </div><div><br></div><div>BTW, while I was playing with @SessionScoped beans, I asked Antoine to show me how to remove a bean from the session. It's only a few lines of code, but again, why not having a @Remove annotation that does that (the exact same one of javax.ejb.Remove) ?<br><div class="gmail_extra"><br><div class="gmail_quote">To summarize, why not taking some of those stateful EJB concerns back to JSR 250 so they could be used anywhere ?</div><div class="gmail_quote"><br></div><div class="gmail_quote">Any thoughts ?</div><div><br></div>-- <br><div><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></div></div></div></div>
______________________________<u></u>_________________<br>
cdi-dev mailing list<br>
<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/<u></u>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/<u></u>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.</blockquote></div>
<br>_______________________________________________<br>
cdi-dev mailing list<br>
<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">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.<br></blockquote></span></div><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></div>