Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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 ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

ejbCreate() & ejbActivate()

 
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.
 
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.
 
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.
 
If you send is by car it's a shipment, but if by ship it's cargo. This tiny ad told me:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic