Interface TaskWrapper
-
public interface TaskWrapper
ATaskWrapper
is a facility to wrapRunnable
background tasks before they are passed to theExecutor
. Use-cases include injection of thread-local context variables, or more fine-granular error handling.All sub-queries sent by the federation engine that make use of the concurrency infrastructure (e.g.
ControlledWorkerScheduler
) are passing this wrapper.The concrete implementation can be configured using
FedXConfig.withTaskWrapper(TaskWrapper)
.- Author:
- Andreas Schwarte
- See Also:
ControlledWorkerScheduler
,FedXConfig.withTaskWrapper(TaskWrapper)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Runnable
wrap(Runnable runnable)
Wrap the givenRunnable
and add custom logic.<T> Callable<T>
wrap(Callable<T> callable)
Wrap the givenCallable
and add custom logic.
-
-
-
Method Detail
-
wrap
Runnable wrap(Runnable runnable)
Wrap the givenRunnable
and add custom logic.Use cases include injection of state into the thread-local context, or more fine granular error handling.
Note that when modifying state in
ThreadLocal
it must be reset properly in a try/finally block.- Parameters:
runnable
- the task as generated by the FedX engine- Returns:
- the wrapped
Runnable
-
wrap
<T> Callable<T> wrap(Callable<T> callable)
Wrap the givenCallable
and add custom logic.Use cases include injection of state into the thread-local context, or more fine granular error handling.
Note that when modifying state in
ThreadLocal
it must be reset properly in a try/finally block.- Parameters:
callable
- the task as generated by the FedX engine- Returns:
- the wrapped
Callable
-
-