Class ContextPropagatingExecutorService
java.lang.Object
io.micronaut.context.propagation.instrument.execution.ContextPropagatingExecutorService
- All Implemented Interfaces:
io.micronaut.scheduling.instrument.InstrumentedExecutor,io.micronaut.scheduling.instrument.InstrumentedExecutorService,io.micronaut.scheduling.instrument.RunnableInstrumenter,Executor,ExecutorService
- Direct Known Subclasses:
ContextPropagatingScheduledExecutorService
@Internal
public class ContextPropagatingExecutorService
extends Object
implements io.micronaut.scheduling.instrument.InstrumentedExecutorService
Wraps
ExecutorService to instrument it for propagating the PropagatedContext
across threads.- Since:
- 4.9.0
-
Constructor Summary
ConstructorsConstructorDescriptionContextPropagatingExecutorService(ExecutorService target, @Nullable io.micronaut.core.propagation.PropagatedContext propagatedContext) -
Method Summary
Modifier and TypeMethodDescriptioninstrument(Runnable task) <T> Callable<T>instrument(Callable<T> 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 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 io.micronaut.core.propagation.PropagatedContext propagatedContext)
-
-
Method Details
-
getTarget
- Specified by:
getTargetin interfaceio.micronaut.scheduling.instrument.InstrumentedExecutor- Specified by:
getTargetin interfaceio.micronaut.scheduling.instrument.InstrumentedExecutorService
-
instrument
- Specified by:
instrumentin interfaceio.micronaut.scheduling.instrument.InstrumentedExecutorService
-
instrument
- Specified by:
instrumentin interfaceio.micronaut.scheduling.instrument.RunnableInstrumenter
-
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
-