Lalit mishra wrote:Hi all,
How do we call the @remove method from ejb client. A code snippet would be a great help.
We will call any method of Statefull session bean in the normal way (like POJO) The only thing is, method is marked with @Remove annotation in order to indicate the container that workflow ends after calling this method. Once method with @Remove executes the container will remove the Stateful bean instance.
Hope you understood.
Sai Surya, SCJP 5.0, SCWCD 5.0, IBM 833 834
http://sai-surya-talk.blogspot.com, I believe in Murphy's law.
We can't directly call the @Remove annotation from EJB client .we have to call the @Remove tagged business method from the client.
The @Remove annotation is used with a method to inform the container that the client no longer needs a session and that the session should be destroyed. This annotation is important, as it is the only way to request the container that the session should end. If the remove method is not used, the session will have to be timed out before it can be destroyed by itself. If stateful session bean instances are not removed when they are no longer needed, the number of inactive instances will keep on incrementing and will waste memory and CPU cycles. The syntax for declaring a method with the @Remove annotation is as follows:
As far as I know this measure makes the bean eligible for garbage collector, this does not means that the bean is also "garbeged" on the moment.
In most of the times the profilers have some ways to force the cg to occurs - but this is to profiler specific.
SCJP, SCJD, SCWCD, OCPJBCD
Joined: Aug 25, 2009
Thanks for the reply.
I did use the force GC option on Profiler but it still doesnt cleanup the bean.
Joined: Aug 25, 2009
In fact I tried creating so many instances of the EJBs and everytime calling the @Remove method. Hundreds of instances were created and the server went OutOfMemory finally. But still the EJBs were hanging around.
For @remove see comments above of SampathKumar chinnadurai for @Destroy : Specifies that the method should be called when the context ends and its context variables are destroyed. Note that create methods are only supported for JavaBeans and stateful session beans.
Note that all stateful session bean components must define a method annotated @Destroy @Remove in order to guarantee destruction of the stateful bean when a context ends.
Destroy methods should be used only for cleanup. Seam catches, logs and swallows any exception that propagates out of a destroy method. Looks to me that either container removes bean or by @remove on method both calls destroy for cleanup.
That's depends what are you doing.
I tend to answer no to this question.
The @Remove cleans marks the ends of a stateful bean.
The @Destroy is jBoss/seam specific and it represents the finalisation for a seam component. More precisely before the seam component (which is a bean) pull out from the context this method is call.
Taking beside Seam: in EJB you should differentiate between the concept of a @Remove annotated method of stateful session bean, which will be called by the client, and the concept of a @PreDestroy annotated method, a lifecycle callback method called by the container. I think the Destroy method of Seam resembles the PreDestroy in EJB.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Stateful session bean calling @remove method from client