Win a copy of Spark in Action this week in the Open Source Projects 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 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

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

Posts: 11
  • Mark post as helpful
  • send pies
  • 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
  • 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.

I love a good mentalist. And so does this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic