i think i'm clear in stating my doubt. i knew that by concept, stateless session bean allows multiple clients whereas stateful allows one client and expires when the client terminates and so on. but would a stateless session bean handles multiple clients by creating separate instances of it (where each to a client)? else, by other means? so, if both type of beans handles multiple clients simultaneously by creating the separate instances of them, then in what way they differs in handling the clients simultaneously? someone out there spare ur precious time to help me out.thanx.
Stateful session beans (SFSBs) are tied to the client that created them. Every time a client calls home.create(...), a new SFSB instance is created for that client only. The client calls bean.remove() to free it, but the instance is destroyed. No two clients will ever access the same SFSB instance without one client passing a reference/handle to the other client. Stateless session beans (SLSBs), on the other hand, are not tied to any particular client permanently. Instead of creating an instance of the bean to service a particular client, a pool of instances is created by the container -- *not* in response to home.create() -- to service all clients. Calling home.create() merely creates a remote/local stub for the bean, allowing access to the pool, not a single instance. When a client calls a method on the bean, the container chooses an instance from the pool to service that one method call and returns the instance to the pool once the method returns. Calling bean.remove() doesn't affect any bean instances. It can be confusing because SLSB instances can service multiple clients, but do so one method at a time. At any point in time, a single bean instance can be doing work for a single client. Over its lifetime, however, a SLSB instance may end up doing work for multiple clients.
subject: how stateless session beans handles the clients?