com.asdf.test
Class ServerRunner

java.lang.Object
  extended by com.asdf.test.ServerRunner
All Implemented Interfaces:
java.lang.Runnable

public class ServerRunner
extends java.lang.Object
implements java.lang.Runnable

ServerRunner Executes server component in it's own thread as long as necessary and handles stopping it when necessary.


Constructor Summary
ServerRunner(Callback handler)
           
 
Method Summary
 void run()
          Run event loop continuously until stop() is called.
static ServerRunner start(Callback handler)
          Initialize ServerRunner and thread for it.
 void stop()
          Stop running event loop.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerRunner

public ServerRunner(Callback handler)
Method Detail

start

public static ServerRunner start(Callback handler)
Initialize ServerRunner and thread for it. Then keep running event loop in run() method until stop() is called or execution has occurred.

Returns:
ServerRunner instance

run

public void run()
Run event loop continuously until stop() is called. Occurring exceptions are stored silently in exception member and can be later retrieved for inspection.

Specified by:
run in interface java.lang.Runnable

stop

public void stop()
          throws java.lang.Exception
Stop running event loop. Running stops on next cycle and function returns after thread has been resumed. If thread doesn't resume in FREEZE_THRESHOLD seconds it's considered an error. Thread is then interrupted.

Throws:
java.lang.Exception