• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Entity bean life cycle

 
author
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I'm studying the entity bean life cycle, it's not
very much clear how the bean moves from the
"POOLED" state to the "READY" state.

The official description:

"Pooled state" When an instance is in this state, it has been instantiated by the container but has not yet been associated with an EJB object.

"Ready state" When a bean instance is in this state, it has been associated with an EJB object.


..is not very clear to me. A Bean moves to the "ready" states after the "findXXX" method or after the call to the create()/business method ?

Thanks a lot
Francesco
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Francesco,

Lets see if I can be of any help.

Differentiate the Entity Bean Class object from entity bean itself.
Container precreates the bean objects in memory and keeps in pool. This may happen at startup of container. To do it, container calls constructor and setEntityContext.
At this time the EB class instance, its not a full bean yet.
Since till now there is no client in picture, ther is no ejb object with it.(*)
From (*), if you call create on it, bean is taken from pool , assigned an EJB Object and ejbCreate and ejbPostCreate is called on it...now it has become a bean.
From (*), if you call ejbFind(), the bean does not leave the pooled state, just executes finder, simply because it's not been called with a biz method.

When you already have a ejbObject for a bean which is in pool, its ejbActivate is called to bring it in ready state.

ejbActivate will not be called on a bean when ejbCreate is called.
ejbPassivate will not be called on bean when ejbRemove is called.

Just to catch a point here, container will follow only 1 of 2 mechanisms available to move a bean from poooooooool to ready state and vice versa.

Amol
 
Francesco Marchioni
author
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Amol,
thanks for your reply.
It sounds clear. My doubt was, mainly, if the bean leaves the pool
just after findXXX. As you said it will only leave the pool (and associated) after calling a business method on it.
(or after create() of course)
thanks a lot
Francesco
 
amol deshpande
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are welcome.





 
If you try to please everybody, your progress is limited by the noisiest fool. And this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic