com.jgoodies.uif.util
Class SafeWorker<T,V>

java.lang.Object
  extended by org.jdesktop.swingworker.SwingWorker<T,V>
      extended by com.jgoodies.uif.util.SafeWorker<T,V>
Type Parameters:
T - the result type returned by this SwingWorker's doInBackground and get methods
V - the type used for carrying out intermediate results by this SwingWorker's publish and process methods
All Implemented Interfaces:
Runnable, Future<T>

public abstract class SafeWorker<T,V>
extends org.jdesktop.swingworker.SwingWorker<T,V>

Adds behavior to its superclass SwingWorker to properly handle exceptions thrown during the background execution.

Version:
$Revision: 1.5 $
Author:
Karsten Lentzsch

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jdesktop.swingworker.SwingWorker
org.jdesktop.swingworker.SwingWorker.StateValue
 
Constructor Summary
SafeWorker()
           
 
Method Summary
protected  void cancelled()
          Called when this worker has been canceled by means of SwingWorker.cancel(boolean) method.
protected  void done()
           
protected  void failed(Throwable throwable)
          Called when a background execution of a worker throws an exception.
protected  void finished()
          Called as the last operation when a task is done.
protected  void interrupted(InterruptedException e)
          Called when a worker background execution has been interrupted.
protected  void succeeded(T result)
          Called when the background operation has been successfully executed.
 
Methods inherited from class org.jdesktop.swingworker.SwingWorker
addPropertyChangeListener, cancel, doInBackground, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, process, publish, removePropertyChangeListener, run, setProgress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SafeWorker

public SafeWorker()
Method Detail

done

protected final void done()
Overrides:
done in class org.jdesktop.swingworker.SwingWorker<T,V>

succeeded

protected void succeeded(T result)
Called when the background operation has been successfully executed. In other words, it hasn't been canceled, is not interrupted and has not thrown an exception during the execution.

Parameters:
result - the result of the worker execution as returned by SwingWorker.get(); may be null.

cancelled

protected void cancelled()
Called when this worker has been canceled by means of SwingWorker.cancel(boolean) method.


failed

protected void failed(Throwable throwable)
Called when a background execution of a worker throws an exception. This default implementation throws Errors immediately, and hands over exceptions to Application#handleException.

Parameters:
throwable - the exception thrown during the background execution

interrupted

protected void interrupted(InterruptedException e)
Called when a worker background execution has been interrupted.


finished

protected void finished()
Called as the last operation when a task is done. This method is called when the background execution succeeded, failed, has been cancelled or interrupted. It is intended for cleaning up the task, task state or releasing resources.



Copyright © 2000-2008 JGoodies Karsten Lentzsch. All Rights Reserved.