Execute when an application is destroyed/ undeployed
<p>I have a static initialization block where I read data from DB into certain variables, update that data during the lifetime of the application &amp; 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.</p>

<p>How can I implement this with on destroy trigger in Java ?</p>

<hr>

<h1>Edit:</h1>

<p>What about the <code>@PreDestroy</code> annotation, could it be useful for my case ?</p>
