Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

EJBObject reference in stateless ejbCreate() ?

 
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?
 
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.
 
Ranch Hand
Posts: 211
  • 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.
 
There's a hole in the bucket, dear Liza, dear Liza, a hole in the bucket, dear liza, a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic