Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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 ...
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Stateful Session Bean - Implementation of a pool by the EJB Container ?

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

A recent interview question has left me baffled a bit on the 'pooling' implementation for session beans by EJB Containers.

It all started with the usual question of 'Difference between stateless and stateful session beans'.

When going through every difference deeper, he took a little more time in 'squeezing' me about the pooling.

This was his exact question:

'With EJB 3, you do not have to implement any ejbCreate(Parameters) method to create unique stateful session bean for every client. Your bean class is a POJO.

Therefore, is it possible that stateful session beans can also be 'pooled' initially and when client invokes a method, a bean is taken from the pool and attached to the client requested. When passivation happens, the state of the bean is stored physically and the bean is shred of its state and sent back to the pool. During activation, a bean is picked from the pool and 'decorated' with the stored state. '

This might be a trick question even, but unfortunately, I have fallen for it :-)

My doubt is 'Is it possible to have an implementation of a Stateful session bean lifecycle as mentioned above ?'

Thanks a lot :-)

Ranch Hand
Posts: 198
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The container is responsible for creation of bean instances and pool.
As a developer we do not have control on that. Only we can specify the pool size in case of stateless session beans.

So, I think the theory explained above is will not work.

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic