Package org.springframework.core.task
Interface TaskDecorator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface TaskDecorator
A callback interface for a decorator to be applied to anyRunnable
about to be executed.Note that such a decorator is not necessarily being applied to the user-supplied
Runnable
/Callable
but rather to the actual execution callback (which may be a wrapper around the user-supplied task).The primary use case is to set some execution context around the task's invocation, or to provide some monitoring/statistics for task execution.
NOTE: Exception handling in
TaskDecorator
implementations may be limited. Specifically in case of aFuture
-based operation, the exposedRunnable
will be a wrapper which does not propagate any exceptions from itsrun
method.
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Runnable
decorate(Runnable runnable)
Decorate the givenRunnable
, returning a potentially wrappedRunnable
for actual execution, internally delegating to the originalRunnable.run()
implementation.
Method Detail
decorate
Runnable decorate(Runnable runnable)
Decorate the givenRunnable
, returning a potentially wrappedRunnable
for actual execution, internally delegating to the originalRunnable.run()
implementation.- Parameters:
runnable
- the originalRunnable
- Returns:
- the decorated
Runnable