org.apache.jetspeed.aggregator.impl
Class WorkerImpl

java.lang.Object
  extended by java.lang.Thread
      extended by org.apache.jetspeed.aggregator.impl.WorkerImpl
All Implemented Interfaces:
Runnable, org.apache.jetspeed.aggregator.Worker

public class WorkerImpl
extends Thread
implements org.apache.jetspeed.aggregator.Worker

Worker thread processes jobs and notify its WorkerMonitor when completed. When no work is available, the worker simply sets itself in a waiting mode pending reactivation by the WorkerMonitor

Version:
$Id: WorkerImpl.java 587064 2007-10-22 11:54:11Z woonsan $
Author:
Raphael Luta, Woonsan Ko

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
private  AccessControlContext context
          Context to process job within
private  Runnable job
          Job to process
private  int jobCount
          Counter of consecutive jobs that can be processed before the worker being actually put back on the idle queue
protected static org.apache.commons.logging.Log log
          Commons logging
private  org.apache.jetspeed.aggregator.WorkerMonitor monitor
          Monitor for this Worker
private  boolean running
          Running status of this worker
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
WorkerImpl(org.apache.jetspeed.aggregator.WorkerMonitor monitor)
           
WorkerImpl(org.apache.jetspeed.aggregator.WorkerMonitor monitor, ThreadGroup tg, String name)
           
 
Method Summary
 Runnable getJob()
          Retrieves the job to execute
 int getJobCount()
          Return the number of jobs processed by this worker since the last time it has been on the idle queue
 void resetJobCount()
          Reset the processed job counter
 void run()
          Process the job assigned, then notify Monitor.
 void setJob(Runnable job)
          Sets the job to execute
 void setJob(Runnable job, AccessControlContext context)
          Sets the job to execute in security context
 void setMonitor(org.apache.jetspeed.aggregator.WorkerMonitor monitor)
          Sets the moitor of this worker
 void setRunning(boolean status)
          Sets the running status of this Worker.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, 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
 
Methods inherited from interface org.apache.jetspeed.aggregator.Worker
start
 

Field Detail

log

protected static final org.apache.commons.logging.Log log
Commons logging


running

private boolean running
Running status of this worker


jobCount

private int jobCount
Counter of consecutive jobs that can be processed before the worker being actually put back on the idle queue


job

private Runnable job
Job to process


context

private AccessControlContext context
Context to process job within


monitor

private org.apache.jetspeed.aggregator.WorkerMonitor monitor
Monitor for this Worker

Constructor Detail

WorkerImpl

public WorkerImpl(org.apache.jetspeed.aggregator.WorkerMonitor monitor)

WorkerImpl

public WorkerImpl(org.apache.jetspeed.aggregator.WorkerMonitor monitor,
                  ThreadGroup tg,
                  String name)
Method Detail

getJobCount

public int getJobCount()
Return the number of jobs processed by this worker since the last time it has been on the idle queue

Specified by:
getJobCount in interface org.apache.jetspeed.aggregator.Worker

resetJobCount

public void resetJobCount()
Reset the processed job counter

Specified by:
resetJobCount in interface org.apache.jetspeed.aggregator.Worker

setRunning

public void setRunning(boolean status)
Sets the running status of this Worker. If set to false, the Worker will stop after processing its current job.

Specified by:
setRunning in interface org.apache.jetspeed.aggregator.Worker

setMonitor

public void setMonitor(org.apache.jetspeed.aggregator.WorkerMonitor monitor)
Sets the moitor of this worker

Specified by:
setMonitor in interface org.apache.jetspeed.aggregator.Worker

setJob

public void setJob(Runnable job,
                   AccessControlContext context)
Sets the job to execute in security context

Specified by:
setJob in interface org.apache.jetspeed.aggregator.Worker

setJob

public void setJob(Runnable job)
Sets the job to execute

Specified by:
setJob in interface org.apache.jetspeed.aggregator.Worker

getJob

public Runnable getJob()
Retrieves the job to execute

Specified by:
getJob in interface org.apache.jetspeed.aggregator.Worker

run

public void run()
Process the job assigned, then notify Monitor. If no job available, go into sleep mode

Specified by:
run in interface Runnable
Overrides:
run in class Thread


Copyright © 1999-2007 Apache Software Foundation. All Rights Reserved.