This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I am actually kind of confused with the method ejbRemove(). I am wondering when exactly this method is called in case of a stateless session bean.
I would like to know if this method is called when the user call remove on the component interface or if it is called when the instance is killed from the pool. My guess is that is never called when the user call the remove method because the bean returns to the pool after each business call and therefore the client EJBObject never keeps a reference to the bean.
Yes, You are right. ejbRemove() method is never going to be called when the user invoke the remove method in the component interface. ejbRemove() method will be invoked by the container, when it need to reduce the size of the instance pool. So client will have no role in removing the bean instance from the pool. After each business method invocation the bean instance will go back to the pool.
For stateless session beans, the clients do not have control over when the beans are created or destroyed. In the case of ejbCreate, the container will only invoke this method when the client invoke a business method. Likewise, the container decides when to call ejbRemove independently of the client.