edu.emory.mathcs.util.concurrent
Class SecureThreadPoolExecutor

java.lang.Object
  extended byedu.emory.mathcs.backport.java.util.concurrent.AbstractExecutorService
      extended byedu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor
          extended byedu.emory.mathcs.util.concurrent.SecureThreadPoolExecutor
All Implemented Interfaces:
Executor, ExecutorService

public class SecureThreadPoolExecutor
extends ThreadPoolExecutor

Version of ThreadPoolExecutor that ensures propagation of access control context and thread context from call initiator to the thread executing the call. In other words, the executing call will observe access control context, delegatable thread locals, and context class loader, as they existed when the call was scheduled.

Version:
1.0
Author:
Dawid Kurzyniec

Nested Class Summary
 
Nested classes inherited from class edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
 
Constructor Summary
SecureThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue)
          Creates a new SecureThreadPoolExecutor with the given initial parameters and default thread factory and handler.
SecureThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue, RejectedExecutionHandler handler)
          Creates a new SecureThreadPoolExecutor with the given initial parameters.
SecureThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue, java.lang.ThreadGroup threadGroup, java.lang.String name)
          Creates a new SecureThreadPoolExecutor with the given initial parameters and default thread factory and handler.
SecureThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue, java.lang.ThreadGroup threadGroup, java.lang.String name, RejectedExecutionHandler handler)
          Creates a new SecureThreadPoolExecutor with the given initial parameters.
 
Method Summary
 void execute(java.lang.Runnable runnable)
          Executes the given task sometime in the future.
 void setThreadFactory(ThreadFactory factory)
          This method is disabled to prevent circumventing the context delegation performed by thie executor.
 
Methods inherited from class edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, shutdown, shutdownNow, terminated
 
Methods inherited from class edu.emory.mathcs.backport.java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecureThreadPoolExecutor

public SecureThreadPoolExecutor(int corePoolSize,
                                int maximumPoolSize,
                                long keepAliveTime,
                                TimeUnit unit,
                                BlockingQueue workQueue)
Creates a new SecureThreadPoolExecutor with the given initial parameters and default thread factory and handler. It may be more convenient to use one of the Executors factory methods instead of this general purpose constructor.

Parameters:
corePoolSize - the number of threads to keep in the pool, even if they are idle.
maximumPoolSize - the maximum number of threads to allow in the pool.
keepAliveTime - when the number of threads is greater than the core, this is the maximum time that excess idle threads will wait for new tasks before terminating.
unit - the time unit for the keepAliveTime argument.
workQueue - the queue to use for holding tasks before they are executed. This queue will hold only the Runnable tasks submitted by the execute method.
Throws:
java.lang.IllegalArgumentException - if corePoolSize, or keepAliveTime less than zero, or if maximumPoolSize less than or equal to zero, or if corePoolSize greater than maximumPoolSize.
java.lang.NullPointerException - if workQueue is null

SecureThreadPoolExecutor

public SecureThreadPoolExecutor(int corePoolSize,
                                int maximumPoolSize,
                                long keepAliveTime,
                                TimeUnit unit,
                                BlockingQueue workQueue,
                                java.lang.ThreadGroup threadGroup,
                                java.lang.String name)
Creates a new SecureThreadPoolExecutor with the given initial parameters and default thread factory and handler. It may be more convenient to use one of the Executors factory methods instead of this general purpose constructor.

Parameters:
corePoolSize - the number of threads to keep in the pool, even if they are idle.
maximumPoolSize - the maximum number of threads to allow in the pool.
keepAliveTime - when the number of threads is greater than the core, this is the maximum time that excess idle threads will wait for new tasks before terminating.
unit - the time unit for the keepAliveTime argument.
workQueue - the queue to use for holding tasks before they are executed. This queue will hold only the Runnable tasks submitted by the execute method.
threadGroup - the thread group in which threads will be created
name - the name prefix for threads
Throws:
java.lang.IllegalArgumentException - if corePoolSize, or keepAliveTime less than zero, or if maximumPoolSize less than or equal to zero, or if corePoolSize greater than maximumPoolSize.
java.lang.NullPointerException - if workQueue is null

SecureThreadPoolExecutor

public SecureThreadPoolExecutor(int corePoolSize,
                                int maximumPoolSize,
                                long keepAliveTime,
                                TimeUnit unit,
                                BlockingQueue workQueue,
                                RejectedExecutionHandler handler)
Creates a new SecureThreadPoolExecutor with the given initial parameters.

Parameters:
corePoolSize - the number of threads to keep in the pool, even if they are idle.
maximumPoolSize - the maximum number of threads to allow in the pool.
keepAliveTime - when the number of threads is greater than the core, this is the maximum time that excess idle threads will wait for new tasks before terminating.
unit - the time unit for the keepAliveTime argument.
workQueue - the queue to use for holding tasks before they are executed. This queue will hold only the Runnable tasks submitted by the execute method.
handler - the handler to use when execution is blocked because the thread bounds and queue capacities are reached.
Throws:
java.lang.IllegalArgumentException - if corePoolSize, or keepAliveTime less than zero, or if maximumPoolSize less than or equal to zero, or if corePoolSize greater than maximumPoolSize.
java.lang.NullPointerException - if workQueue or handler are null.

SecureThreadPoolExecutor

public SecureThreadPoolExecutor(int corePoolSize,
                                int maximumPoolSize,
                                long keepAliveTime,
                                TimeUnit unit,
                                BlockingQueue workQueue,
                                java.lang.ThreadGroup threadGroup,
                                java.lang.String name,
                                RejectedExecutionHandler handler)
Creates a new SecureThreadPoolExecutor with the given initial parameters.

Parameters:
corePoolSize - the number of threads to keep in the pool, even if they are idle.
maximumPoolSize - the maximum number of threads to allow in the pool.
keepAliveTime - when the number of threads is greater than the core, this is the maximum time that excess idle threads will wait for new tasks before terminating.
unit - the time unit for the keepAliveTime argument.
workQueue - the queue to use for holding tasks before they are executed. This queue will hold only the Runnable tasks submitted by the execute method.
threadGroup - the thread group in which threads will be created
name - the name prefix for threads
handler - the handler to use when execution is blocked because the thread bounds and queue capacities are reached.
Throws:
java.lang.IllegalArgumentException - if corePoolSize, or keepAliveTime less than zero, or if maximumPoolSize less than or equal to zero, or if corePoolSize greater than maximumPoolSize.
java.lang.NullPointerException - if workQueue or handler are null.
Method Detail

execute

public void execute(java.lang.Runnable runnable)
Description copied from class: ThreadPoolExecutor
Executes the given task sometime in the future. The task may execute in a new thread or in an existing pooled thread. If the task cannot be submitted for execution, either because this executor has been shutdown or because its capacity has been reached, the task is handled by the current RejectedExecutionHandler.

Specified by:
execute in interface Executor
Overrides:
execute in class ThreadPoolExecutor
Parameters:
runnable - the task to execute

setThreadFactory

public void setThreadFactory(ThreadFactory factory)
This method is disabled to prevent circumventing the context delegation performed by thie executor.

Overrides:
setThreadFactory in class ThreadPoolExecutor
Parameters:
factory - the new thread factory
See Also:
ThreadPoolExecutor.getThreadFactory()