This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
@Remove only makes sense for statefull session beans, not stateless. In the case of a stateless session bean, as soon as the call is finished, the bean is placed back in the pool (or destroyed).
However, for a statefull session bean, the bean maintains its conversational state until it times out. The @Remove annotation is how you (the bean designer) can tell the container that the session is over and the bean can be recycled.
I hope this helps,
Mark E Hansen
Joined: Apr 01, 2009
I've had another read of your original question and I think I see there was some confusion.
The @Remove annotation does not indicate that a method is a call-back. It simply says that the statefull session bean should be recycled after this method call finished.
For example, assume you have a statefull session bean with 4 methods: doStep1(), doStep2(), doStep3() and doStep4(). The bean should retain conversational state throughout all the steps. However, after the application calls doStep4(), it is finished with this bean. Using the @Remove annotation, you tell the container to recycle the bean after this method call is finished.
Without the @Remove annotation on that method, the bean would persist (and take up valuable resources) until it times out.
I think what you're looking for, however, is the @PreDestroy annotation. This can be used on any bean (stateless/statefull session and MDB) and annotates a method (public, private, etc.) as a callback for the lifecycle event.
Sorry I went off-track with my first response - my brain was stuck on the @Remove annotation rather than what you were actually asking