public abstract class ManagedTaskListenerTask extends java.lang.Object implements ManagedTaskListener
Modifier and Type | Field and Description |
---|---|
protected java.lang.Object |
delegate |
protected ManagedExecutorService |
executor |
protected java.util.concurrent.Future<?> |
future |
Modifier | Constructor and Description |
---|---|
protected |
ManagedTaskListenerTask(java.lang.Object task) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getDelegate() |
void |
taskAborted(java.util.concurrent.Future<?> future,
ManagedExecutorService executor,
java.lang.Object task,
java.lang.Throwable exception)
Called when a task's Future has been cancelled anytime during the life of a task.
|
void |
taskAborted(java.lang.Throwable skippedException) |
void |
taskDone(java.util.concurrent.Future<?> future,
ManagedExecutorService executor,
java.lang.Object task,
java.lang.Throwable exception)
Called when a submitted task has completed running, either successfully or
failed due to any exception thrown from the task, task being cancelled,
rejected, or aborted.
|
void |
taskStarting(java.util.concurrent.Future<?> future,
ManagedExecutorService executor,
java.lang.Object task)
This method is called before the task is about to start.
|
void |
taskSubmitted(java.util.concurrent.Future<?> future,
ManagedExecutorService executor,
java.lang.Object task)
Called after the task has been submitted to the Executor.
|
protected java.util.concurrent.Future<?> future
protected final java.lang.Object delegate
protected ManagedExecutorService executor
public void taskSubmitted(java.util.concurrent.Future<?> future, ManagedExecutorService executor, java.lang.Object task)
ManagedTaskListener
This event does not indicate that the task has been scheduled for execution.
taskSubmitted
in interface ManagedTaskListener
future
- the Future
instance that was created when the task was submitted.executor
- the executor used to run the associated Future.task
- the task that was submitted.public void taskAborted(java.util.concurrent.Future<?> future, ManagedExecutorService executor, java.lang.Object task, java.lang.Throwable exception)
ManagedTaskListener
Future.isCancelled()
method returns false if the task was aborted through another means other than
Future.cancel(boolean)
.
The exception argument will represent the cause of the cancellation:
CancellationException
if the task was cancelled,
SkippedException
if the task was skipped or
AbortedException
if the task failed to start for another reason.
AbortedException.getCause()
method will return the exception that
caused the task to fail to start.taskAborted
in interface ManagedTaskListener
future
- the Future
instance that was created when the task was submitted.executor
- the executor used to run the associated Future.task
- the task that was submitted.exception
- the cause of the task abort.public void taskDone(java.util.concurrent.Future<?> future, ManagedExecutorService executor, java.lang.Object task, java.lang.Throwable exception)
ManagedTaskListener
taskDone
in interface ManagedTaskListener
future
- the Future
instance that was created when the task was submitted.executor
- the executor used to run the associated Future.task
- the task that was submitted.exception
- if not null, the exception that caused the task to fail.public void taskStarting(java.util.concurrent.Future<?> future, ManagedExecutorService executor, java.lang.Object task)
ManagedTaskListener
taskStarting
in interface ManagedTaskListener
future
- the Future
instance that was created when the task was submitted.executor
- the executor used to run the associated Future.task
- the task that was submitted.public void taskAborted(java.lang.Throwable skippedException)
public java.lang.Object getDelegate()