This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes how stateless session beans handles the clients? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "how stateless session beans handles the clients?" Watch "how stateless session beans handles the clients?" New topic
Author

how stateless session beans handles the clients?

Akshay Kumar
Ranch Hand

Joined: Feb 24, 2004
Posts: 37
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.
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how stateless session beans handles the clients?
 
Similar Threads
Concurrency / pooling with EJB
Access to EJBObject from within ebjCreate of a stateless SessionBean
Question on exercise pg 108 HFE
Why have more than one stateless session bean?
Question regarding Lifecycle of STATELESS session bean.