Actually, when a client invokes a method on a stateless session object, the container takes one session bean out of the pool and invokes the method on it. When the call returns, the container might put the instance back in the pool or use it for servicing other incoming calls. The bottom line is that at any time, only one client is executing a method of given session bean instance. So, yes, multiple clients may have a reference to "the same" stateless session bean, but due to the nature of stateless session bean, you have no idea how the container decides to manage those reference, and thus, you have no idea whether the references the client has all point to the same stateless session bean. Actually, you don't even have to care about the instance that is executing your calls since the beans are stateless, and thus, they all do the same job... Does this make sense to you?
Even EJB spec doesn't recommend to create instance variable in the statless bean. So it must depends on input parameter.
Best Regards<br />N.Shankar<br />SCJP, SCWCD
Joined: Aug 26, 2001
Stateless session beans may declare instance variables, of course. The only requirement is that those variables should not be used to store client-specific data since they are supposed to be stateless... Examples of instance variables are database connections, etc... [ June 30, 2004: Message edited by: Valentin Crettaz ]