• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

EJB Pool

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Just curious to know why do we need to pool stateless session Bean.
Can't they be implemented like servlet only one instance per EJB getting request from multiple clients?

Thanks
Gagan
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The EJB spec mandates that the access to EJBs be thread safe. This means that multiple clients cannot be accessing the same instance of the stateless bean at the same time. One way to achieve this goal is to have a single instance of the bean and "wait" till each of the client completes the access to the bean before letting the next client in. This obviously isn't practical for real applications. That's where the pool comes into picture. A certain number of bean instances will be available in the pool and whenever a client wants access to the bean, an instance can be allocated from that pool. This way multiple clients will work on different instances of the stateless bean at the same time.
 
Gagandeep-Aryan Malhotra
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But for what reasons the specs mandates stateless session bean to be thread safe. For entity and Statefull this make sense. Stateless session bean will not have any instance variable. So the same instance can service multiple clients.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gagandeep-Aryan Malhotra wrote:For entity and Statefull this make sense. Stateless session bean will not have any instance variable. So the same instance can service multiple clients.



Stateless bean can have instance variables (for example you can have fields within a stateless bean which can have injected values). However the clients or the bean methods themselves aren't expected to assume that the values changed in one business method invocation will be available during another business method invocation of the same bean.
 
Gagandeep-Aryan Malhotra
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for clearing doubt. It was of great help.

Can you please elaborate more on "injecting values".

Thanks in advance.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gagandeep-Aryan Malhotra wrote:

Can you please elaborate more on "injecting values".


Java EE5 and EJB3, support dependency injection. But anyway, that was just an example to help explain that the bean can hold state.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic