This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Lifecycle of a SFSB with respect to activation

 
Mark Garland
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Deepika Joshi
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mark Garland
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Deepika, Promod and Kengkaj,

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

MG
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic