The minimal interface that must be implemented by a service component.
Example Java implementation of a service component:
public class MyService { private static boolean _stop; public void run() { while (! _stop) { try { // do whatever this service does on each iteration Thread.sleep(10000); } catch (InterruptedException ie) { _stop = true; } } } public void start() { _stop = false; } public void stop() { _stop = true; } }
Run the service. This operation may run indefinitely,
but if so it should go to sleep at regular intervals
(to avoid tying up system resources) and should check
if stop
has been called (to allow graceful shutdown).
void run ( );
Start the service. This operation must complete in a relatively short amount of time since it is called during server startup.
void start ( );
Stop the service. Possible implementations include setting a flag that the 'run' operation checks for at the start of each iteration of its main loop.
void stop ( );