com.roeschter.jsl
Class SimpleStopper

java.lang.Object
  |
  +--com.roeschter.jsl.SimpleStopper
All Implemented Interfaces:
Stopable

public class SimpleStopper
extends java.lang.Object
implements Stopable

Most simple version of Stopable. Simply call ServiceStopper.stop( new SimpleStopper() );


Constructor Summary
SimpleStopper()
           
 
Method Summary
static void main(java.lang.String[] argv)
           
 void onServiceStop()
          Called when the service is about to stop.
 int timeToWait()
          How long should the ServiceStopper wait (in milliseconds) for the stop thread to die? 0 waits for ever.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleStopper

public SimpleStopper()
Method Detail

onServiceStop

public void onServiceStop()
Description copied from interface: Stopable
Called when the service is about to stop. You can't veto against stopping. All you can do is delay it while you are doing cleanup. Some time after the stop call returns, the JVM will stop with System.exit(0). Any exception thrown will be ignored.

Specified by:
onServiceStop in interface Stopable

timeToWait

public int timeToWait()
Description copied from interface: Stopable
How long should the ServiceStopper wait (in milliseconds) for the stop thread to die? 0 waits for ever. Specify some other value if you want to propose a System.exit() after some timeout. Remark: Is is not guaranteed that the JVM will die after the specefied timeout. There may be other Stopables being less cooperative. If there are other Stopables in the same queue they may or may not be called after the timeout. They are definetely not called if the call to the previous Stopable does not return.

Specified by:
timeToWait in interface Stopable

main

public static void main(java.lang.String[] argv)