Yea, ejbRemove() will be called by the container on bean instance when the client invoke remove() method in the ejbObject of the stateful session bean. This will be called only once in the life cycle of a stateful session bean.
The difference between the two calls is not about time. ejbPassivate() is called by the container only when it is running short on resources(memory). If the server is not low on resources it will not bother to passivate a bean even though the bean has been around for a while. As for the ejbRemove() method, it gets called by the container when a bean has timed out. Timeout is not about how long the bean has been in the 'method ready' state, it is about how long the bean has been left idle. A bean could time out when the bean is in the 'method ready' state or when it has been passivated. If it is in the passivated state, then it gets removed without getting re activated.
Hope this helps.. You may want to refer to pg184 - 185 of HFEJB for more info. Cheers ! [ April 27, 2005: Message edited by: linoops ]
Though both ejbPassivate and ejbRemove are releasing resources they are not same by any means. When passivating the EJB container store/ persists the state of EJB and release resources. But removing is just like assign null into the reference. Meaning of removing passive EJB is removing the stored state of the EJB from the storage. Hope this helps
Joined: Sep 14, 2002
Joined: Oct 03, 2003
A followup question to Kris's post. Since ejbRemove is not called if the bean has been passivated, how can i make sure that something always happens before a bean dies ???
Also, what is typically done in the ejbRemove method?? (Haven't used ejb's much, so real world examples of what you do in the ejbRemove will help).