Originally posted by Brian Tinnel: The remove of a Stateless Session Bean acts like a NOP. It doesn't really do anything. Therefore, you can call it as many times as you like and nothing should happen.
So you want to say that if i call business methods on a Stateless Session Bean, after invoking remove() method, it will work?
Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
As Brian mentioned EJBObject#remove() call on a stateless session bean's component interface will not anything or in other words a remove() method will not be invoked on the actual SessionBean. It is up to the container to remove a stateless session bean from the pool.
As you might know a component interface is not linked to a particular instance of a stateless session bean. When a client calls a business method on the comp interface, container gets any bean of this type from the pool and invokes a method (i.e. a method invoked by a client on the comp interface) on it. As soon as the method is completed container returns the method result to the client and places the bean back to the pool.
I thought invoking the create() method for a stateless session bean created an ejbObject for the client on the server, and then when the client invoked a method a bean from the instance pool was 'swapped' into the ejbObject of the client and serviced the request before being placed back into the instance pool?
Then when you invoke remove(), it is the 'ejbObject' which is removed.
I guess you can think of it that way, but it isn't accurate and that could cause some errors in your code because your concept does not match reality. The danger in not knowing how a bean really works is that you might use an instance variable to not realize that when you store data in it, that data is available to any client which happens to get the same bean instance.
So it is important to know that a remove does not really remve anything, and that a create really doesn't create anything (from the standpoint of a Stateless Session Bean).
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop