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

life cycle and access to beanness

 
Girija Siva
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • 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
 
Suman Sarker
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
It is implied, because getEJBObject and getEJBLocalObject are available from within ejbCreate().
 
Kaarthik Sivashanmugam
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Please refer to the discussion: http://www.coderanch.com/t/159389/java-EJB-SCBCD/certification/calling-getEJBObject-ejbCreate-Stateless-session

It has pointers to the explanation for this behaviour.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic