• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

life cycle and access to beanness

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was trying to make my mind completely clear of all the confusion i had about 'life cycle and access to beanness' and stuck at start with stateless beans
if the create() from client is triggering EJBObject creation how can we have access to getEJBObject() in ejbCreate() which is part of creating the the bean and putting it in the pool
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Girija,
If you take a close look at the interaction diagram in page 227 of HFEJB, you'll see that call to create() method in home object and the correspoing call to ejbCreate() in the bean occurs at a completely different time. You will also find that ejbCreate() method is called when EJBObject is already made available by the container.

Hope the diagram clears your confusion.

Suman
 
Girija Siva
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You will also find that ejbCreate() method is called when EJBObject is already made available by the container.


The timeline of create() on home and ejbCreate() on bean are unrelated is it not.
Per say, the container creates beans and puts them in pool. It calls ejbCreate() as part of the bean creation. At that time there is no client create call on the home.
EJBObject is created as part of the client create() call at a different time.
When is it the EJBObject is associated with the bean???
When ejbCreate() is called there is no client=> no call create() on home=> no creation of EJBObject , how is it EJBObject is available at the time of calling ejbCreate(). What is it I am missing in here
Thanks in advance
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For any type of session bean, the EJBObject is available before ejbCreate(). Why? Because the EJB spec writers made it mandatory! The idea is that the bean provider may need to acquire a reference to the EJBObject from ejbCreate(). So, it's up to the EJB Container provider to somehow implement this.

Note that for entity beans, the EJBObject is not available in ejbCreate() as the PK is not available, but you can get it in the next method call - which is ejbPostCreate().
 
Girija Siva
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Roger Can you plaese refer to the page of the spec that makes this mandetory
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is implied, because getEJBObject and getEJBLocalObject are available from within ejbCreate().
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Girija,
Did you understand the answers provided. I did not. Unaware of this posting, I started another discussion here. I have not got any convincing answer yet. Since you had the same question may be if you have an answer, you can explain that to me.

thanks.
Kaarthik
 
Kaarthik Sivashanmugam
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please refer to the discussion: https://coderanch.com/t/159389/java-EJB-SCBCD/certification/calling-getEJBObject-ejbCreate-Stateless-session

It has pointers to the explanation for this behaviour.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic