Trull

edu.luc.cs.trull.task
Class AbstractTaskWorker

java.lang.Object
  extended by edu.luc.cs.trull.EmptyComponent
      extended by edu.luc.cs.trull.TerminatingComponent
          extended by edu.luc.cs.trull.task.AbstractTaskWorker
All Implemented Interfaces:
Component, PropertyChangeSource, Startable, Suspendable, Terminating, java.beans.PropertyChangeListener, java.util.EventListener
Direct Known Subclasses:
PooledTaskWorker, QueuedTaskWorker

abstract class AbstractTaskWorker
extends TerminatingComponent

A Worker for the step-by-step execution of a Task using an Executor.

See Also:
Task

Field Summary
protected  boolean firstTime
          A variable indicating whether the task is being executed for the first time.
private static org.apache.log4j.Logger logger
           
protected static int RUNNING
          The running state.
protected  java.lang.Runnable start
          The Runnable for starting work on the task.
protected  EDU.oswego.cs.dl.util.concurrent.WaitableInt state
          The variable holding the current state.
protected static int STOPPED
          The stopped state.
protected static int SUSPENDED
          The suspended state.
protected  Task task
          The task executed by this worker.
 
Constructor Summary
AbstractTaskWorker(Task task)
          Constructs a worker for the given task.
 
Method Summary
protected abstract  EDU.oswego.cs.dl.util.concurrent.Executor getExecutor()
          The executor used by this worker to schedule portions of the work.
 void resume()
          Resumes this suspendable component.
protected  void setStart(java.lang.Runnable start)
          Sets the Runnable for starting the work.
 void setTask(Task task)
          Sets the task to be performed.
 void start(java.beans.PropertyChangeEvent incoming)
          Starts this startable component.
 void stop()
          Stops this startable component.
 void suspend()
          Suspends this suspendable component.
 
Methods inherited from class edu.luc.cs.trull.TerminatingComponent
fireTermination, getParent, getTermEvent, scheduleTermination, setTerminationListener
 
Methods inherited from class edu.luc.cs.trull.EmptyComponent
addPropertyChangeListener, getPropertyChangeListeners, getTerminationListener, propertyChange, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

firstTime

protected boolean firstTime
A variable indicating whether the task is being executed for the first time.


logger

private static org.apache.log4j.Logger logger

RUNNING

protected static final int RUNNING
The running state.

See Also:
Constant Field Values

start

protected java.lang.Runnable start
The Runnable for starting work on the task.


state

protected final EDU.oswego.cs.dl.util.concurrent.WaitableInt state
The variable holding the current state.


STOPPED

protected static final int STOPPED
The stopped state.

See Also:
Constant Field Values

SUSPENDED

protected static final int SUSPENDED
The suspended state.

See Also:
Constant Field Values

task

protected Task task
The task executed by this worker.

Constructor Detail

AbstractTaskWorker

public AbstractTaskWorker(Task task)
Constructs a worker for the given task.

Parameters:
task - the task to be performed.
Throws:
java.lang.IllegalArgumentException - if the task is null.
Method Detail

getExecutor

protected abstract EDU.oswego.cs.dl.util.concurrent.Executor getExecutor()
The executor used by this worker to schedule portions of the work.

Returns:
the executor used by this worker.

resume

public void resume()
Description copied from interface: Suspendable
Resumes this suspendable component.

Specified by:
resume in interface Suspendable
Overrides:
resume in class EmptyComponent

setStart

protected void setStart(java.lang.Runnable start)
Sets the Runnable for starting the work.

Parameters:
start -

setTask

public void setTask(Task task)
Sets the task to be performed.

Parameters:
task - the task to be performed.
Throws:
java.lang.IllegalArgumentException - if the task is null.

start

public void start(java.beans.PropertyChangeEvent incoming)
Description copied from interface: Startable
Starts this startable component.

Specified by:
start in interface Startable
Overrides:
start in class EmptyComponent
Parameters:
incoming - the event that triggered the invocation of this method. May be null.

stop

public void stop()
Description copied from interface: Startable
Stops this startable component.

Specified by:
stop in interface Startable
Overrides:
stop in class EmptyComponent

suspend

public void suspend()
Description copied from interface: Suspendable
Suspends this suspendable component.

Specified by:
suspend in interface Suspendable
Overrides:
suspend in class EmptyComponent

Trull

http://www.cs.luc.edu/trull/