Provide custom BackgroundExecutorWrapper to pass thread locals

(cherry picked from commit 336accf447)
This commit is contained in:
Noemi Szemenyei
2022-03-11 13:31:50 +01:00
parent 75662aac5c
commit 3c7555de36
8 changed files with 307 additions and 50 deletions
@@ -0,0 +1,23 @@
package io.ebean.config;
import java.util.concurrent.Callable;
/**
* BackgroundExecutorWrapper that can be used to wrap tasks that are sent to background (i.e. an other thread).
* It should copy all neccessary thread-local variables. See {@link MdcBackgroundExecutorWrapper} for implementation details.
*
* @author Roland Praml, FOCONIS AG
*/
public interface BackgroundExecutorWrapper {
/**
* Wrap the task with MDC context if defined.
*/
<T> Callable<T> wrap(Callable<T> task);
/**
* Wrap the task with MDC context if defined.
*/
Runnable wrap(Runnable task);
}