Running a background thread and shutting down when undeployed
My app needs to do continuous processing in a background thread, ideally created when the application is deployed to the server (but my previous posting about how to create an object on deployment didn't get any answers). I've settled for lazily creating the thread the first time the app is used, but my problem now is that I don't know how to get notified when my app is undeployed - that means that I don't get a chance to shut down the threads I'm running (one of which is holding a port open), which in turn means that i can't redeploy - i have to shut down the whole server and start it up to get rid of my app.
Surely there's a way around this ?
Is there no way to register for a callback when my app is going to be undeployed ?