[jboss-user] [EJB 3.0] - Predestroy!
do-not-reply at jboss.com
Tue Feb 13 05:15:01 EST 2007
I have been thinking about starting a topic on "When should the PreDestroy callback called?" for some time.
I have been developing EJBs over two years and also as I closely observed the evolution of the EJB3 code base in Jboss at the source level. Not to mention EJB3 spec pdf is on my desktop ;-)
I have some local resources in one of my projects that must be definitely released on EJBs' destroy.
Looking at SimpleStatefulCache, I see that a in 5 minutes (by default) SFSB is passivated and it stays "forever" on the disk.
Spec is not clear enough about from then on what to do. It does state that after some extended time, the container should remove the handles, references etc., and annotates the PreDestroy callbacks next to the remove driven and timeout driven transitions to "does not exist" state. However in further explanation in the text, clearly says that preDestroy is called on remove method invocation but ignores the issue in timeout driven cases. (Ref Spec, P76, pragraph starts as "While the instance is in the passivated state, the...")
So Jboss EJB implementation is correct in that way. However, I strongly think the spec is unclear in this scenario. Resources allocated in PostConstruct, init and throughout the beans usage, MUST be released. Therefore preDestroy must be guaranteed to be called.
This might even be extended to undeployment of the container.
Therefore, I would like to ask the opinions of the people whether I am right on:
- A second pool of passivated beans required.
- After some designated time passivated beans must be destroy forever.
- Before the point above preDestroy method(s) must be called.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4015695#4015695
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4015695
More information about the jboss-user