Class ContextPropagatingExecutorService
java.lang.Object
io.micronaut.context.propagation.instrument.execution.ContextPropagatingExecutorService
- All Implemented Interfaces:
InstrumentedExecutor
,InstrumentedExecutorService
,RunnableInstrumenter
,Executor
,ExecutorService
- Direct Known Subclasses:
ContextPropagatingScheduledExecutorService
@Internal
public class ContextPropagatingExecutorService
extends Object
implements InstrumentedExecutorService
Wraps
ExecutorService
to instrument it for propagating the PropagatedContext
across threads.- Since:
- 4.9.0
- Author:
- Hauke Lange
-
Constructor Summary
ConstructorsConstructorDescriptionContextPropagatingExecutorService
(ExecutorService target, @Nullable PropagatedContext propagatedContext) -
Method Summary
Modifier and TypeMethodDescriptionImplementors can override to specify the targetExecutorService
.instrument
(Runnable task) Implementors can override to instrument a Runnable.<T> Callable<T>
instrument
(Callable<T> task) Instruments the given callable task.static boolean
isInstrumented
(ExecutorService executorService) Checks if the givenExecutorService
is instrumented withContextPropagatingExecutorService
.static Optional<ExecutorService>
unwrap
(ExecutorService executorService) Unwraps the targetExecutorService
from the givenInstrumentedExecutorService
if it is instrumented withContextPropagatingExecutorService
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.scheduling.instrument.InstrumentedExecutor
execute
Methods inherited from interface io.micronaut.scheduling.instrument.InstrumentedExecutorService
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow, submit, submit, submit
-
Constructor Details
-
ContextPropagatingExecutorService
-
ContextPropagatingExecutorService
public ContextPropagatingExecutorService(ExecutorService target, @Nullable @Nullable PropagatedContext propagatedContext)
-
-
Method Details
-
getTarget
Description copied from interface:InstrumentedExecutorService
Implementors can override to specify the targetExecutorService
.- Specified by:
getTarget
in interfaceInstrumentedExecutor
- Specified by:
getTarget
in interfaceInstrumentedExecutorService
- Returns:
- The target
ExecutorService
-
instrument
Description copied from interface:InstrumentedExecutorService
Instruments the given callable task.- Specified by:
instrument
in interfaceInstrumentedExecutorService
- Type Parameters:
T
- The generic return type- Parameters:
task
- the task to instrument- Returns:
- The callable
-
instrument
Description copied from interface:RunnableInstrumenter
Implementors can override to instrument a Runnable.- Specified by:
instrument
in interfaceRunnableInstrumenter
- Parameters:
task
- The command to instrument- Returns:
- The instrumented runnable
-
unwrap
Unwraps the targetExecutorService
from the givenInstrumentedExecutorService
if it is instrumented withContextPropagatingExecutorService
.- Parameters:
executorService
- The instrumented executor service- Returns:
- The target executor service of the
ContextPropagatingScheduledExecutorService
or empty if not found
-
isInstrumented
Checks if the givenExecutorService
is instrumented withContextPropagatingExecutorService
.- Parameters:
executorService
- The executor service to check- Returns:
- true if it is instrumented, false otherwise
-