Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Remove while passivated

 
Magnus Stattin
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What will happen if remove is called on a stateful session bean while it is passivated?
Will ejbActivate and then ejbRemove be called?
Thank you
/Magnus
 
Ken Boyd
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No it won't call ejbActivate to remove stateful bean if it is passivated.
SCJP 1.4
SCWCD
 
Magnus Stattin
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Nehul
AFAIK the container will not call ejbRemove stateful session bean in these cases:
1) a time-out while passivated
2) a system exception in a business method
3) a container crash
a call from remove while passivated will be an additional case. Do you know where in the spec I can find this mentioned.
Thank you
/Magnus
 
Anselm Paulinus
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nehul:
I beg to differ on your response here. I have not seen a link from passivated state to Does Not Exist State using the remove method. I assume that the container will first activate the bean before calling ejbRemove() on it. Can you explain further why you think otherwise or why you think that it wont activate the bean fist before removing it, outside the overhead cost of doing this?
 
Ken Boyd
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read page 213 from Head First EJB.
I am 100% sure it won't call ejbActivate to remove bean if it is in passivation. It will only call ejbActivate if client come back in reasonable time when bean was last passviated.
Container has better things to do compare to call ejbActivate just to remove it. So you better put your clean up code in both ejbPassivate & ejbRemove method.
Hope this will make my point clear.
SCJP1.4
SCWCD
[ January 19, 2004: Message edited by: Nehul Nalekar ]
 
Yi Meng
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose the container will first call ejbActivate then ejbRemove......because the remove call is just something active from client and the container will first activate the bean and make the client call though it's a remove call.
please refer to Kathy's reply in this threadhttp://www.coderanch.com/t/158446/java-EJB-SCBCD/certification/Some-questions
[ January 19, 2004: Message edited by: Yi Meng ]
 
Ken Boyd
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We don't talk about client remove call to container.
We are talking about bean in passivate mode & no call comes from client in reasonable time. In that case no ejbActivation method called.
 
Ken Boyd
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah Kathy mentions it correctly with in depth explanation. She has mentioned every scenario for remove call.
 
Anselm Paulinus
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nehul Nalekar:
We don't talk about client remove call to container.
We are talking about bean in passivate mode & no call comes from client in reasonable time. In that case no ejbActivation method called.

I think Kathy already did a good work of explanation on this issue of remove so we need not argue further on it.
Thanks everyone,
Anselm
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic