Package io.micrometer.context
Class ContextScheduledExecutorService
java.lang.Object
io.micrometer.context.ContextExecutorService<ScheduledExecutorService>
io.micrometer.context.ContextScheduledExecutorService
- All Implemented Interfaces:
AutoCloseable,Executor,ExecutorService,ScheduledExecutorService
public final class ContextScheduledExecutorService
extends ContextExecutorService<ScheduledExecutorService>
implements ScheduledExecutorService
Wraps a
ScheduledExecutorService in order to capture context via
ContextSnapshot when a task is submitted, and propagate context to the task
when it is executed.- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescription<V> ScheduledFuture<V> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) static ScheduledExecutorServicewrap(ScheduledExecutorService service) Deprecated.static ScheduledExecutorServicewrap(ScheduledExecutorService service, ContextSnapshotFactory contextSnapshotFactory) Wrap the givenScheduledExecutorServicein order to propagate context to any executed task through the givenContextSnapshotFactory.static ScheduledExecutorServicewrap(ScheduledExecutorService service, Supplier<ContextSnapshot> supplier) Wrap the givenScheduledExecutorServicein order to propagate context to any executed task through the givenContextSnapshotsupplier.Methods inherited from class io.micrometer.context.ContextExecutorService
awaitTermination, capture, execute, getExecutorService, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow, submit, submit, submit, wrap, wrap, wrapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, close, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow, submit, submit, submit
-
Method Details
-
schedule
- Specified by:
schedulein interfaceScheduledExecutorService
-
schedule
- Specified by:
schedulein interfaceScheduledExecutorService
-
scheduleAtFixedRate
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) - Specified by:
scheduleAtFixedRatein interfaceScheduledExecutorService
-
scheduleWithFixedDelay
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) - Specified by:
scheduleWithFixedDelayin interfaceScheduledExecutorService
-
wrap
public static ScheduledExecutorService wrap(ScheduledExecutorService service, ContextSnapshotFactory contextSnapshotFactory) Wrap the givenScheduledExecutorServicein order to propagate context to any executed task through the givenContextSnapshotFactory.This method only captures ThreadLocal value. To work with other types of contexts, use
wrap(ScheduledExecutorService, Supplier).- Parameters:
service- the executorService to wrapcontextSnapshotFactory-ContextSnapshotFactoryfor capturing aContextSnapshotat the point when tasks are scheduled- Returns:
ScheduledExecutorServicewrapper- Since:
- 1.1.2
-
wrap
public static ScheduledExecutorService wrap(ScheduledExecutorService service, Supplier<ContextSnapshot> supplier) Wrap the givenScheduledExecutorServicein order to propagate context to any executed task through the givenContextSnapshotsupplier.Typically, a
ContextSnapshotFactorycan be used to supply the snapshot. In the case that only ThreadLocal values are to be captured, thewrap(ScheduledExecutorService, ContextSnapshotFactory)variant can be used.- Parameters:
service- the executorService to wrapsupplier- supplier for capturing aContextSnapshotat the point when tasks are scheduled- Returns:
ScheduledExecutorServicewrapper
-
wrap
Deprecated.Variant ofwrap(ScheduledExecutorService, Supplier)that usesContextSnapshot.captureAll(Object...)to create the context snapshot.- Parameters:
service- the executorService to wrap- Returns:
ScheduledExecutorServicewrapper
-
wrap(ScheduledExecutorService, Supplier)