David
The Apache Commons Daemon library provides a native wrapper that
handles all the boilerplate unix-style daemon things (e.g. a pid-file,
the ability to start/stop/restart), wraps SIGnals, and provides the
java application with early-warning that the process is being shut
down (see http://commons.apache.org/daemon/index.html).
I have two requirements:
- I would like to perform some cleanup in my
"hey-the-jvm-is-shutting-down" handler, and I need to make sure the
Service is no longer processing messages when that happens.
- I want the service to automatically restart itself if it dies for any reason.
The Daemon library provides these features.
In general the ability to notify the Service that it should terminate,
from within the same JVM, might be a useful feature. Let me know if
you're interested in the patch (it's small!).
.. Shlomo