Re: Using JNI to determine whether an object implements an
interface
On Sun, 21 Nov 2010, Steve Sobol wrote:
On Sun, 21 Nov 2010 12:23:53 +0000 (UTC)
Martin Gregorie <martin@address-in-sig.invalid> wrote:
Your launcher looks like a good alternative way to handle the essentials
of service management. So, questions:
- how would a service handle state queries and management commands apart
from stop/pause/resume?
That's up to the app developer. I only care about requests from the OS's
service infrastructure. On Windows, that'll be the Service Control
Manager. On Linux, it'll be the initscript in /etc/init.d.
Out of interest, how does Windows send these requests to services? I know
nothing about Windows's APIs.
Also, how are you thinking of doing it on unix? I infer you'll have an
init script which takes the usual verbs 'start', 'stop', 'restart' and
your 'pause' and 'resume', but how will you get from the script to the
runner program? AFAIK, there is no standard mechanism for such things
(although perhaps it's most often signals?), although of course there is a
plethora of options.
Don't take these questions as a knock: I'm genuinely curious about how
this can be done portably and why it is preferable to using a socket
connection.
These are excellent questions, but I think we're talking apples and
oranges here. My app is not meant to be a general-purpose management
tool.
I think what Martin was wondering is why this approach is better than
using a conventional launcher (plain old java or, on Windows, an existing
service wrapper tool), and writing your app so that it can be managed via
a socket (or perhaps RMI, JMX, or some other means). I can see that one
answer is convenience - with your system, to be stoppable, a service just
has to implement the stop method in your interface, whereas if you're
using a socket, you have to write the code to accept connections, decode
commands, and so on.
Incidentally, another existing tool which hasn't been mentioned so far
(that i've seen) is Apache Commons Daemon (apologies if this URL is wrong,
it's copied by hand from my phone, because my network is semi-down):
http://commons.apache.org/daemon/
It only does start/stop commands, but it has some other features too.
tom
--
SAWING CHASING CRUNCHING ROBOTIC DEMOLITION