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
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 A Sarker<br />SCJP, SCWCD, SCBCD<br /> <br />If You Can't Beat Them ... Join Them!
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
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().
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.