aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Stateful session bean passivation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Stateful session bean passivation" Watch "Stateful session bean passivation" New topic
Author

Stateful session bean passivation

Ravi Bansal
Ranch Hand

Joined: Aug 18, 2008
Posts: 86
EJB 3.x Specs Chapter 4, section 4.2
A Container may only passivate a stateful session bean instance when the instance is not in a transaction


Can anyone elaborate on this little bit more ?
Generally session bean invocation takes place in transaction context and I thought whether to do the passivation or not will be determined by container on the basis of max-cache-size of beans or idle time out period .


SCJP 5.0 94%
OCE-EJBD 90%
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1717
    
  25

Hi Ravi,

Can anyone elaborate on this little bit more ?

This just means that passivation should only been done when the session bean is idle (that is: not involved a transaction)

Generally session bean invocation takes place in transaction context and I thought whether to do the passivation or not will be determined by container on the basis of max-cache-size of beans or idle time out period .

How and when to use passivation is not prescribed in the specs, and therefore up to the container developers

This is what the specs say about it:
EJB spec 4.2 "To efficiently manage the size of its working set, a session bean container may need to temporarily transfer the state of an idle stateful session bean instance to some form of secondary storage. The transfer from the working set to secondary storage is called instance passivation. The transfer back is called activation. "


Regards,
Frits
Ravi Bansal
Ranch Hand

Joined: Aug 18, 2008
Posts: 86
Thanks for the Reply Frits.

I agree when you say how and when passivation should be done , is upto container implementation. I should have been more specific about weblogic when I mentioned about idle-time-out and max-cache-size.

But going back to original question of Session bean will not be passivated if its in transaction.

In case my Java EE client (say another EJB having some transaction context) is calling a stateful session bean multiple methods . that means across the different method calls of stateful , it will never be passivated.
Do you agree?

Say if i have Something like below in my client program calling stateful session bean methods method1(), method2(), method3() and each of the methods in stateful session bean having transaction attribute as SUPPORTS OR REQUIRED



Begin transaciton
look up JNDI and get the bean reference
call method1()
call method2()
call method3()
End transaction.


So in above between any of the method calls (say between method1() and method2() invocations ) , Stateful Session bean will never be passivated as they will be running in transaction context of caller EJB.
Am i right ?

Thanks in Advance


Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1717
    
  25

In case my Java EE client (say another EJB having some transaction context) is calling a stateful session bean multiple methods . that means across the different method calls of stateful , it will never be passivated.
Do you agree?

Yes, that is correct

So in above between any of the method calls (say between method1() and method2() invocations ) , Stateful Session bean will never be passivated as they will be running in transaction context of caller EJB. Am i right ?

Yes! the Stateful Session Bean (SSB) is registered in the transactional context of the client, so the containers knows it is busy and that it should not passivate the SSB.

Regards,
Frits
Ravi Bansal
Ranch Hand

Joined: Aug 18, 2008
Posts: 86
Thanks alot for quick response Frits.
 
 
subject: Stateful session bean passivation