|
JBoss Threads 2.0.0.GA-redhat-2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.threads.JBossExecutors
public final class JBossExecutors
JBoss thread- and executor-related utility and factory methods.
Method Summary | ||
---|---|---|
static RejectedExecutionHandler |
abortPolicy()
Get the abort policy for a ThreadPoolExecutor . |
|
static BlockingExecutor |
blockingDirectExecutor()
Get an executor which executes tasks in the current thread, which implements BlockingExecutor . |
|
static BlockingExecutor |
blockingDiscardingExecutor()
Get an executor which discards all tasks, which implements BlockingExecutor . |
|
static BlockingExecutor |
blockingRejectingExecutor()
Get an executor which rejects all tasks, which implements BlockingExecutor . |
|
static RejectedExecutionHandler |
callerRunsPolicy()
Get the caller-runs policy for a ThreadPoolExecutor . |
|
static Runnable |
classLoaderPreservingTask(Runnable delegate)
Create a task that delegates to the given task, preserving the context classloader which was in effect when this method was invoked. |
|
static DirectExecutor |
cleanupExecutor(DirectExecutor delegate,
Runnable cleaner)
Create an executor which runs the given cleanup task after running its given task. |
|
static Runnable |
compositeTask(Collection<Runnable> runnables)
Create a task that is a composite of several other tasks. |
|
static Runnable |
compositeTask(Runnable... runnables)
Create a task that is a composite of several other tasks. |
|
static DirectExecutor |
contextClassLoaderExecutor(DirectExecutor delegate,
ClassLoader taskClassLoader)
Create a direct executor which runs tasks with the given context class loader. |
|
static Runnable |
contextClassLoaderResetter()
Get a Runnable which, when executed, clears the thread context class loader (if the caller has sufficient
privileges). |
|
static DependencyTaskBuilder |
dependencyTaskBuilder(Executor executor,
Runnable task)
Create a builder for a dependent task. |
|
static BlockingExecutor |
directBlockingExecutor(DirectExecutor delegate)
An executor which delegates to the given direct executor, but implements the blocking executor interface. |
|
static DirectExecutor |
directExecutor()
Get the direct executor. |
|
static DirectExecutorService |
directExecutorService()
Get the direct executor service. |
|
static DirectExecutor |
discardingExecutor()
Get the discarding executor. |
|
static DirectExecutorService |
discardingExecutorService()
Get the discarding executor service. |
|
static RejectedExecutionHandler |
discardOldestPolicy()
Get the discard-oldest policy for a ThreadPoolExecutor . |
|
static RejectedExecutionHandler |
discardPolicy()
Get the discard policy for a ThreadPoolExecutor . |
|
static DirectExecutor |
exceptionLoggingExecutor(DirectExecutor delegate)
Create a direct executor which consumes and logs errors that are thrown to the default thread error category "org.jboss.threads.errors" . |
|
static DirectExecutor |
exceptionLoggingExecutor(DirectExecutor delegate,
org.jboss.logging.Logger log)
Create a direct executor which consumes and logs errors that are thrown. |
|
static DirectExecutor |
exceptionLoggingExecutor(DirectExecutor delegate,
org.jboss.logging.Logger log,
org.jboss.logging.Logger.Level level)
Create a direct executor which consumes and logs errors that are thrown. |
|
static void |
executeUninterruptibly(Executor executor,
Runnable task)
Execute a task uninterruptibly. |
|
static Executor |
executor(WrappingExecutor delegate,
DirectExecutor taskWrapper)
An executor which delegates to a wrapping executor, wrapping each task in a task wrapper. |
|
static Runnable |
executorTask(DirectExecutor executor,
Runnable task)
Get a task that runs the given task through the given direct executor. |
|
static RejectedExecutionHandler |
handoffPolicy(Executor target)
Get a handoff policy for a ThreadPoolExecutor . |
|
static DirectExecutor |
initializingExecutor(DirectExecutor delegate,
Runnable initializer)
Create an executor which runs the given initialization task before running its given task. |
|
static Thread.UncaughtExceptionHandler |
loggingExceptionHandler()
Get an uncaught exception handler which logs to the default error logger. |
|
static Thread.UncaughtExceptionHandler |
loggingExceptionHandler(org.jboss.logging.Logger log)
Get an uncaught exception handler which logs to the given logger. |
|
static Thread.UncaughtExceptionHandler |
loggingExceptionHandler(String categoryName)
Get an uncaught exception handler which logs to the given logger. |
|
static
|
notifyingDirectExecutor(DirectExecutor delegate,
TaskNotifier<Runnable,? super A> notifier,
A attachment)
Get a notifying direct executor. |
|
static
|
notifyingRunnable(R task,
TaskNotifier<? super R,? super A> notifier,
A attachment)
Get a notifying runnable wrapper for a task. |
|
static Runnable |
nullRunnable()
Get the null runnable which does nothing. |
|
static DirectExecutor |
privilegedExecutor(DirectExecutor delegate)
Create a direct executor which runs with the privileges given by the current access control context. |
|
static DirectExecutor |
privilegedExecutor(DirectExecutor delegate,
AccessControlContext context)
Create a direct executor which runs with the privileges given by the supplied AccessControlContext instance. |
|
static DirectExecutor |
privilegedExecutor(DirectExecutor delegate,
Class<?> targetClass)
Create a direct executor which runs with the privileges given by the supplied class' protection domain. |
|
static BlockingExecutor |
protectedBlockingExecutor(BlockingExecutor target)
|
|
static BlockingExecutorService |
protectedBlockingExecutorService(BlockingExecutor target)
Wrap a blocking executor with an BlockingExecutorService instance which supports all the features of
BlockingExecutorService except for shutting down the executor. |
|
static DirectExecutorService |
protectedDirectExecutorService(DirectExecutor target)
Wrap a direct executor with an DirectExecutorService instance which supports all the features of ExecutorService
except for shutting down the executor. |
|
static ExecutorService |
protectedExecutorService(Executor target)
Wrap an executor with an ExecutorService instance which supports all the features of ExecutorService
except for shutting down the executor. |
|
static ScheduledExecutorService |
protectedScheduledExecutorService(ScheduledExecutorService target)
Wrap a scheduled executor with a ScheduledExecutorService instance which supports all the features of
ScheduledExecutorService except for shutting down the executor. |
|
static DirectExecutor |
rejectingExecutor()
Get the rejecting executor. |
|
static DirectExecutor |
rejectingExecutor(String message)
Get a rejecting executor. |
|
static DirectExecutorService |
rejectingExecutorService()
Get the rejecting executor service. |
|
static DirectExecutorService |
rejectingExecutorService(String message)
Get the rejecting executor service. |
|
static DirectExecutor |
resettingExecutor(DirectExecutor delegate)
Create a direct executor which delegates tasks to the given executor, and then clears all thread-local data after each task completes (regardless of outcome). |
|
static ThreadFactory |
resettingThreadFactory(ThreadFactory delegate)
Create a thread factory which resets all thread-local storage and delegates to the given thread factory. |
|
static
|
run(R task,
DirectExecutor directExecutor,
TaskNotifier<? super R,? super A> notifier,
A attachment)
Run a task through the given direct executor, invoking the given notifier with the given attachment. |
|
static
|
run(R task,
TaskNotifier<? super R,? super A> notifier,
A attachment)
Run a task, invoking the given notifier with the given attachment. |
|
static BlockingExecutor |
threadFactoryExecutor(ThreadFactory factory)
Create an executor that executes each task in a new thread. |
|
static BlockingExecutor |
threadFactoryExecutor(ThreadFactory factory,
int maxThreads)
Create an executor that executes each task in a new thread. |
|
static BlockingExecutor |
threadFactoryExecutor(ThreadFactory factory,
int maxThreads,
boolean blocking)
Create an executor that executes each task in a new thread. |
|
static BlockingExecutor |
threadFactoryExecutor(ThreadFactory factory,
int maxThreads,
boolean blocking,
DirectExecutor taskExecutor)
Create an executor that executes each task in a new thread. |
|
static DirectExecutor |
threadFormattedNameExecutor(DirectExecutor delegate,
String newName)
Create a direct executor which changes the thread name for the duration of a task using a formatted name. |
|
static Runnable |
threadLocalResetter()
Get a Runnable which, when executed, clears the thread-local storage of the calling thread. |
|
static DirectExecutor |
threadNameExecutor(DirectExecutor delegate,
String newName)
Create a direct executor which changes the thread name for the duration of a task. |
|
static DirectExecutor |
threadNameNotateExecutor(DirectExecutor delegate,
String notation)
Create a direct executor which adds a note to the thread name for the duration of a task. |
|
static Executor |
uninterruptibleExecutor(Executor delegate)
Get an executor which executes tasks uninterruptibly in the event of blocking. |
|
static Executor |
wrappingExecutor(DirectExecutor taskWrapper,
Executor delegate)
An executor which delegates to another executor, wrapping each task in a task wrapper. |
|
static WrappingExecutor |
wrappingExecutor(Executor delegate)
Create a wrapping executor for a delegate executor which creates an executorTask(DirectExecutor, Runnable) for
each task. |
|
static ThreadFactory |
wrappingThreadFactory(DirectExecutor taskWrapper,
ThreadFactory delegate)
Creates a thread factory which executes the thread task via the given task wrapping executor. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static DirectExecutor directExecutor()
public static DirectExecutorService directExecutorService()
public static DirectExecutor rejectingExecutor()
public static DirectExecutor rejectingExecutor(String message)
message
- the reject message
public static DirectExecutorService rejectingExecutorService()
public static DirectExecutorService rejectingExecutorService(String message)
message
- the reject message
public static DirectExecutor discardingExecutor()
public static DirectExecutorService discardingExecutorService()
public static DirectExecutor privilegedExecutor(DirectExecutor delegate, AccessControlContext context)
AccessControlContext
instance.
delegate
- the executor to delegate to at the privileged levelcontext
- the AccessControlContext
to use
public static DirectExecutor privilegedExecutor(DirectExecutor delegate, Class<?> targetClass) throws SecurityException
delegate
- the executor to delegate to at the privileged leveltargetClass
- the target class whose protection domain should be used
SecurityException
- if there is a security manager installed and the caller lacks the "getProtectionDomain"
RuntimePermission
public static DirectExecutor privilegedExecutor(DirectExecutor delegate)
delegate
- the executor to delegate to at the privileged level
public static DirectExecutor contextClassLoaderExecutor(DirectExecutor delegate, ClassLoader taskClassLoader)
delegate
- the executor to delegate totaskClassLoader
- the context class loader to use
public static DirectExecutor threadNameExecutor(DirectExecutor delegate, String newName)
delegate
- the executor to delegate tonewName
- the thread name to use
public static DirectExecutor threadFormattedNameExecutor(DirectExecutor delegate, String newName)
JBossThread
.
delegate
- the executor to delegate tonewName
- the thread name to use
public static DirectExecutor threadNameNotateExecutor(DirectExecutor delegate, String notation)
delegate
- the executor to delegate tonotation
- the note to use
public static DirectExecutor exceptionLoggingExecutor(DirectExecutor delegate, org.jboss.logging.Logger log)
delegate
- the executor to delegate tolog
- the logger to which exceptions are written at the error
level
public static DirectExecutor exceptionLoggingExecutor(DirectExecutor delegate, org.jboss.logging.Logger log, org.jboss.logging.Logger.Level level)
delegate
- the executor to delegate tolog
- the logger to which exceptions are writtenlevel
- the level at which to log exceptions
public static DirectExecutor exceptionLoggingExecutor(DirectExecutor delegate)
"org.jboss.threads.errors"
.
delegate
- the executor to delegate to
public static DirectExecutor resettingExecutor(DirectExecutor delegate) throws SecurityException
RuntimePermission
("modifyThread")
permission to use this method.
delegate
- the delegate direct executor
SecurityException
- if the caller does not have the RuntimePermission
("modifyThread")
permissionpublic static DirectExecutor initializingExecutor(DirectExecutor delegate, Runnable initializer)
delegate
- the delegate direct executorinitializer
- the initialization task
public static DirectExecutor cleanupExecutor(DirectExecutor delegate, Runnable cleaner)
delegate
- the delegate direct executorcleaner
- the cleanup task
public static BlockingExecutor blockingDirectExecutor()
BlockingExecutor
.
public static BlockingExecutor blockingDiscardingExecutor()
BlockingExecutor
.
public static BlockingExecutor blockingRejectingExecutor()
BlockingExecutor
.
public static Executor wrappingExecutor(DirectExecutor taskWrapper, Executor delegate)
taskWrapper
- the task wrapperdelegate
- the delegate executor
public static BlockingExecutor directBlockingExecutor(DirectExecutor delegate)
delegate
- the delegate direct executor
public static WrappingExecutor wrappingExecutor(Executor delegate)
executorTask(DirectExecutor, Runnable)
for
each task.
delegate
- the delegate executor
public static Executor executor(WrappingExecutor delegate, DirectExecutor taskWrapper)
delegate
- the delegate executortaskWrapper
- the task wrapper
public static BlockingExecutor threadFactoryExecutor(ThreadFactory factory)
factory
- the thread factory to use
public static BlockingExecutor threadFactoryExecutor(ThreadFactory factory, int maxThreads)
factory
- the thread factory to usemaxThreads
- the maximum number of allowed threads
public static BlockingExecutor threadFactoryExecutor(ThreadFactory factory, int maxThreads, boolean blocking)
blocking
parameter.
factory
- the thread factory to usemaxThreads
- the maximum number of allowed threadsblocking
- true
if the submitter should block when the maximum number of threads has been reached
public static BlockingExecutor threadFactoryExecutor(ThreadFactory factory, int maxThreads, boolean blocking, DirectExecutor taskExecutor)
blocking
parameter.
factory
- the thread factory to usemaxThreads
- the maximum number of allowed threadsblocking
- true
if the submitter should block when the maximum number of threads has been reachedtaskExecutor
- the executor which should run each task
public static RejectedExecutionHandler abortPolicy()
ThreadPoolExecutor
.
ThreadPoolExecutor.AbortPolicy
public static RejectedExecutionHandler callerRunsPolicy()
ThreadPoolExecutor
.
ThreadPoolExecutor.CallerRunsPolicy
public static RejectedExecutionHandler discardOldestPolicy()
ThreadPoolExecutor
.
ThreadPoolExecutor.DiscardOldestPolicy
public static RejectedExecutionHandler discardPolicy()
ThreadPoolExecutor
.
ThreadPoolExecutor.DiscardPolicy
public static RejectedExecutionHandler handoffPolicy(Executor target)
ThreadPoolExecutor
. The returned instance will
delegate to another executor in the event that the task is rejected.
target
- the target executor
public static BlockingExecutor protectedBlockingExecutor(BlockingExecutor target)
public static ExecutorService protectedExecutorService(Executor target)
ExecutorService
instance which supports all the features of ExecutorService
except for shutting down the executor.
target
- the target executor
public static DirectExecutorService protectedDirectExecutorService(DirectExecutor target)
DirectExecutorService
instance which supports all the features of ExecutorService
except for shutting down the executor.
target
- the target executor
public static ScheduledExecutorService protectedScheduledExecutorService(ScheduledExecutorService target)
ScheduledExecutorService
instance which supports all the features of
ScheduledExecutorService
except for shutting down the executor.
target
- the target executor
public static BlockingExecutorService protectedBlockingExecutorService(BlockingExecutor target)
BlockingExecutorService
instance which supports all the features of
BlockingExecutorService
except for shutting down the executor.
target
- the target executor
public static ThreadFactory resettingThreadFactory(ThreadFactory delegate) throws SecurityException
RuntimePermission
("modifyThread")
permission to use this method.
delegate
- the delegate thread factory
SecurityException
- if the caller does not have the RuntimePermission
("modifyThread")
permissionpublic static ThreadFactory wrappingThreadFactory(DirectExecutor taskWrapper, ThreadFactory delegate)
taskWrapper
- the task wrapping executordelegate
- the delegate thread factory
public static Runnable nullRunnable()
public static Runnable threadLocalResetter() throws SecurityException
Runnable
which, when executed, clears the thread-local storage of the calling thread.
You must have the RuntimePermission
("modifyThread")
permission to use this method.
SecurityException
- if the caller does not have the RuntimePermission
("modifyThread")
permissionpublic static Runnable contextClassLoaderResetter()
Runnable
which, when executed, clears the thread context class loader (if the caller has sufficient
privileges).
public static Runnable executorTask(DirectExecutor executor, Runnable task)
executor
- the executor to run the task throughtask
- the task to run
public static Runnable compositeTask(Runnable... runnables)
runnables
- the tasks
public static Runnable classLoaderPreservingTask(Runnable delegate) throws SecurityException
delegate
- the delegate runnable
SecurityException
- if a security manager exists and the caller does not have the "copyClassLoader"
RuntimePermission
.public static Runnable compositeTask(Collection<Runnable> runnables)
runnables
- the tasks
public static Thread.UncaughtExceptionHandler loggingExceptionHandler(org.jboss.logging.Logger log)
log
- the logger
public static Thread.UncaughtExceptionHandler loggingExceptionHandler(String categoryName)
categoryName
- the name of the logger category to log to
public static Thread.UncaughtExceptionHandler loggingExceptionHandler()
public static <R extends Runnable,A> void run(R task, DirectExecutor directExecutor, TaskNotifier<? super R,? super A> notifier, A attachment)
R
- the task typeA
- the attachment typetask
- the taskdirectExecutor
- the executornotifier
- the notifierattachment
- the attachmentpublic static <R extends Runnable,A> void run(R task, TaskNotifier<? super R,? super A> notifier, A attachment)
R
- the task typeA
- the attachment typetask
- the tasknotifier
- the notifierattachment
- the attachmentpublic static <R extends Runnable,A> Runnable notifyingRunnable(R task, TaskNotifier<? super R,? super A> notifier, A attachment)
R
- the task typeA
- the attachment typetask
- the tasknotifier
- the notifierattachment
- the attachment
public static <A> DirectExecutor notifyingDirectExecutor(DirectExecutor delegate, TaskNotifier<Runnable,? super A> notifier, A attachment)
A
- the attachment typedelegate
- the executor which will actually run the tasknotifier
- the notifierattachment
- the attachment
public static void executeUninterruptibly(Executor executor, Runnable task) throws RejectedExecutionException
executor
- the executor to delegate totask
- the task to execute
RejectedExecutionException
- if the task was rejected by the executorpublic static Executor uninterruptibleExecutor(Executor delegate)
delegate
- the delegate executor
public static DependencyTaskBuilder dependencyTaskBuilder(Executor executor, Runnable task)
executor
- the executor to usetask
- the task to run when all dependencies are met
|
JBoss Threads 2.0.0.GA-redhat-2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |