wood burning stoves*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes What will be safely passivated? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "What will be safely passivated?" Watch "What will be safely passivated?" New topic
Author

What will be safely passivated?

Edmund Yong
Ranch Hand

Joined: Nov 16, 2003
Posts: 164
Page 205 of HFEJB (Sharpen your pencil) asks what will be safely passivated. Is there an answer to this question?

I tried to work out this question, and below are those which I think will NOT be safely passivated:

reference to a java.net.Socket object
a transient variable with a non-null value
a non-trasient, non-Serializable variable with a non-null value

Am I correct?


SCJP 1.2, SCWCD 1.4
B.Sathish
Ranch Hand

Joined: Aug 18, 2005
Posts: 372
Transient variables will be safely passivated whether they are null or non-null. The only thing is when activated, transient variables might not get back their default values.

In fact, in one of the answers to "There are no dumb questions" ,the book advices you to use transient as it would improve passivation efficiency
Sankar Subbiramaniam
Ranch Hand

Joined: Oct 03, 2000
Posts: 116
You can find answers to sharpen your pencils in the following link:
answers for sharpen your pencils partB
Micheal Jacob
Ranch Hand

Joined: Nov 25, 2002
Posts: 89
Hi,

Can we consider passivation as somewhat similar to serialization of objects ?
If yes, i suppose i always studied that transient variables are not serialized.

am i wrong somewhere ?

thanks in advance.

Micheal
B.Sathish
Ranch Hand

Joined: Aug 18, 2005
Posts: 372
same here. If a variable is declared transient, the container won't bother saving it i.e. transient variables as you said will not be serialized and saved. Hence even if a transient variable is non-serializable, it will not cause any problems during serialization and hence the bean can be safely serialized / passivated.
Micheal Jacob
Ranch Hand

Joined: Nov 25, 2002
Posts: 89
Hi,

As u also said,
transient variables are not serialized, so while passivating, container's job will be easy.

But the question says, "find out, which of these will be safely passivated"

In this case, transient variables with non-null value will not be passivated. (though bean will still be passivated. Is this not true ?


Micheal
Edmund Yong
Ranch Hand

Joined: Nov 16, 2003
Posts: 164
"a transient variable with a non-null value" is checked in the answers. However, it says that the value after activation might be weird. So how can this be considered safely passivated?
Micheal Jacob
Ranch Hand

Joined: Nov 25, 2002
Posts: 89
Hello,

"The Bean Provider must assume that the content of transient fields may be lost between the ejbPassivate and ejbActivate notifications"
- page 72, EJB Spec.


Can we say, transient variables are not passivated ?

Micheal
B.Sathish
Ranch Hand

Joined: Aug 18, 2005
Posts: 372
It depends on what you consider the meaning of "safely passivated". What the question actually meant was - which of the following will be passivated without throwing any runtime exception. If you have for example, a java.net.Socket object having a live socket connection and if you try to passivate it without making it null, it will throw an exception while it is passivated - ObjectNotSerializable exception or some other exception like it. But a transient variable can be safely passivated without throwing exceptions right? This is what the question in the book actually meant. I believe the actual exam questions will be clearer
 
jQuery in Action, 2nd edition
 
subject: What will be safely passivated?
 
Similar Threads
sharpen your pencil question - page 205
a question from sun's assessment test.
states of stateful session bean
Passivation confusion
Chapter 4 - HF Sark study group