aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes why is  @Remove not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "why is  @Remove not working" Watch "why is  @Remove not working" New topic
Author

why is @Remove not working

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi ,

Hi ,

I have coded a ejb3 stateless session bean as shown



Please tell me why CallBackMethod() is not getting called called . Do you need to do any configurations ??

Thank you .



Save India From Corruption - Anna Hazare.
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 650
@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
Ranch Hand

Joined: Apr 01, 2009
Posts: 650
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
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thank you for the answer and for the KT with @Remove annotation .
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 650
Ravi Kiran V wrote:Thank you for the answer and for the KT with @Remove annotation .
KT?
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Knowledge Transfer
 
jQuery in Action, 2nd edition
 
subject: why is @Remove not working