• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

how stateless session beans handles the clients?

Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
My cellmate was this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic