de.caff.gimmix
Class Worker

java.lang.Object
  extended by de.caff.gimmix.Worker
All Implemented Interfaces:
java.lang.Runnable

public abstract class Worker
extends java.lang.Object
implements java.lang.Runnable

A Runnable which knows of exceptions.

 

Constructor Summary
Worker()
          Default constructor.
Worker(KnockOffListener listener)
          Constructor taking an intial knock off listener.
 
Method Summary
 void addKnockOffListener(KnockOffListener listener)
          Add a knock off listener.
protected abstract  void execute()
          Implement this in extending classes to do the work.
 java.lang.Throwable getCatched()
          Get the thrwoable catched during work, if there happened one.
protected  void informKnockOffListeners()
          Call all knockoff listeners.
static void invokeInEventDispatchThread(java.lang.Runnable run)
          Invoke in the AWT thread.
 void removeKnockOffListener(KnockOffListener listener)
          Remove a knock off listener.
 void rethrow()
          This throws the catched exception if there occured one.
 void run()
          When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Worker

public Worker()
Default constructor.


Worker

public Worker(KnockOffListener listener)
Constructor taking an intial knock off listener.

Parameters:
listener - knock off listener
Method Detail

run

public void run()
When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.

The general contract of the method run is that it may take any action whatsoever.

Specified by:
run in interface java.lang.Runnable
See Also:
Thread.run()

execute

protected abstract void execute()
                         throws java.lang.Exception
Implement this in extending classes to do the work.

Throws:
java.lang.Exception - any exception thrown during work

getCatched

public java.lang.Throwable getCatched()
Get the thrwoable catched during work, if there happened one.

Returns:
the throwable or null if there didn't occure any

rethrow

public void rethrow()
             throws java.lang.Throwable
This throws the catched exception if there occured one.

Throws:
java.lang.Throwable - exception catched during execute of work

addKnockOffListener

public void addKnockOffListener(KnockOffListener listener)
Add a knock off listener. The knock off listener will be called in the AWT event thread after the worker has finished.

Parameters:
listener - new listener

removeKnockOffListener

public void removeKnockOffListener(KnockOffListener listener)
Remove a knock off listener.

Parameters:
listener - listener to remove

informKnockOffListeners

protected void informKnockOffListeners()
Call all knockoff listeners.


invokeInEventDispatchThread

public static void invokeInEventDispatchThread(java.lang.Runnable run)
Invoke in the AWT thread.

Parameters:
run - runnable which has to be invoked in the AWT event thread