*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes EJB Passivation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "EJB Passivation" Watch "EJB Passivation" New topic
Author

EJB Passivation

rania ferrag
Ranch Hand

Joined: Feb 04, 2004
Posts: 88
Hi every one,

Can some one answer the question bellow, and if you can give some details that could be great !

Which of the following properties are saved at the time of EJB Passivation

A-EJBHome reference
B-Transient Variables
C-User Transaction
D-NamingContext
E-EJBObject reference

THanks and Regards,

Rania
Mahesh Desai
Ranch Hand

Joined: Apr 04, 2007
Posts: 76
A, C, D & E are correct answers.

B is incorrect: Passivation (serialization) skips the variables of the bean class which are declared as transient while storing the object on secondary storage.

By the completion of the ejbPassivate() method, all the nontransient fields (which will be saved) of the bean state must be one of the following:

1] A serializable object, that is, its class implements the Serializable interface.
2] Null.
3] A reference to an enterprise bean�s remote component (EJBObject) interface or remote home (EJBHome) interface.
4] A reference to an enterprise bean�s local component(EJBLocalObject) interface or local home (EJBLocalHome) interface.
5] A reference to a SessionContext object.
6] A reference to the bean�s JNDI context (for example, java:comp/env) or any of its subcontexts.
7] A reference to a user transaction interface: javax.transaction.UserTransaction.
8] A reference to a resource manager connection factory, for example, javax.sql.DataSource.
9] A reference to a javax.ejb.Timer object.



Hope this helps,


Thanks,
Mahesh



----------------------
SCJP 1.4 | SCWCD 1.4 | SCBCD 1.3 | SCEA Part I - In Progress
[ May 08, 2007: Message edited by: Mahesh Desai ]
rania ferrag
Ranch Hand

Joined: Feb 04, 2004
Posts: 88
Hi Mahesh !!

Thank you so much for your prompt response, I'll make sure to memorize the case you mentioned above.

My Best Regards

Rania
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
During passivation of entity beans nothing is saved , its only put back to the pool.

In case of stateful session bean , during passivation everything that you have mentioned is saved.The only thing is that it doesnot guarantee the correct values during activation of transient variables.So you should take care of it.


Rahul Bhattacharjee
LinkedIn - Blog
rania ferrag
Ranch Hand

Joined: Feb 04, 2004
Posts: 88
Thanks Rahul for your answer, But I'm confused, I thought that for an entity bean we save the data to the underlying DB before passivating the instance entity bean, the container call ejbStore() before passivating the bean... Can some one clarify this please ?

Also the Transient field are not saved , right ?

If any comment on this and clarification, will be help me ...

Thank you all for your help,

My Regards,
Rania
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Passivation , activation , ejbCreate , ejbRemove have completely different meaning for entity beans and stateful session beans.

I am talking about the objects that you have mentioned in your initial post.During passivation of stateful session beans you need to take care of transient variables during activation as because its not guaranteed that it would be set to default values.
rania ferrag
Ranch Hand

Joined: Feb 04, 2004
Posts: 88
Thank Rahul for your quick reply
You said
During passivation of entity beans nothing is saved , its only put back to the pool.

So only for Stateful sessionbean, where the state are saved ?

Rania
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by rania ferrag:
Thank Rahul for your quick reply
You said
So only for Stateful sessionbean, where the state are saved ?



No , for stateful session beans the objects that you have mentioned in the initial post are taken care by the container , rest of the stuffs you have take care.
 
 
subject: EJB Passivation