org.ow2.petals.microkernel.api.container.thread
Class AbstractThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.ow2.petals.microkernel.api.container.thread.AbstractThread
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
BootstrapThread, ComponentLifeCycleThread

public abstract class AbstractThread
extends Thread

This class is the parent class for managing tasks to perform on Components, Bootstrap and ServiceAssemblies. Tasks on those objects are performed in a dedicated thread, preventing the main thread to be blocked. When a timeout exceeds on an action, the task is considered as blocked, and an exception is thrown

Author:
Adrien Louis - EBM WebSourcing, Christophe Hamerling - EBM WebSourcing

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
protected  javax.jbi.JBIException jbiException
          Exception thrown when a task failed in its own thread.
protected  LoggingUtil logger
           
protected  BlockingQueue<String> requestQueue
          The blocking working queue is equal to a FIFO.
protected  BlockingQueue<String> responseQueue
          The response queue used to wait for the task to complete.
static String SHUTDOWNTHREAD
          Shutdown thread action
protected  long timeout
          Time before an action is considered as blocked Exception is thrown when this time exceed
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
AbstractThread(long taskTimeout, LoggingUtil logger)
          Creates a new instance of AbstractThread
 
Method Summary
protected abstract  boolean doTask(String action)
          Execute the task in the dedicated thread.
protected  void execute(String action)
          Execute the action.
 void run()
           
 void shutdownThread()
          Shutdown the current thread
 
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

jbiException

protected javax.jbi.JBIException jbiException
Exception thrown when a task failed in its own thread. Retrieved by the main thread


requestQueue

protected BlockingQueue<String> requestQueue
The blocking working queue is equal to a FIFO. The worker thread is waiting for an element to be added in this queue by the caller thread. This queue is the synchronization object between caller thread and execution thread. When an element is added by the caller thread, the execution thread wakes up and do the task.


responseQueue

protected BlockingQueue<String> responseQueue
The response queue used to wait for the task to complete. The caller thread is blocked on this queue while the task is not complted by the worker thread. This queue is the synchronization object between execution thread and caller thread. When the execution thread put an object in this queue, the caller thread wakes up.


SHUTDOWNTHREAD

public static final String SHUTDOWNTHREAD
Shutdown thread action

See Also:
Constant Field Values

logger

protected final LoggingUtil logger

timeout

protected long timeout
Time before an action is considered as blocked Exception is thrown when this time exceed

Constructor Detail

AbstractThread

public AbstractThread(long taskTimeout,
                      LoggingUtil logger)
Creates a new instance of AbstractThread

Method Detail

run

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

doTask

protected abstract boolean doTask(String action)
Execute the task in the dedicated thread. A JBI exception can occur during the task execution. In this case, the local jbiException must be filled with this exception and is shared between client and thread.

Returns:
false if the current thread needs to be shutdowned

execute

protected void execute(String action)
                throws javax.jbi.JBIException
Execute the action. If the thread is not alive, throw an exception. On the other cases, put the action in the FIFO and wait for the task to complete. This method is the entry point of the task submission, multiple threads will wait for other threads to complete.

Parameters:
action -
Throws:
javax.jbi.JBIException

shutdownThread

public void shutdownThread()
                    throws javax.jbi.JBIException
Shutdown the current thread

Throws:
javax.jbi.JBIException


Copyright © 2005-2015 Linagora. All Rights Reserved.