aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Lifecycle of a SFSB with respect to activation 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 "Lifecycle of a SFSB with respect to activation" Watch "Lifecycle of a SFSB with respect to activation" New topic
Author

Lifecycle of a SFSB with respect to activation

Mark Garland
Ranch Hand

Joined: Nov 11, 2006
Posts: 226
Hi,

From EJB3 in Action pg99, discussing the lifecycle of a SFSB...

7 If the client invokes a passivated bean, it is activated (brought back into memory from temporary storage).
8 If the client does not invoke a passivated bean instance for a period of time, it is destroyed.
9 If the client requests the removal of a bean instance, it is first activated if necessary and then destroyed.


So, if 7 happens, the bean is first activated - makes sense.
If 8 happens the bean is destroyed. But, is it activated first?
If 9 happens, what does "if necessary" mean?

Thanks,

MG


28/06/06 - SCJP - 69%, 05/06/07 - SCWCD - 92%, 28/02/08 - IBM DB2 v9 Fundamentals (Exam 730) - 87%, 18/11/08 - IBM DB2 v9 DBA (Exam 731) - 89%, 26/02/11 - SCBCD - 88%
Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268
7 If the client invokes a passivated bean, it is activated (brought back into memory from temporary storage).
8 If the client does not invoke a passivated bean instance for a period of time, it is destroyed.
9 If the client requests the removal of a bean instance, it is first activated if necessary and then destroyed.


So, if 7 happens, the bean is first activated - makes sense.
If 8 happens the bean is destroyed. But, is it activated first?
If 9 happens, what does "if necessary" mean?


7. is fine with you.
8. No (compare it with when in your web application session is expire, it invalidate the session)
9. process can remove something which does exist, so it brings back the bean. Second while removing there could be instructions to do (written in you code). (compare it with logout button, it invalidate & could give you good buy message or do more)

I am also new to EJB, but hope this would be helpful.
Promod kumar
Ranch Hand

Joined: Jun 26, 2006
Posts: 90
For 8, I found this in the spec (section 4.4 of the core spec). The way I am interpreting this is that the instance will not be activated in this case, it will be destroyed/removed without first activating. Can someone confirm this. Also the sesion object mentioned in the quote, is it the same as the instance?

While the instance is in the passivated state, the container may remove the session object after
the expiration of a timeout specified by the Deployer. All object references and handles for the
session object become invalid. If a client attempts to invoke a method on the bean’s business
interface, the container will throw the javax.ejb.NoSuchEJBException[16]. If the EJB
2.1 client view is used, the container will throw the java.rmi.NoSuchObjectException
if the client is a remote client, or the javax.ejb.NoSuchObjectLocalException
if the client is a local client.


For 9, if necessary means that if the bean is passivated and remove message is sent, the bean is first activated and then remove message is executed on the bean. If the bean is already active the remove message is executed straight away.
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
Mark Garland wrote:Hi,

From EJB3 in Action pg99, discussing the lifecycle of a SFSB...

7 If the client invokes a passivated bean, it is activated (brought back into memory from temporary storage).
8 If the client does not invoke a passivated bean instance for a period of time, it is destroyed.
9 If the client requests the removal of a bean instance, it is first activated if necessary and then destroyed.


So, if 7 happens, the bean is first activated - makes sense.
If 8 happens the bean is destroyed. But, is it activated first?
If 9 happens, what does "if necessary" mean?

Thanks,

MG

8. No.
9. If a bean is passivated, it will be activated and then destroyed.


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Mark Garland
Ranch Hand

Joined: Nov 11, 2006
Posts: 226
Hi Deepika, Promod and Kengkaj,

Thank you for your responses - that makes a lot more sense.

MG
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Lifecycle of a SFSB with respect to activation