public static interface InterceptingExecutorService.Decorator
Modifier and Type | Interface and Description |
---|---|
static class |
InterceptingExecutorService.Decorator.Builder
Builds a decorator, composing up to three functional interfaces.
|
Modifier and Type | Method and Description |
---|---|
default void |
afterFailed(ExecutorService delegate,
Callable<?> task,
Throwable cause)
Performs actions after the given task has failed.
|
default <T> void |
afterFinish(ExecutorService delegate,
Callable<T> task,
T result)
Performs actions after the given task has completed successfully.
|
static InterceptingExecutorService.Interceptor |
asInterceptor(List<? extends InterceptingExecutorService.Decorator> decorators)
Converts a list of decorators into a single interceptor.
|
default void |
beforeStart(ExecutorService delegate,
Callable<?> task)
Performs actions before the given task.
|
static InterceptingExecutorService.Decorator.Builder |
builder()
Returns a new builder, for creating a decorator from simple lambda expressions.
|
default void beforeStart(ExecutorService delegate, Callable<?> task)
task.call()
.delegate
- the underlying executor that is executing the tasktask
- the task that is runningdefault <T> void afterFinish(ExecutorService delegate, Callable<T> task, T result)
delegate
- the underlying executor that is executing the tasktask
- the task that ranresult
- the result produced by the taskdefault void afterFailed(ExecutorService delegate, Callable<?> task, Throwable cause)
delegate
- the underlying executor that is executing the tasktask
- the task that failedcause
- the cause of failurestatic InterceptingExecutorService.Decorator.Builder builder()
static InterceptingExecutorService.Interceptor asInterceptor(List<? extends InterceptingExecutorService.Decorator> decorators)
Execution of the task is short-circuited if a decorator throws an exception from its
beforeStart(java.util.concurrent.ExecutorService, java.util.concurrent.Callable<?>)
action. In such an event, subsequent decorators are
skipped. For every invocation of beforeStart(java.util.concurrent.ExecutorService, java.util.concurrent.Callable<?>)
, either afterFinish(java.util.concurrent.ExecutorService, java.util.concurrent.Callable<T>, T)
or
afterFailed(java.util.concurrent.ExecutorService, java.util.concurrent.Callable<?>, java.lang.Throwable)
will be invoked. So, if a decorator throws an exception,
short-circuiting task execution, any decorators already invoked will have their
afterFailed(java.util.concurrent.ExecutorService, java.util.concurrent.Callable<?>, java.lang.Throwable)
action invoked.
decorators
- a list of decorators