org.jasig.portal.utils.threading
Class BaseTask

java.lang.Object
  extended by org.jasig.portal.utils.threading.BaseTask
All Implemented Interfaces:
java.lang.Runnable, Task
Direct Known Subclasses:
ChannelRenderer.Worker, RunnableTask, StatsRecorderWorkerTask

public abstract class BaseTask
extends java.lang.Object
implements Task

A convenience base task class for subclasses. Introduces an execute() method which declares throws Exception, which subclasses may override. Any Exception thrown from execute will be caught and stored, to be accessible through getException NOTE: Throwable is not caught to avoid catching Errors

Author:
Aaron Hamid (arh14 at cornell dot edu)

Field Summary
protected  java.lang.Exception exception
           
 
Constructor Summary
BaseTask()
           
 
Method Summary
abstract  void execute()
          Subclasses should implement this method NOTE: not declaring throws Throwable.
 java.lang.Exception getException()
          Returns the exception that was thrown during execution, if any
 void run()
          Run implementation which delegates to execute().
protected  void setException(java.lang.Exception e)
          Only subclasses are allowed to use this
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

exception

protected java.lang.Exception exception
Constructor Detail

BaseTask

public BaseTask()
Method Detail

run

public void run()
Run implementation which delegates to execute(). Catches and stores any exception execute() throws.

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

setException

protected void setException(java.lang.Exception e)
Only subclasses are allowed to use this

Parameters:
e - exception to set

execute

public abstract void execute()
                      throws java.lang.Exception
Subclasses should implement this method NOTE: not declaring throws Throwable. We shouldn't really catch Errors, should we?

Throws:
java.lang.Exception

getException

public java.lang.Exception getException()
Returns the exception that was thrown during execution, if any

Specified by:
getException in interface Task
Returns:
the exception that was thrown during execution, if any