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 Details

    • ContextPropagatingExecutorService

      public ContextPropagatingExecutorService(ExecutorService target)
    • ContextPropagatingExecutorService

      public ContextPropagatingExecutorService(ExecutorService target, @Nullable @Nullable io.micronaut.core.propagation.PropagatedContext propagatedContext)
  • Method Details

    • getTarget

      public ExecutorService getTarget()
      Specified by:
      getTarget in interface io.micronaut.scheduling.instrument.InstrumentedExecutor
      Specified by:
      getTarget in interface io.micronaut.scheduling.instrument.InstrumentedExecutorService
    • instrument

      public <T> Callable<T> instrument(Callable<T> task)
      Specified by:
      instrument in interface io.micronaut.scheduling.instrument.InstrumentedExecutorService
    • instrument

      public Runnable instrument(Runnable task)
      Specified by:
      instrument in interface io.micronaut.scheduling.instrument.RunnableInstrumenter
    • unwrap

      public static Optional<ExecutorService> unwrap(ExecutorService executorService)
      Unwraps the target ExecutorService from the given InstrumentedExecutorService if it is instrumented with ContextPropagatingExecutorService.
      Parameters:
      executorService - The instrumented executor service
      Returns:
      The target executor service of the ContextPropagatingScheduledExecutorService or empty if not found
    • isInstrumented

      public static boolean isInstrumented(ExecutorService executorService)
      Checks if the given ExecutorService is instrumented with ContextPropagatingExecutorService.
      Parameters:
      executorService - The executor service to check
      Returns:
      true if it is instrumented, false otherwise