I have a static initialization block where I read data from DB into certain variables, update that data during the lifetime of the application & save it to DB at regular periodic intervals but when the application is unexpectedly/suddently destroyed/ undeployed I want to write back the current state of the variable back to the DB.
How can I implement this with on destroy trigger in Java ?
Edit:
What about the @PreDestroy
annotation, could it be useful for my case ?