Top Description Methods
org.springframework.core.task

public Interface TaskDecorator

Known Direct Implementers
org.springframework.core.task.support.CompositeTaskDecorator, org.springframework.core.task.support.ContextPropagatingTaskDecorator
Annotations
@FunctionalInterface

A callback interface for a decorator to be applied to any Runnable 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 a Future-based operation, the exposed Runnable will be a wrapper which does not propagate any exceptions from its run method.

Author
Juergen Hoeller
Since
4.3
See Also
TaskExecutor#execute(Runnable), SimpleAsyncTaskExecutor#setTaskDecorator, org.springframework.core.task.support.TaskExecutorAdapter#setTaskDecorator

Method Summary

Modifier and TypeMethod and Description
public Runnable

Returns:

the decorated Runnable
decorate
(Runnable
the original Runnable
runnable
)

Decorate the given Runnable, returning a potentially wrapped Runnable for actual execution, internally delegating to the original Runnable#run() implementation.

Method Detail

decorateback to summary
public Runnable decorate(Runnable runnable)

Decorate the given Runnable, returning a potentially wrapped Runnable for actual execution, internally delegating to the original Runnable#run() implementation.

Parameters
runnable:Runnable

the original Runnable

Returns:Runnable

the decorated Runnable