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:
java.lang.Runnable, Worker

public class WorkerImpl
extends java.lang.Thread
implements 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
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected static org.apache.commons.logging.Log log
          Commons logging
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
WorkerImpl(WorkerMonitor monitor)
           
WorkerImpl(WorkerMonitor monitor, java.lang.ThreadGroup tg, java.lang.String name)
           
 
Method Summary
 java.lang.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(java.lang.Runnable job)
          Sets the job to execute
 void setJob(java.lang.Runnable job, java.security.AccessControlContext context)
          Sets the job to execute in security context
 void setMonitor(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

Constructor Detail

WorkerImpl

public WorkerImpl(WorkerMonitor monitor)

WorkerImpl

public WorkerImpl(WorkerMonitor monitor,
                  java.lang.ThreadGroup tg,
                  java.lang.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 Worker

resetJobCount

public void resetJobCount()
Reset the processed job counter

Specified by:
resetJobCount in interface 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 Worker

setMonitor

public void setMonitor(WorkerMonitor monitor)
Sets the moitor of this worker

Specified by:
setMonitor in interface Worker

setJob

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

Specified by:
setJob in interface Worker

setJob

public void setJob(java.lang.Runnable job)
Sets the job to execute

Specified by:
setJob in interface Worker

getJob

public java.lang.Runnable getJob()
Retrieves the job to execute

Specified by:
getJob in interface 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 java.lang.Runnable
Overrides:
run in class java.lang.Thread


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