• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EJB 3.0 statefull session bean life cycle dout

 
Ranch Hand
Posts: 188
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Chap 3 of EJB 3 in action (Debu Panda) page no 99 states (9th point of sfsb life cycle call backs) that

If the client requests the removal of a bean instance, it is first activated if necessary and then destroyed.



Does this imply that in certain situations the postActivate methods will be invoked and then the @Remove method will be called.

If yes then which are the situations in which the container is likely to call postActivate and why ... as i do not see the need to activate a bean just to destroy it !!

Thanks
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i guess the reason would be to call PreDestroy method on the bean instance or on the call back handler....so it needs to activate the bean instance.
 
Ranch Hand
Posts: 329
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sid sree:
Does this imply that in certain situations the postActivate methods will be invoked and then the @Remove method will be called.



Methods annotated with the @Remove annotation are business methods. As per the ejb core specification, the Container must activate a passivated bean before running any business method on that bean. That's why @PostActivate is called before the @Remove method.

A @Remove method is not used exclusively for indicating that the bean can be removed. It may perform all the business logic you want.
[ September 24, 2008: Message edited by: Sergio Tridente ]
 
Sudarshan Sreenivasan
Ranch Hand
Posts: 188
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Extremely well put ... thanks alot
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No Doubt, it was a brilliant explanation but with the clarification of one doubt i have another doubt popped out.

What is we do not have any business method to be called on the Passivated bean. Say we don't have @Remove method. Why don't we distroy the passivated bean there itself. Why to bring it back to life when the motive is killing(In case there is not any Business method to be called).
 
Sergio Tridente
Ranch Hand
Posts: 329
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Juggy Obhi:
What is we do not have any business method to be called on the Passivated bean. Say we don't have @Remove method. Why don't we distroy the passivated bean there itself.



How would you do that? What mechanism other than calling a @Remove method would you use to tell the container that it may destroy your bean's instance?
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A client can destroy a Statefull ONLY calling its @Remove method (or mapped with <remove-method> in DD).

Sergio: Nice explanation about @Remove be a Business method, I didn't know that
 
Well don't expect me to do the dishes! This ad has been cleaned for your convenience:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic