Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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

EJBObject reference in stateless ejbCreate() ?

 
siva raju
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can a stateless session bean get a reference to the EJB Object in the ejbCreate().
Its clearly mentioned in HFEJB that the bean creation(setSessionContext + ejbCreate) occur at a completely different/unrelated time from the client called Home.create() when the EJBObject is created.
What am I missing?
 
Daniel Rhoades
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The EJBObject is created when the client requests the bean, but the EJBObject just points to a bean in the pool.

When the Bean finishes its work it goes back to the pool, the EJBObject is still there if the client needs it, but it may grab a different bean from the pool for the next request
 
siva raju
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still confused. Let me rephrase a bit. The container calls the stateless session bean ejbCreate() just prior to putting it in the pool.

Container adds a bean to the pool
bean.newInstance()-> bean.setSessionContext() -> bean.ejbCreate()

The EJBObject is created in direct relation to the client calling a Home.create() which generally occurs much later.

Client invoked create
EJBHome.create() -> EJBObject.newInstance()

So, how can the bean instance access the SessionContext.getEJBObject() from the ejbCreate() when there is no EJBObject associated?
Thx in advance.
 
Keerthi P
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its clearly mentioned in HFEJB that the bean creation(setSessionContext + ejbCreate) occur at a completely different/unrelated time from the client called Home.create() when the EJBObject is created.


I'm not sure what HF EJB mentions about the above quote. But according to the spec, it is the container's responsibility to make sure that the EJBObject is made available in the ejbCreate() of a bean instance. So the only possibility is that the EJBObject should have been instantiated by the container before ejbCreate() is called.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic