|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.lang.Thread
|
+--org.exolab.jmscts.core.ThreadedAction
Helper class to run an action in a separate thread, and catch any exception that the action generates.
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
ThreadedAction()
Construct a new ThreadedAction |
|
ThreadedAction(CompletionListener listener)
Construct a new ThreadedAction, with a listener to notify
on completion |
|
| Method Summary | |
long |
getElapsedTime()
Returns the elapsed time of the action. |
java.lang.Exception |
getException()
Returns any exception thrown by runProtected(), or
null, if no exception was thrown |
void |
run()
Run the action. |
abstract void |
runProtected()
Run the action |
protected void |
setException(java.lang.Exception exception)
Set the exception |
void |
waitForCompletion()
Wait for the action to complete |
boolean |
waitForCompletion(long timeout)
Wait for the action to complete |
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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 |
| Constructor Detail |
public ThreadedAction()
ThreadedActionpublic ThreadedAction(CompletionListener listener)
ThreadedAction, with a listener to notify
on completionlistener - the listener to notify on completion| Method Detail |
public void run()
runProtected().CompletionListener was supplied, it will be notified
on completion of the action.run in class java.lang.Thread
public abstract void runProtected()
throws java.lang.Exception
java.lang.Exception - for any errorpublic long getElapsedTime()
runProtected()public java.lang.Exception getException()
runProtected(), or
null, if no exception was thrownnull, if none was
thrown
public void waitForCompletion()
throws java.lang.InterruptedException
java.lang.InterruptedException - if interrupted
public boolean waitForCompletion(long timeout)
throws java.lang.InterruptedException
timeout - the number of milleseconds to wait. An argument less
than or equal to zero means not to wait at alltrue if the action completed in the given time
framejava.lang.InterruptedException - if interrupted while waitingprotected void setException(java.lang.Exception exception)
exception - the exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||