Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejbCreate() & ejbActivate()

 
Rahul JG
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given that a bean instance can move from the Pooled state to the Ready state under two circumstances:
1) via creation
2) via activation
how does the container decide whether to "create" the bean or to "activate" the bean. In other words how does the
container decide whether to call ejbCreate() or ejbActivate() on the Pooled bean instance.
 
Sudhir V
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create if you are calling create method on the home interface i.e. when you are inserting a new entity.
Activate is when you invoke a business method on the component interface of an existing entity.
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And from a lifecycle standpoint, ejbCreate will *only* be called as a result of a client calling create to generate a new entity. The container doesn't get to decide when it happens - it is purely a client-driven response.
ejbActivate happens whenever the container decides to allocate an instance to represent a specific entity (hence the assorted HFE photos & cartoons in chapters 5/6 about actors). That could happen during a find (ejbFind) operation, or as Sudhir already mentioned, during the processing of a business method provided via the component interface. It could also happen during a remove (ejbRemove), because the entity data must be loaded into the instance before the removal can be processed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic