permaculture playing cards*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes When an EJBObject is created Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "When an EJBObject is created" Watch "When an EJBObject is created" New topic
Author

When an EJBObject is created

Konda Balabbigari
Ranch Hand

Joined: Jan 02, 2001
Posts: 35
Friends
When the EJBObject is created and bean is assigned to an EJBObject in the Entity bean life cycle.
Ex:
before ejbCreate() method starts executing
OR
after ejbCreate method complete
herve attia
Ranch Hand

Joined: Sep 28, 2001
Posts: 138

In CMP entity bean, container creates first a bean instance, calls setEntityContext,
calls ejbCreate() on the bean instance and update the database, creates an EJBObject, assign the bean instance to the EJBObject, and call ejbPostCreate()
Konda Balabbigari
Ranch Hand

Joined: Jan 02, 2001
Posts: 35
herve
Which is true, even i thought the same thing. But in the page number 213 of Richard Monson in the topic "Transitioning from the Pooled state to the Ready State via creation" it states that first EJB object must be created and then bean instance is taken from the instance pool and assigned it to EJB object. Next the ejbCreate() method is executed.
Is this same thing or different for my question.
Thanks herve
Konda...
Iyengar Srividya76
Ranch Hand

Joined: Sep 09, 2001
Posts: 87
Hi...
even I was confused about the same thing bout what Konda said but
my stand on this point is that the lifecycle specified by Herve,
container creates first a bean instance, calls setEntityContext,
calls ejbCreate() on the bean instance......
is basically the transition from 'Does Not exist state' to 'Pooled state'
and what Konda says is transition from 'Pooled state' to 'Ready state' when the bean instance is already created....
Thanx,
Vidya
herve attia
Ranch Hand

Joined: Sep 28, 2001
Posts: 138

An ejbCreate(), ejbPostCreate() callbacks methods are only called once in the bean's life cycle !!! my answer was referring to these point because you mentioned these callbacks methods.
A EJBbean (entity and stateful session) can go back and forth between the ready state and pooled state (activation/passivation).
The client is not aware about these mechanism . The container uses the ejbPassivate(), ejbActivate(),( + ejbLoad(), ejbStore() if entity bean only ) to synchronise the bean fields.
The client is still referring the same EJBObject after the EJBBean has been passivated !!! it is why container, during activation, takes a EJB Bean from the pool and assigns it to the EJBObject.

ruilin yang
Ranch Hand

Joined: Feb 25, 2001
Posts: 334
According to people who took the part-1 exam, it is very important to understand EJB life cycle. The following two problems which posted by Srividya may be worth discussing again.
8.A reference to an EJB can be stored by a client for later use by:
a) serializing the EJBObject to disk
b) Adding the object to the server's pooled objects
c) implementing a find for the bean
d) storing the Handle of the EJB for the bean object
10.A developer successfully creating and tests a stateful bean following deployment, intermittent
"NullpointerException" begin to occur, particularly when the server is hardly loaded. What most likely
to related problem.
a) setSessionContext
b) ejbCreate
c) ejbPassivate
d) beforeCompletion
e) ejbLoad
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: When an EJBObject is created