permaculture playing cards*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Passivation of SB while in transaction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Passivation of SB while in transaction" Watch "Passivation of SB while in transaction" New topic
Author

Passivation of SB while in transaction

Ankit Doshi
Ranch Hand

Joined: Dec 04, 2002
Posts: 222
Page 70 of the spec says:
A container may only passivate a session bean instance when the instance is not in a transaction.


If I am not mistaking, this applies to session beans with bean managed transaction demarcation only. Because I think in case of CMT the transaction will not remain open before leaving the method - is this correct?
Balaji Anand
Ranch Hand

Joined: Nov 03, 2004
Posts: 146
yes correct
Frederic Esnault
Ranch Hand

Joined: Feb 13, 2006
Posts: 284
Yes you're correct. BMT is a way to allow beans to manage their transactions by themselves, and especially one aspect of the transaction : it's scope. The scope for CMT tx is the method in which it runs, which means from method start to method end. But BMT allows bean to make smaller and (in case of stateful session beans) longer transactions.

So yes, you're correct.

One thing to keep in mind about BMT, and which is not very much tested (but might be in real exam) : BMT beans do not accept tx from outside, they only use tx they initiated. Off topic here, but while I'm thinking about this, I say it .


SCJP 5 - SCWCD 1.4 - SCBCD 1.3 - Certification study documents/resources: http://esnault.frederic.free.fr/certification
Ankit Doshi
Ranch Hand

Joined: Dec 04, 2002
Posts: 222
Good point that one ... Actually I had posted a separate question on this. The question was that - when we say BMT beans do not accept tx from outside - are we talking about the bean scope here or the method scope here? And the reply I got was the bean scope. So I interpret it as a BMT transaction started in one method of the BMT can propogate in the other method of the same BMT bean.
Frederic Esnault
Ranch Hand

Joined: Feb 13, 2006
Posts: 284
Your interpretation is correct
p anish
Ranch Hand

Joined: Feb 26, 2005
Posts: 32
I think this will apply for session bean's with cmt also. For example Bean A's method funA (has tx attribute Required) is invoking funB(has tx attribute Required) in Bean B.Now even after executing funB it's transaction is not yet over.It has to commit or roll back(This depends on funA of Bean A).In this case i think Bean B will not be passivated.

Am i right???
Frederic Esnault
Ranch Hand

Joined: Feb 13, 2006
Posts: 284
No, after funB() method is over, tx only covers bean A; bean B is not in any transaction anymore at this time, so it may be passivated. Bean A will not be passivated until completion of tx, but bean B is not protected, as it didn't initiate tx; it appeared during tx lifetime, that's all.
p anish
Ranch Hand

Joined: Feb 26, 2005
Posts: 32
Thank you Frederic for the replay.
But i still have doubts on it.The scenario can be like this:-
C was A's client, for A c is has initiated the tx and A will not be passivated before C commit's .

For B, A is client who has initiated the transaction and B will not be passivated befor A commit's.B don't know whether the call was from another bean or a java client.

isn't it???.
 
Don't get me started about those stupid light bulbs.
 
subject: Passivation of SB while in transaction