com.roeschter.jsl
Class ServiceStopper

java.lang.Object
  extended by java.lang.Thread
      extended by com.roeschter.jsl.ServiceStopper
All Implemented Interfaces:
java.lang.Runnable

public class ServiceStopper
extends java.lang.Thread

Responsible for listening on a port for the service stop signal by the jsl process. Default port is 8375.
If you are running the your application from java command line (not through the jsl.exe) simply use java ServiceStopper. The listener Thread will be started as a daemon Thread.


Nested Class Summary
(package private)  class ServiceStopper.Stopper
           
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static int PORT
          Port for stopping the application.
(package private) static ServiceStopper singleton
           
protected  ServiceStopper.Stopper stopper
          The queue that a single stop thread will stop
protected  java.util.ArrayList stoppers
          List of Stopable queues the singleton will stop on signal
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
private ServiceStopper()
           
private ServiceStopper(ServiceStopper.Stopper stopper)
           
 
Method Summary
protected  boolean _stop(Stopable stopable)
           
protected  boolean _stopAfter(Stopable stopAfter, Stopable stopable)
           
protected  ServiceStopper.Stopper find(Stopable stopAfter)
           
private static ServiceStopper get()
           
static void main(java.lang.String[] arg)
          Stop the service on the default port.
 void run()
           
static boolean stop(Stopable stopable)
          Stop the stopable on exit.
static boolean stopAfter(Stopable stopAfter, Stopable stopable)
          Stop the stopable on exit.
protected  void stopAll()
           
protected  void stopSingle()
           
protected  int timeToWait()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

singleton

static ServiceStopper singleton

PORT

public static int PORT
Port for stopping the application. Default is 8375


stoppers

protected java.util.ArrayList stoppers
List of Stopable queues the singleton will stop on signal


stopper

protected ServiceStopper.Stopper stopper
The queue that a single stop thread will stop

Constructor Detail

ServiceStopper

private ServiceStopper()

ServiceStopper

private ServiceStopper(ServiceStopper.Stopper stopper)
Method Detail

get

private static ServiceStopper get()

stop

public static boolean stop(Stopable stopable)
Stop the stopable on exit. Remark that a Stopable passed here will be stopped asychronously. In other words, each Stopable will be called in it's own thread concurrently.


stopAfter

public static boolean stopAfter(Stopable stopAfter,
                                Stopable stopable)
Stop the stopable on exit. Remark that a Stopable passed here will be stopped synchronized with stopAfter. In other words, you can create a queue of stopables which will be called one after the other all synchronized in the same thread.


_stop

protected boolean _stop(Stopable stopable)

_stopAfter

protected boolean _stopAfter(Stopable stopAfter,
                             Stopable stopable)

find

protected ServiceStopper.Stopper find(Stopable stopAfter)

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

stopAll

protected void stopAll()

timeToWait

protected int timeToWait()

stopSingle

protected void stopSingle()

main

public static void main(java.lang.String[] arg)
Stop the service on the default port. This is useful for debugging purposes when running the java app from command line. A simple java ServiceStopper [port] will stop the application.