public final class ServiceTalkTracingThreadContextMap extends ServiceTalkThreadContextMap
ThreadContext
that provides storage for MDC based upon AsyncContext
that also includes tracing
information in accessors via AsyncContextInMemoryScopeManager
. Due to the read only nature of making the
tracing information available the ThreadContext
map-like interface spirit is not strictly followed. This is
due to the fact that modifier methods (e.g. ServiceTalkThreadContextMap.put(String, String)
, ServiceTalkThreadContextMap.clear()
) will not have any impact
on this class returning tracing information from the accessor methods (e.g. get(String)
). The motivation for
this behavior is to avoid a tight coupling between changes to the tracing storage having to be replicated in this MDC
storage container. The mechanics to orchestrate this add non-negligible complexity/overhead and so this class
provides a trade-off to make the tracing information available in MDC.Constructor and Description |
---|
ServiceTalkTracingThreadContextMap() |
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(java.lang.String key) |
java.lang.String |
get(java.lang.String key) |
protected java.util.Map<java.lang.String,java.lang.String> |
getCopy(java.util.Map<java.lang.String,java.lang.String> storage)
Get a copy of this
ThreadContextMap given the underlying Map storage. |
protected java.util.Map<java.lang.String,java.lang.String> |
getImmutableMapOrNull(java.util.Map<java.lang.String,java.lang.String> storage)
Provide the implementation for
ServiceTalkThreadContextMap.getImmutableMapOrNull() given then underlying Map storage. |
protected org.apache.logging.log4j.util.StringMap |
getReadOnlyContextData(java.util.Map<java.lang.String,java.lang.String> storage)
Create a new read-only
StringMap . |
boolean |
isEmpty() |
clear, getCopy, getImmutableMapOrNull, getReadOnlyContextData, put, putAll, remove, removeAll
@Nullable public java.lang.String get(java.lang.String key)
get
in interface org.apache.logging.log4j.spi.ReadOnlyThreadContextMap
get
in interface org.apache.logging.log4j.spi.ThreadContextMap
get
in class ServiceTalkThreadContextMap
public boolean containsKey(java.lang.String key)
containsKey
in interface org.apache.logging.log4j.spi.ReadOnlyThreadContextMap
containsKey
in interface org.apache.logging.log4j.spi.ThreadContextMap
containsKey
in class ServiceTalkThreadContextMap
protected java.util.Map<java.lang.String,java.lang.String> getCopy(java.util.Map<java.lang.String,java.lang.String> storage)
ServiceTalkThreadContextMap
ThreadContextMap
given the underlying Map
storage.getCopy
in class ServiceTalkThreadContextMap
storage
- the underlying Map
storage.ThreadContextMap
.@Nullable protected java.util.Map<java.lang.String,java.lang.String> getImmutableMapOrNull(java.util.Map<java.lang.String,java.lang.String> storage)
ServiceTalkThreadContextMap
ServiceTalkThreadContextMap.getImmutableMapOrNull()
given then underlying Map
storage.getImmutableMapOrNull
in class ServiceTalkThreadContextMap
storage
- the underlying Map
storage.Map
or null
if empty.public boolean isEmpty()
isEmpty
in interface org.apache.logging.log4j.spi.ReadOnlyThreadContextMap
isEmpty
in interface org.apache.logging.log4j.spi.ThreadContextMap
isEmpty
in class ServiceTalkThreadContextMap
protected org.apache.logging.log4j.util.StringMap getReadOnlyContextData(java.util.Map<java.lang.String,java.lang.String> storage)
ServiceTalkThreadContextMap
StringMap
.getReadOnlyContextData
in class ServiceTalkThreadContextMap
storage
- The underlying storage for this ThreadContextMap
.StringMap
.