Java shutdown function on jar unloading -
is there mechanism in java allow me imbue function or runnable something-or-other called if jar is unloaded?
note jvm will, in general, stay up. rules out runtime.addshutdownhook
.
(it's required facilitate hot redeployment web server).
there's nothing in java se, far i'm aware.
but since mention "web server", might looking @ java ee solution. , there's servletcontextlistener
. implement interface , configure implementing class in web.xml
.
for pure java se solution, not bind library-loading class, instance instead. way can have tighter control on when loaded , unloaded.
you use finalize
here, that's 1 of few cases appropriate. have drawback of being non-deterministic (i.e. can't depend on object being finalized when new version being loaded).
Comments
Post a Comment