ContextAccessor and
ThreadLocalAccessor.
A static instance is available via getInstance(). It is intended to be
initialized on startup, and to be aware of all available accessors, as many as
possible. The means to control what context gets propagated is in
ContextSnapshot, which filters context values by key.
| Modifier and Type | Field and Description |
|---|---|
| private final List | |
| private static final ContextRegistry | |
| private final List | |
| private final List | |
| private final List |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public ContextAccessor | getContextAccessorForRead(Object
the context to read from context)Find a |
| public ContextAccessor | getContextAccessorForWrite(Object
the context to write to context)Return a |
| public List | |
| public static ContextRegistry | |
| public List | |
| public ContextRegistry | |
| public ContextRegistry | loadThreadLocalAccessors()
Load |
| public ContextRegistry | |
| public < the type of value stored in the ThreadLocal V> ContextRegistry | Returns: the same registry instancethe key, ThreadLocal<V> key to associate with the
ThreadLocal valuethe underlying threadLocal)ThreadLocalRegister a |
| public < the type of value stored in the ThreadLocal V> ContextRegistry | Returns: the same registry instancethe key, Supplier<V> key to associate with the
ThreadLocal valuecallback to use for getting the value getSupplier, Consumer<V> callback to use for setting the value setConsumer, Runnable callback to use for resetting the value resetTask)Register a |
| public ContextRegistry | Returns: the same registry instancethe accessor to register accessor)Register a |
| public boolean | Returns: true when accessor got successfully removedaccessor instance to remove accessorToRemove)Removes a registered |
| public boolean | Returns: true when accessor got successfully removedunder which the accessor got registered key)Removes a |
| public String |
| contextAccessors | back to summary |
|---|---|
| private final List<ContextAccessor<?, ?>> contextAccessors | |
| instance | back to summary |
|---|---|
| private static final ContextRegistry instance | |
| readOnlyContextAccessors | back to summary |
|---|---|
| private final List<ContextAccessor<?, ?>> readOnlyContextAccessors | |
| readOnlyThreadLocalAccessors | back to summary |
|---|---|
| private final List<ThreadLocalAccessor<?>> readOnlyThreadLocalAccessors | |
| threadLocalAccessors | back to summary |
|---|---|
| private final List<ThreadLocalAccessor<?>> threadLocalAccessors | |
| ContextRegistry | back to summary |
|---|---|
| public ContextRegistry() | |
| getContextAccessorForRead | back to summary |
|---|---|
| public ContextAccessor Find a
| |
| getContextAccessorForWrite | back to summary |
|---|---|
| public ContextAccessor Return a
| |
| getContextAccessors | back to summary |
|---|---|
| public List Return a read-only list of registered | |
| getInstance | back to summary |
|---|---|
| public static ContextRegistry getInstance() Return a global Note The global instance should be initialized on startup to
ensure it has the ability to propagate to and from different types of context
throughout the application. The registry itself is not intended to as a mechanism
to control what gets propagated. It is in | |
| getThreadLocalAccessors | back to summary |
|---|---|
| public List Return a read-only list of registered | |
| loadContextAccessors | back to summary |
|---|---|
| public ContextRegistry loadContextAccessors() Load
Note that existing registrations of the same | |
| loadThreadLocalAccessors | back to summary |
|---|---|
| public ContextRegistry loadThreadLocalAccessors() Load
Note that existing registrations with the same | |
| registerContextAccessor | back to summary |
|---|---|
| public ContextRegistry registerContextAccessor(ContextAccessor<?, ?> accessor) Register a | |
| registerThreadLocalAccessor | back to summary |
|---|---|
| public <V> ContextRegistry registerThreadLocalAccessor(String key, ThreadLocal<V> threadLocal) Register a
| |
| registerThreadLocalAccessor | back to summary |
|---|---|
| public <V> ContextRegistry registerThreadLocalAccessor(String key, Supplier<V> getSupplier, Consumer<V> setConsumer, Runnable resetTask) Register a
| |
| registerThreadLocalAccessor | back to summary |
|---|---|
| public ContextRegistry registerThreadLocalAccessor(ThreadLocalAccessor<?> accessor) Register a
| |
| removeContextAccessor | back to summary |
|---|---|
| public boolean removeContextAccessor(ContextAccessor<?, ?> accessorToRemove) Removes a registered
| |
| removeThreadLocalAccessor | back to summary |
|---|---|
| public boolean removeThreadLocalAccessor(String key) Removes a
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |