• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

What will be safely passivated?

 
Ranch Hand
Posts: 242
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can find answers to sharpen your pencils in the following link:
answers for sharpen your pencils partB
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 372
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 242
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 372
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic