• 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

When all @PreDestroy gets called?

 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

May I list down all the cases where @PreDestroy is guaranteed. Would be greatful if you can correct.

  • The Stateful Session Bean's method was called by a client and is complete. The Bean is idle for some time. It gets passivated and times out of passivation. The @PreDestroy is called.
  • The Stateful Session Bean's method is called and is complete. The @Remove method is called by client. The Bean calls Remove and then the @PreDestroy method.
  • The Stateful Session Bean was used by the Client. Suddenly a System Crash happens. Does the server bother to call the @PreDestroy, when the System itself is undergoing crash?


  • Regards,
    Rajesh
     
    Ranch Hand
    Posts: 856
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    in your 3rd case, it will not bother to call.
     
    Ranch Hand
    Posts: 757
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Rajesh So wrote:
    The Bean is idle for some time. It gets passivated and times out of passivation. The @PreDestroy is called.



    As I know @PreDestroy is not called in this case. It is called, only if the bean is in activated (object) state. If it is in passivated state when timing out, the bean (passivated) will be destroyed without calling @PreDestroy method.
     
    Rajesh So
    Ranch Hand
    Posts: 149
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Do you believe only in case 2 that @PreDestroy is called? Is @Remove, the only route to @PreDestroy?

  • The Stateful Session Bean's method is called and is complete. The @Remove method is called by client. The Bean calls Remove and then the @PreDestroy method.


  • Other than the cases I mentioned, is there any other way to reach @PreDestroy?
     
    Treimin Clark
    Ranch Hand
    Posts: 757
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Rajesh So wrote:
    Other than the cases I mentioned, is there any other way to reach @PreDestroy?



    If the session (bean) is timed-out, while the bean is in active (non-passive) mode.

     
    Rajesh So
    Ranch Hand
    Posts: 149
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    If the session (bean) is timed-out, while the bean is in active (non-passive) mode


    May I know how to simulate this in Glassfish?

    Are all Routes to @PreDestroy are mentioned in this post? Have we left out anything?
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic