Class ContextPropagatingExecutorService
java.lang.Object
io.micronaut.context.propagation.instrument.execution.ContextPropagatingExecutorService
- All Implemented Interfaces:
InstrumentedExecutor,InstrumentedExecutorService,RunnableInstrumenter,AutoCloseable,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 booleanisInstrumented(ExecutorService executorService) Checks if the givenExecutorServiceis instrumented withContextPropagatingExecutorService.static Optional<ExecutorService> unwrap(ExecutorService executorService) Unwraps the targetExecutorServicefrom the givenInstrumentedExecutorServiceif it is instrumented withContextPropagatingExecutorService.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.concurrent.ExecutorService
closeMethods inherited from interface io.micronaut.scheduling.instrument.InstrumentedExecutor
executeMethods 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:InstrumentedExecutorServiceImplementors can override to specify the targetExecutorService.- Specified by:
getTargetin interfaceInstrumentedExecutor- Specified by:
getTargetin interfaceInstrumentedExecutorService- Returns:
- The target
ExecutorService
-
instrument
Description copied from interface:InstrumentedExecutorServiceInstruments the given callable task.- Specified by:
instrumentin interfaceInstrumentedExecutorService- Type Parameters:
T- The generic return type- Parameters:
task- the task to instrument- Returns:
- The callable
-
instrument
Description copied from interface:RunnableInstrumenterImplementors can override to instrument a Runnable.- Specified by:
instrumentin interfaceRunnableInstrumenter- Parameters:
task- The command to instrument- Returns:
- The instrumented runnable
-
unwrap
Unwraps the targetExecutorServicefrom the givenInstrumentedExecutorServiceif it is instrumented withContextPropagatingExecutorService.- Parameters:
executorService- The instrumented executor service- Returns:
- The target executor service of the
ContextPropagatingScheduledExecutorServiceor empty if not found
-
isInstrumented
Checks if the givenExecutorServiceis instrumented withContextPropagatingExecutorService.- Parameters:
executorService- The executor service to check- Returns:
- true if it is instrumented, false otherwise
-