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)
TaskManagerTaskControl 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 TaskEvents as
appropriate. See TaskListener for details.create in interface TaskManagerprotected <V> TaskControl<V> createTaskControl(TaskContext context)
protected <V,C> TaskContext createTaskContext(Task<V,C> task)
public TaskListenerSupport getTaskListenerSupport()
TaskManagergetTaskListenerSupport in interface TaskManagerpublic Iterable<TaskControl> getTasks(TaskPredicate predicate)
TaskManagergetTasks in interface TaskManagerpublic TaskControl findTask(TaskPredicate predicate)
findTask in interface TaskManagerpublic Future<?> submit(Runnable task)
TaskManagerRunnable object for execution. Contrary to executing
Tasks this is more lightweight as it does not fire any events
and is not managed by this manager.submit in interface TaskManagerpublic <T> Future<T> submit(Callable<T> task)
TaskManagerCallable object for execution. Contrary to executing
Tasks this is more lightweight as it does not fire any events
and is not managed by this manager.submit in interface TaskManagerpublic TaskControl getTask(String contextId)
TaskManagergetTask in interface TaskManager