public class DefaultTaskManager extends Object implements TaskManager
Constructor and Description |
---|
DefaultTaskManager(GriffonApplication application,
ExecutorServiceManager executorServiceManager,
TaskBlocker blocker) |
Modifier and Type | Method and Description |
---|---|
<V,C> TaskControl<V> |
create(Task<V,C> task)
Creates a new
TaskControl for a given task. |
protected ThreadPoolExecutor |
createExecutorService() |
protected <V,C> TaskContext |
createTaskContext(Task<V,C> task) |
protected <V> TaskControl<V> |
createTaskControl(TaskContext context) |
protected TaskListenerSupport |
createTaskListenerSupport() |
TaskControl |
findTask(TaskPredicate predicate) |
TaskControl |
getTask(String contextId)
Looks up a task by the specified context id.
|
TaskListenerSupport |
getTaskListenerSupport()
Allows to add listeners.
|
Iterable<TaskControl> |
getTasks(TaskPredicate predicate)
Returns a collection of all currently created task conforming to
the specified predicate.
|
<T> Future<T> |
submit(Callable<T> task)
Submits a
Callable object for execution. |
Future<?> |
submit(Runnable task)
Submits a
Runnable object for execution. |
public DefaultTaskManager(@Nonnull GriffonApplication application, @Nonnull ExecutorServiceManager executorServiceManager, TaskBlocker blocker)
protected TaskListenerSupport createTaskListenerSupport()
protected ThreadPoolExecutor createExecutorService()
public <V,C> TaskControl<V> create(Task<V,C> task)
TaskManager
TaskControl
for a given task. The state is
set to Task.State.PENDING
and the task is not started. That
allows to add listeners for this task execution before starting
it.
Tasks created by this method will fire TaskEvent
s as
appropriate. See TaskListener
for details.create
in interface TaskManager
protected <V> TaskControl<V> createTaskControl(TaskContext context)
protected <V,C> TaskContext createTaskContext(Task<V,C> task)
public TaskListenerSupport getTaskListenerSupport()
TaskManager
getTaskListenerSupport
in interface TaskManager
public Iterable<TaskControl> getTasks(TaskPredicate predicate)
TaskManager
getTasks
in interface TaskManager
public TaskControl findTask(TaskPredicate predicate)
findTask
in interface TaskManager
public Future<?> submit(Runnable task)
TaskManager
Runnable
object for execution. Contrary to executing
Task
s this is more lightweight as it does not fire any events
and is not managed by this manager.submit
in interface TaskManager
public <T> Future<T> submit(Callable<T> task)
TaskManager
Callable
object for execution. Contrary to executing
Task
s this is more lightweight as it does not fire any events
and is not managed by this manager.submit
in interface TaskManager
public TaskControl getTask(String contextId)
TaskManager
getTask
in interface TaskManager