aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Session bean instance variables ready for passivation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Session bean instance variables ready for passivation" Watch "Session bean instance variables ready for passivation" New topic
Author

Session bean instance variables ready for passivation

Fernando Matias Valadao
Greenhorn

Joined: Feb 19, 2003
Posts: 26
Hi, guys!
On page 203 of HFEJB book, you can see that "bean's local component or home interface" are an example of "passivatable" instance variable. That is, it can be either an entity local component interface or a session local component interface.
Unfortunatelly , on page 71 of the spec, you find out that only "entity's local component or home interface" can be serialized.
So according to the spec, isn't a requirement to serialize the references to session local interfaces (component and home)? That's exactly what HFEJB is pointing!
Thanks in advance.


"In the case of a nuclear attack, the protection of our records is essential, if this country is to carry on its economy and maintain our way of life."
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1164
Fernando,

Passivation is used on entity and stateful beans. http://java.sun.com/developer/onlineTraining/EJBIntro/EJBIntro.html explains it well.

entity beans

The ejbPassivate() and ejbActivate() methods are invoked on the bean by the container just before the bean is passivated and just after the bean is activated, respectively. Passivation in entity beans means that the bean instance is disassociated with its remote reference so that the container can evict it from memory or reuse it. It's a resource conservation measure the container employs to reduce the number of instances in memory. A bean might be passivated if it hasn't been used for a while or as a normal operation performed by the container to maximize reuse of resources. Some containers will remove beans from memory, while others will reuse instances for other more active remote references. The ejbPassivate() and ejbActivate() methods provide the bean with a notification when it is about to be passivated (disassociated with the remote reference) or activated (associated with a remote reference).


stateful beans

To conserve resources, stateful session beans may be passivated when they are not in use by the client. Passivation in stateful session beans is different than for entity beans. In stateful beans, passivation means the bean's conversational-state is written to a secondary storage (often disk) and the instance is removed from memory. The client's reference to the bean is not affected by passivation, it remains alive and usable while the bean is passivated. When the client invokes a method on a bean that is passivated, the container will activate the bean by instantiating a new instance and populating its conversational-state with the state written to secondary storage. This passivation/activation process is often accomplished using simple Java serialization but it can be implemented in other proprietary ways as long as the mechanism behaves the same as normal serialization. (One exception to this is that transient fields do not need to be set to their default initial values when a bean is activated.)


So, all the passivation and activation processes are done just on the beans and not on the local/remote/home interfaces.

-- Dan


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Fernando Matias Valadao
Greenhorn

Joined: Feb 19, 2003
Posts: 26
Hi, Dan
Thank you very much for your reply.
I understood your consideration, but what I was arguing about was the instance variables of the bean that is about to be passivated/activated, not the bean itself.
I was asking about the differences between HFEJB and the spec (or maybe there was no difference and I was just
Again: In HFEJB it's written that "bean's local component or home interface are an example of "passivatable" instance variable", while in the spec we can read that "entity's local component or home interface can be serialized".
Hope it became clearer now.
Thanks.

Fernando
Leena Diwan
Ranch Hand

Joined: Jun 18, 2001
Posts: 351
Even I am looking for the answer to this question.

I have copied the statments from spec here -

'The objects that are assigned to the instance�s non-transient fields after the ejbPassivate method completes must be one of the following:

� An "enterprise bean�s" remote interface reference, even if the stub class is not serializable.
� An "enterprise bean�s" remote home interface reference, even if the stub class is not serializable.
� An "entity bean�s" local interface reference, even if it is not serializable.
� An "entity bean�s" local home interface reference, even if it is not serializable.

Why the diff between the first two and the last two?

Regards,
Leena


[SCJP2, SCWCD1.3, SCBCD]
Fernando Matias Valadao
Greenhorn

Joined: Feb 19, 2003
Posts: 26
Hey Kathy / Valentin / Bert:
Don't you have any tips to solve our question?
Thanks in advance

Fernando
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session bean instance variables ready for passivation
 
Similar Threads
Remove methods in component or home interface
MovieBean ejbHomeListAllMovies()
Which Exception is thrown?
[EJB 2.0 Spec] WHERE IS THE TRICK???!!!
EJBLocalHome