ThreadLocal and other types of context and exposes
methods to propagate those values.
Use ContextSnapshotFactory#builder() to configure a factory to work with
snapshots.
Implementations are disallowed to store null values. If a ThreadLocal
is not set, or it's value is null, there is no way of distinguishing one from
the other. In such a case, the ContextSnapshot simply must not contain a
capture for the particular ThreadLocal. Implementations should filter out any
null values after reading into the storage also obtained by calling
ContextAccessor#readValues(Object, Predicate, Map), and should likewise ignore
null values from ContextAccessor#readValue(Object, Object).
| Modifier and Type | Class and Description |
|---|---|
| public static interface | ContextSnapshot.Scope
An object to use to reset |
| Modifier and Type | Method and Description |
|---|---|
| public static ContextSnapshot | Returns: a snapshot with saved context valuesone more context objects to extract values from contexts)
Deprecated
use
Capture values from ContextSnapshotFactory#captureAll(Object. on a factory
obtained via a ContextSnapshotFactory#builder().
ThreadLocal and from other context objects using all
accessors from the global ContextRegistry
instance.
|
| public static ContextSnapshot | Returns: a snapshot with saved context valuesthe registry to use registry, Object... one more context objects to extract values from contexts)
Deprecated
use
Capture values from ContextSnapshotFactory#captureAll(Object. on a factory
obtained via a ContextSnapshotFactory#builder() combined with
ContextSnapshotFactory..
ThreadLocal and from other context objects using all
accessors from the global ContextRegistry
instance.
|
| public static ContextSnapshot | Returns: a snapshot with saved context valuespredicate for context value keys keyPredicate, ContextRegistry the registry with the accessors to use registry, Object... one more context objects to extract values from contexts)
Deprecated
use
Variant of ContextSnapshotFactory#captureAll(Object. on a factory
obtained via a ContextSnapshotFactory#builder() and configure
ContextSnapshotFactory. and
ContextSnapshotFactory..
captureAll(Object.
|
| public static ContextSnapshot | Returns: the createdContextSnapshotthe context to read values from context)
Deprecated
use
Create a ContextSnapshotFactory#captureFrom(Object. on a factory
obtained via a ContextSnapshotFactory#builder().
ContextSnapshot by reading values from the given context object.
|
| public static ContextSnapshot | Returns: the createdContextSnapshotthe context to read values from context, ContextRegistry the registry to use registry)
Deprecated
use
Create a ContextSnapshotFactory#captureFrom(Object. on a factory
obtained via a ContextSnapshotFactory#builder() combined with
ContextSnapshotFactory..
ContextSnapshot by reading values from the given context object.
|
| public static ContextSnapshot | Returns: the createdContextSnapshotthe context to read values from context, Predicate<Object> predicate for context value keys keyPredicate, ContextRegistry the registry to use registry)
Deprecated
use
Create a ContextSnapshotFactory#captureFrom(Object. on a factory
obtained via a ContextSnapshotFactory#builder() and configure
ContextSnapshotFactory. and
ContextSnapshotFactory..
ContextSnapshot by reading values from the given context object.
|
| public static ContextSnapshot. | Returns: an object that can be used to resetThreadLocal values at the end
of the context scope, either removing them or restoring their previous values, if
any.the source context to read values from sourceContext)
Deprecated
use
Variant of ContextSnapshotFactory#setThreadLocalsFrom(Object, String. with no keys
on a factory obtained via a ContextSnapshotFactory#builder().
setThreadLocalsFrom(Object, String.
|
| public static ContextSnapshot. | Returns: an object that can be used to resetThreadLocal values at the end
of the context scope, either removing them or restoring their previous values, if
any.the source context to read values from sourceContext, ContextRegistry the registry with the accessors to use contextRegistry)
Deprecated
use
Variant of ContextSnapshotFactory#setThreadLocalsFrom(Object, String. with no keys
on a factory obtained via a ContextSnapshotFactory#builder() combined with
ContextSnapshotFactory..
setThreadLocalsFrom(Object, String.
|
| public ContextSnapshot. | Returns: an object that can be used to resetThreadLocal values at the end
of the context scope, either removing them or restoring their previous values, if
any.Set |
| public ContextSnapshot. | Returns: an object that can be used to resetThreadLocal values at the end
of the context scope, either removing them or restoring their previous values, if
any.selects keys for use when setting keyPredicate)ThreadLocal valuesVariant of |
| public static ContextSnapshot. | Returns: an object that can be used to resetThreadLocal values at the end
of the context scope, either removing them or restoring their previous values, if
any.the source context to read values from sourceContext, String... the keys of the values to read (at least one key must be passed) keys)
Deprecated
use
Read the values specified by from the given source context, and if found, use them
to set ContextSnapshotFactory#setThreadLocalsFrom(Object, String. on a factory
obtained via a ContextSnapshotFactory#builder().
ThreadLocal values.
|
| public static ContextSnapshot. | Returns: an object that can be used to resetThreadLocal values at the end
of the context scope, either removing them or restoring their previous values, if
any.the source context to read values from sourceContext, ContextRegistry the registry with the accessors to use contextRegistry, String... the keys of the values to read (at least one key must be passed) keys)
Deprecated
use
Variant of ContextSnapshotFactory#setThreadLocalsFrom(Object, String. on a factory
obtained via a ContextSnapshotFactory#builder() combined with
ContextSnapshotFactory..
setThreadLocalsFrom(Object, String.
|
| public < the type of the target context C> C | Returns: a context, possibly a new instance, with the written valuesthe context to write to context)Update the given context with all snapshot values. |
| public < the type of the target context C> C | Returns: a context, possibly a new instance, with the written valuesthe context to write to context, Predicate<Object> predicate for context value keys keyPredicate)Variant of |
| public default Runnable | |
| public default < the type of value produced by the T> CallableCallable | |
| public default < the type of value produced by the T> ConsumerCallable | |
| public default Executor | Returns: wrapped instancethe executor to instrument executor)Return a new |
| captureAll | back to summary |
|---|---|
| public static ContextSnapshot captureAll(Object... contexts)
Deprecated use Capture values from
| |
| captureAll | back to summary |
|---|---|
| public static ContextSnapshot captureAll(ContextRegistry registry, Object... contexts)
Deprecated use Capture values from
| |
| captureAllUsing | back to summary |
|---|---|
| public static ContextSnapshot captureAllUsing(Predicate<Object> keyPredicate, ContextRegistry registry, Object... contexts)
Deprecated use Variant of
| |
| captureFrom | back to summary |
|---|---|
| public static ContextSnapshot captureFrom(Object context)
Deprecated use Create a
| |
| captureFrom | back to summary |
|---|---|
| public static ContextSnapshot captureFrom(Object context, ContextRegistry registry)
Deprecated use Create a
| |
| captureFrom | back to summary |
|---|---|
| public static ContextSnapshot captureFrom(Object context, Predicate<Object> keyPredicate, ContextRegistry registry)
Deprecated use Create a
| |
| setAllThreadLocalsFrom | back to summary |
|---|---|
| public static ContextSnapshot. Deprecated use
Variant of
| |
| setAllThreadLocalsFrom | back to summary |
|---|---|
| public static ContextSnapshot. Deprecated use
Variant of
| |
| setThreadLocals | back to summary |
|---|---|
| public ContextSnapshot. Set
| |
| setThreadLocals | back to summary |
|---|---|
| public ContextSnapshot. Variant of
| |
| setThreadLocalsFrom | back to summary |
|---|---|
| public static ContextSnapshot. Deprecated use
Read the values specified by from the given source context, and if found, use them
to set
| |
| setThreadLocalsFrom | back to summary |
|---|---|
| public static ContextSnapshot. Deprecated use
Variant of
| |
| updateContext | back to summary |
|---|---|
| public <C> C updateContext(C context) Update the given context with all snapshot values.
| |
| updateContext | back to summary |
|---|---|
| public <C> C updateContext(C context, Predicate<Object> keyPredicate) Variant of | |
| wrap | back to summary |
|---|---|
| public default Runnable wrap(Runnable runnable) Return a new | |
| wrap | back to summary |
|---|---|
| public default <T> Callable Return a new | |
| wrap | back to summary |
|---|---|
| public default <T> Consumer Return a new | |
| wrapExecutor | back to summary |
|---|---|
| public default Executor wrapExecutor(Executor executor) Return a new
| |
ThreadLocal values at the end of a context scope.
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Redeclares java. ThreadLocal values, either removing them or restoring their
previous values, if any.
|
| close | back to summary |
|---|---|
| public void close() Redeclares java. Reset
| |