• 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

spring shut down hook

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

I have standalone application , using spring ioc in that app.
This app is executed using command prompt. When user press ctrl+c or close the command prompt, I have to add shutdown hook.
So that i can call my customised bean method.
Is it possible to achieve this functionality using spring 2.0.

while searching I got following method which is called as
context.registerShutdownHook()

but how method mentioned above will call my method.

I've to use spring 2.0 only.

Thanks
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes this functionality was there in spring 2.

After creating your context you would immediately register your shutdown hook like you mentioned in your previous post. I think the part you are missing is using the spring life cycle events. What you want to do is on the bean definition that needs clean up define a destroy method using the 'destroy-method=' attribute. This method will be called when that bean is destoyed during the shutdown process which is initiated bythe shutdown hook you registered when the user ctrl-c to terminate the app.
 
reply
    Bookmark Topic Watch Topic
  • New Topic