Hi all, if client call remove() in home interface, will container call ejbRemove() in session bean? From HF EJB, ebjRemove should be called by container. Please advise.. thanks.
SCJP, SCJD, SCWCD, SCBCD, SCEA, SCJP6
To be obtained: SCEA 5
in session bean it depends on if it is stateful or stateless. 1. stateful... it will call the remove 2. stateless... it will not call. The container is responsible for creation and removal.
if u look at the state diagram for the beans you will know if it is the result of the clients action or the container does it.
George, you will get RemoveException if you call remove() method forcefully. if your client is remote, then Container converts that RemoveException to RemoteException and throws it to the client.
i am not sure if i will get an exception for calling a remove on a stateless session bean. all i could say is... i have called it in my session beans trial.. nothing will happen. the container will not actually bother abt the call it will neither give any exception nor call ejbRemove(). i dont have the HFEJB with me now but it is mentioned in that book in the session beans chapter. can someone clarify about the exception... anyways how do i force a remove() call to a session bean in the first place?
You will not get an exception for calling remove() on the EJBObject of a stateless bean. (spec p88) You are telling the container you are done with it but it is up to the container when it wants to destroy the bean (ejbRemove()). Instead, calling remove() will destroy the reference to the component interface. Any client that tries to use that same reference will get a NoSuchObject(Local)Exception.
I think when remove is called on a stateless session bean, the bean goes back to the pool created by the container. Now its upto the container to decide. if the container thinks that it is running low on resources, it might decide to reduce the pool size by removing the beans from the pool during which it will call ejbRemove() method for the corresponding bean instance.
Listen. That's my theme music. That's how I know I'm a super hero. That, and this tiny ad told me:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!