|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.swinglib.AsynchronousOperation<T>
public abstract class AsynchronousOperation<T>
A base class for implementing operations that need to run on their own
thread and report back to the event thread. Unlike Sun's SwingWorker
class, this object does not spawn its own thread. Instead, it must
be passed to a program-created thread, or better, a threadpool.
To use, subclass and pass an instance to your operation thread.
You must implement at least the performOperation()
method, which is
executed on the operation thread. This method may return a single object,
or throw any exception type. Depending on how it completes (return/throw),
one of onSuccess(T)
, onFailure(java.lang.Throwable)
will then be executed on the
event thread.
Constructor Summary | |
---|---|
AsynchronousOperation()
|
Method Summary | |
---|---|
protected void |
onComplete()
This method is invoked on the event thread when the operation completes, regardless of whether it succeeded or failed. |
protected void |
onFailure(Throwable e)
This method is invoked on the event thread if performOperation()
threw an exception. |
protected void |
onSuccess(T result)
This method is invoked on the event thread after a successful call to performOperation() . |
protected abstract T |
performOperation()
The concrete class implements this method, which is executed on the non-event thread. |
void |
run()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AsynchronousOperation()
Method Detail |
---|
public final void run()
run
in interface Runnable
protected abstract T performOperation() throws Exception
Exception
protected void onComplete()
protected void onSuccess(T result)
performOperation()
. Application code typically overrides
to do something with that result.
protected void onFailure(Throwable e)
performOperation()
threw an exception. Application code typically overrides
to do something with that exception.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |