<html><body>
<p><tt>Instead, could we provide an 80% success case and make the rest undefined?</tt><br>
<br>
<tt>I'd rather say, if the bean defines an @Remove method with the signature</tt><br>
<tt>void &lt;method_name&gt;(); then that method will be called at the end of the context.</tt><br>
<tt>If multiple @Remove methods exist that follow that pattern, the results</tt><br>
<tt>are undefined (i.e. containers may destroy the bean without calling any</tt><br>
<tt>or may call an arbitrary @Remove method). &nbsp;All exceptions thrown during </tt><br>
<tt>a call of the @Remove method are ignored, but should be logged.</tt><br>
<br>
<tt>This at least exercises typical component lifecycle behavior in the </tt><br>
<tt>typical cases. &nbsp;It also correlates (somewhat) with the way the JavaBeans</tt><br>
<tt>spec. expects JavaBeans components to be handled (i.e. method patterns).</tt><br>
<tt>In other words, when the container/runtime understands how to do something,</tt><br>
<tt>it should do it.</tt><br>
<tt><br>
Thanks,<br>
Jim Knutson<br>
WebSphere J2EE Architect</tt><br>
<br>
<tt>gavin.king@gmail.com wrote on 01/06/2009 06:04:15 PM:<br>
<br>
&gt; &gt; Is there some rationale for why the context lifecycle management shouldn't<br>
&gt; &gt; drive the typical client lifecycle methods of the beans?<br>
&gt; <br>
&gt; Jim, this is what we used to have, but it was causing all kinds of<br>
&gt; problems. Basically, there is no good way to decide *which* remove<br>
&gt; method the context should call to destroy the stateful bean. Stateful<br>
&gt; beans can have an arbitrary set of remove methods and each of these<br>
&gt; potentially has &quot;special&quot; semantics that go beyond simple destruction<br>
&gt; of the bean. So there's no way for Web Beans to decide on its own<br>
&gt; which one to call. Nor can we rely upon the user annotating the<br>
&gt; &quot;right&quot; @Remove method, since we're supposed to be supporting<br>
&gt; pre-existing EJBs with no special annotations. Nor can we require that<br>
&gt; the user explicitly call the @Remove method before the context ends,<br>
&gt; because any exceptions that occur during context destruction need to<br>
&gt; be swallowed and logged - they occur too late in the request lifecycle<br>
&gt; to do anything meaningful with them.<br>
&gt; <br>
&gt; So I think the best option is to say:<br>
&gt; <br>
&gt; If the application did not explicitly call a @Remove method before the<br>
&gt; context ends, the container destroys the stateful bean w/o using any<br>
&gt; @Remove method to do it. (The @PreDestroy callback would still occur.)<br>
&gt; <br>
&gt; I'm going to run this by Ken today.<br>
&gt; <br>
&gt; -- <br>
&gt; Gavin King<br>
&gt; gavin.king@gmail.com<br>
&gt; <a href="http://in.relation.to/Bloggers/Gavin">http://in.relation.to/Bloggers/Gavin</a><br>
&gt; <a href="http://hibernate.org">http://hibernate.org</a><br>
&gt; <a href="http://seamframework.org">http://seamframework.org</a><br>
</tt></body></html>