org.apache.sandesha2.workers
Class SandeshaThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.apache.sandesha2.workers.SandeshaThread
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
Invoker, PollingManager, Sender

public abstract class SandeshaThread
extends java.lang.Thread

Aggregates pause and stop logic between sender and invoker threads.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  org.apache.axis2.context.ConfigurationContext context
           
protected  StorageManager storageManager
           
protected  org.apache.axis2.util.threadpool.ThreadFactory threadPool
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SandeshaThread(int sleepTime)
           
 
Method Summary
 void blockForPause()
          Waits for the invoking thread to pause
protected  void doPauseIfNeeded()
           
 void finishPause()
           
 java.util.ArrayList<SequenceEntry> getSequences()
           
 WorkerLock getWorkerLock()
           
protected  boolean hasStoppedRunning()
           
protected abstract  boolean internalRun()
          The main work loop, to be implemented by any child class.
 boolean isThreadStarted()
           
 void run()
           
protected  boolean runMainLoop()
          Test to check if a notify has been called when not waiting
 void runThreadForSequence(org.apache.axis2.context.ConfigurationContext context, java.lang.String sequenceID, boolean rmSource)
          Ensure that the worker thread is aware of the given sequence.
 void setRanMainLoop()
          Indicate that the main loop has been run
 void stopRunning()
           
 void stopThreadForSequence(java.lang.String sequenceID, boolean rmSource)
           
 void wakeThread()
          Wake the current thread as there is work to be done.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, 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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

threadPool

protected transient org.apache.axis2.util.threadpool.ThreadFactory threadPool

context

protected org.apache.axis2.context.ConfigurationContext context

storageManager

protected StorageManager storageManager
Constructor Detail

SandeshaThread

public SandeshaThread(int sleepTime)
Method Detail

getWorkerLock

public final WorkerLock getWorkerLock()

stopThreadForSequence

public void stopThreadForSequence(java.lang.String sequenceID,
                                  boolean rmSource)

blockForPause

public void blockForPause()
Waits for the invoking thread to pause


finishPause

public void finishPause()

stopRunning

public void stopRunning()

isThreadStarted

public boolean isThreadStarted()

runThreadForSequence

public void runThreadForSequence(org.apache.axis2.context.ConfigurationContext context,
                                 java.lang.String sequenceID,
                                 boolean rmSource)
Ensure that the worker thread is aware of the given sequence. As source sequences do not have a proper sequence id at the time they are bootstrapped, the caller must pass in the internal sequence id when rmSource is true.


getSequences

public java.util.ArrayList<SequenceEntry> getSequences()
Returns:
a List of SequenceEntry instances

hasStoppedRunning

protected boolean hasStoppedRunning()

doPauseIfNeeded

protected void doPauseIfNeeded()

wakeThread

public void wakeThread()
Wake the current thread as there is work to be done. Also flag that if we miss a notify, then there is work to be done. Implementing threads should check this value before waiting


setRanMainLoop

public void setRanMainLoop()
Indicate that the main loop has been run


runMainLoop

protected boolean runMainLoop()
Test to check if a notify has been called when not waiting

Returns:

internalRun

protected abstract boolean internalRun()
The main work loop, to be implemented by any child class. If the child wants to sleep before the next loop then they should return true.


run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread


Copyright © The Apache Software Foundation. All Rights Reserved.