Package org.jboss.weld.executor
Class AbstractExecutorServices
- java.lang.Object
-
- org.jboss.weld.executor.AbstractExecutorServices
-
- All Implemented Interfaces:
org.jboss.weld.bootstrap.api.Service
,org.jboss.weld.manager.api.ExecutorServices
- Direct Known Subclasses:
CommonForkJoinPoolExecutorServices
,FixedThreadPoolExecutorServices
,SingleThreadExecutorServices
,TimingOutFixedThreadPoolExecutorServices
public abstract class AbstractExecutorServices extends Object implements org.jboss.weld.manager.api.ExecutorServices
Common implementation ofExecutorServices
- Author:
- Jozef Hartinger
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jboss.weld.manager.api.ExecutorServices
org.jboss.weld.manager.api.ExecutorServices.TaskFactory<T extends Object>
-
-
Constructor Summary
Constructors Constructor Description AbstractExecutorServices()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected <T> List<Future<T>>
checkForExceptions(List<Future<T>> futures)
void
cleanup()
protected abstract int
getThreadPoolSize()
Indicates the maximum number of threads in this thread pool.ScheduledExecutorService
getTimerExecutor()
Returns a singleton instance of ScheduledExecutorService.<T> List<Future<T>>
invokeAllAndCheckForExceptions(Collection<? extends Callable<T>> tasks)
<T> List<Future<T>>
invokeAllAndCheckForExceptions(org.jboss.weld.manager.api.ExecutorServices.TaskFactory<T> factory)
protected void
shutdown()
<T> Collection<? extends Callable<T>>
wrap(Collection<? extends Callable<T>> tasks)
This method is invoked with the body ofinvokeAllAndCheckForExceptions(java.util.Collection)
It allows to wrap the tasks with some additional logic.
-
-
-
Method Detail
-
getTimerExecutor
public ScheduledExecutorService getTimerExecutor()
Returns a singleton instance of ScheduledExecutorService.- Specified by:
getTimerExecutor
in interfaceorg.jboss.weld.manager.api.ExecutorServices
- Returns:
- A managed instance of ScheduledExecutorService
-
invokeAllAndCheckForExceptions
public <T> List<Future<T>> invokeAllAndCheckForExceptions(Collection<? extends Callable<T>> tasks)
- Specified by:
invokeAllAndCheckForExceptions
in interfaceorg.jboss.weld.manager.api.ExecutorServices
-
invokeAllAndCheckForExceptions
public <T> List<Future<T>> invokeAllAndCheckForExceptions(org.jboss.weld.manager.api.ExecutorServices.TaskFactory<T> factory)
- Specified by:
invokeAllAndCheckForExceptions
in interfaceorg.jboss.weld.manager.api.ExecutorServices
-
getThreadPoolSize
protected abstract int getThreadPoolSize()
Indicates the maximum number of threads in this thread pool. If the value is unknown or if the max number of threads is not bounded this method should return -1
-
cleanup
public void cleanup()
- Specified by:
cleanup
in interfaceorg.jboss.weld.bootstrap.api.Service
-
shutdown
protected void shutdown()
-
wrap
public <T> Collection<? extends Callable<T>> wrap(Collection<? extends Callable<T>> tasks)
This method is invoked with the body ofinvokeAllAndCheckForExceptions(java.util.Collection)
It allows to wrap the tasks with some additional logic. For instance, Weld'sCommonForkJoinPoolExecutorServices
overrides this in order to set TCCL to null prior to execution.
-
-