Abstract class for declaring an NT service. A Java implementation of a service must declare the
startService
and stopService
methods. startService
must run the
actual service and must block until the service is ready to terminate. For example it may sit in a loop
servicing requests. stopService
will be called when startService
is expected
to stop blocking and return. The stopService
method should return promptly. Any time
consuming shutdown code should be done asynchronously (for example in the startService
thread) before startService
returns.
For example:
public class MyService extends NTService { boolean running = true; protected void startService () { while (running) { System.beep (); Thread.sleep (1000); } } protected void stopService () { running = false; } private MyService () { super ("MyService"); } public static void main (String[] args) { new MyService ().run (); } }
Type | Name and description |
---|---|
protected def |
NTService(String serviceName) Ensures that the DLL is loaded. |
protected void |
run() Runs the service, registering it with the NT service dispatcher. |
protected void |
startService() This will be called when the service is started and must block until the service completes. |
protected void |
stopService() This will be called when the service is stopped and the startService method must
terminate. |
Runs the service, registering it with the NT service dispatcher. If there is a problem this will
terminate the JVM with the Windows error code. If all is okay, this will never return. All subsequent
processing is done by the allocated StarterThread
and StopperThread
objects
and threads internal to the DLL.
This will be called when the service is started and must block until the service completes.
This will be called when the service is stopped and the startService
method must
terminate.