aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes ejbPassivate and ejbRemove for SFSB 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 "ejbPassivate and ejbRemove for SFSB" Watch "ejbPassivate and ejbRemove for SFSB" New topic
Author

ejbPassivate and ejbRemove for SFSB

Sany Bel
Ranch Hand

Joined: Mar 12, 2004
Posts: 51
What happens when a user calls remove on a passivated session bean?
1) Container treats it as any other business method and calls ejbActivate and then ejbRemove.
2) Container will kill the bean without calling ejbActivate.
I personally think 1 is correct. But I wanted to confirm that.


--------------<br />Sany Bel<br />SCJP 1.4, SCBCD
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
No, 2 is correct because it is pointless for the container to activate a stateful session bean and then destroy it. It will go straight from the "passivated" state to the "does not exist" state without ever getting an ejbRemove() call. As ejbRemove() may never be called, it makes sense to replicate your code (cleanup, finalization, etc) in both ejbPassivate() and ejbRemove().
It's also worth bearing in mind that ejbPassivate() may also never be called. This means that none of your cleanup code may ever get called, so you will need do your cleanup at intervals in case ejbPassivate() or ejbRemove() were never called.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Seema Manivannan
Ranch Hand

Joined: Sep 20, 2001
Posts: 128
This has been answered in detail by Kathy in the following post
http://www.coderanch.com/t/158446/java-EJB-SCBCD/certification/Some-questions
Thanks


Seema Manivannan<br />Author and Trainer: Java Certifications<br /> <br />Whizlabs Software<br />Success, certified!<br />Global leader: J2EE certification exam preparation!<br /><a href="http://www.whizlabs.com" target="_blank" rel="nofollow">http://www.whizlabs.com</a><br /> <br />An ISO 9001-2000 certified company!
Santosh Ramachandrula
Ranch Hand

Joined: Apr 04, 2004
Posts: 252
This has been answered in detail by Kathy in the following post
http://www.coderanch.com/t/158446/java-EJB-SCBCD/certification/Some-questions

I read the article posted by Kathy Siera as directed by Seema but I don't think that there is a direct answer to what Sany Bel has asked.
With respect to Sany's question is the answer option number 1 or 2? and also why?
Thanks,
Santosh


Thanks,
Santosh
Seema Manivannan
Ranch Hand

Joined: Sep 20, 2001
Posts: 128
hello,
Option 1 is correct.
Kathy says in the given post:
for stateFUL session beans, the container will treat a remove() method as a business method, and "wake up" the bean to invoke the ejbRemove() method (so ejbActivate() will be called first).
Thanks
[ April 09, 2004: Message edited by: seema manivannan ]
Sany Bel
Ranch Hand

Joined: Mar 12, 2004
Posts: 51
Thanks a lot Seema!!
Santosh Ramachandrula
Ranch Hand

Joined: Apr 04, 2004
Posts: 252
Thanks Seema!!
I got it..

Santosh
 
Don't get me started about those stupid light bulbs.
 
subject: ejbPassivate and ejbRemove for SFSB
 
Similar Threads
Need Clarification-REgarding Sharpen your Pencil
ejbRemove() doesn't call ejbPassivate() ? - HFE p371 question #16
ejbRemove on Session and Entity
calling remove() on passivated SSBean
Session Bean Stateful life cycle