• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

EJBObject reference in stateless ejbCreate() ?

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this 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
reply
    Bookmark Topic Watch Topic
  • New Topic