SortedArrayStringMap-based implementation of the ThreadContextMap interface that attempts not to
create temporary objects. Adding and removing key-value pairs will not create temporary objects.
This implementation does not make a copy of its contents on every operation, so this data structure cannot be passed to log events. Instead, client code needs to copy the contents when interacting with another thread.
| Modifier and Type | Field and Description |
|---|---|
| protected static final int | DEFAULT_INITIAL_CAPACITY
The default initial capacity. |
| public static final String | INHERITABLE_MAP
Property name ( ) for selecting |
| private static volatile boolean | |
| private static volatile int | |
| protected final ThreadLocal | |
| protected static final String | PROPERTY_NAME_INITIAL_CAPACITY
System property name that can be used to control the data structure's initial capacity. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Implements org. Clears the context. |
| public boolean | containsKey(final String
The key to locate. key)Implements org. Determines if the key is in the context. |
| protected StringMap | Returns: an implementation of theStringMap used to back this thread context mapReturns an implementation of the |
| protected StringMap | Returns: an implementation of theStringMap used to back this thread context mapthe key-value pairs to initialize the returned context data with original)Returns an implementation of the |
| private ThreadLocal | |
| public boolean | equals(final Object
the reference object with which to compare. obj)Overrides java. Indicates whether some other object is "equal to" this one. |
| public String | get(final String
The key to locate. key)Implements org. Gets the context identified by the |
| public Map | getCopy()
Implements org. Gets a non- |
| public Map | getImmutableMapOrNull()
Implements org. Returns an immutable view on the context Map or |
| public StringMap | getReadOnlyContextData()
Implements org. Returns the context data for reading. |
| private StringMap | |
| public <V> V | getValue(final String
the key whose value to return key)Implements org. Returns the Object value for the specified key, or |
| public int | |
| pack-priv static void | |
| public boolean | isEmpty()
Implements org. Returns true if the Map is empty. |
| public void | put(final String
The key name. key, final String The key value. value)Implements org. Puts a context value (the |
| public void | putAll(final Map<String, String>
The map. values)Implements org. Puts all given context map entries into the current thread's context map. |
| public <V> void | putAllValues(final Map<String, V>
the map of key-value pairs to add values)Implements org. Puts all given key-value pairs into the collection. |
| public void | putValue(final String
the key to add or remove. Keys may be key, final Object null.the value to add. Values may be value)null.Implements org. Puts the specified key-value pair into the collection. |
| public void | remove(final String
The key to remove. key)Implements org. Removes the context identified by the |
| public void | removeAll(final Iterable<String>
The keys. keys)Implements org. Removes all given context map keys from the current thread's context map. |
| public String |
| DEFAULT_INITIAL_CAPACITY | back to summary |
|---|---|
| protected static final int DEFAULT_INITIAL_CAPACITY The default initial capacity. | |
| INHERITABLE_MAP | back to summary |
|---|---|
| public static final String INHERITABLE_MAP Property name ( ) for selecting | |
| inheritableMap | back to summary |
|---|---|
| private static volatile boolean inheritableMap | |
| initialCapacity | back to summary |
|---|---|
| private static volatile int initialCapacity | |
| localMap | back to summary |
|---|---|
| protected final ThreadLocal<StringMap> localMap | |
| PROPERTY_NAME_INITIAL_CAPACITY | back to summary |
|---|---|
| protected static final String PROPERTY_NAME_INITIAL_CAPACITY System property name that can be used to control the data structure's initial capacity. | |
| GarbageFreeSortedArrayThreadContextMap | back to summary |
|---|---|
| public GarbageFreeSortedArrayThreadContextMap() | |
| clear | back to summary |
|---|---|
| public void clear() Implements org. Doc from org. Clears the context.
| |
| containsKey | back to summary |
|---|---|
| public boolean containsKey(final String key) Implements org. Doc from org. Determines if the key is in the context. | |
| createStringMap | back to summary |
|---|---|
| protected StringMap createStringMap() Returns an implementation of the Subclasses may override.
| |
| createStringMap | back to summary |
|---|---|
| protected StringMap createStringMap(final ReadOnlyStringMap original) Returns an implementation of the Subclasses may override.
| |
| createThreadLocalMap | back to summary |
|---|---|
| private ThreadLocal | |
| equals | back to summary |
|---|---|
| public boolean equals(final Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| get | back to summary |
|---|---|
| public String get(final String key) Implements org. Doc from org. Gets the context identified by the This method has no side effects. | |
| getCopy | back to summary |
|---|---|
| public Map Implements org. Doc from org. Gets a non- | |
| getImmutableMapOrNull | back to summary |
|---|---|
| public Map Implements org. Doc from org. Returns an immutable view on the context Map or | |
| getReadOnlyContextData | back to summary |
|---|---|
| public StringMap getReadOnlyContextData() Implements org. Doc from org. Returns the context data for reading. Note that regardless of whether the returned context data has been frozen (made read-only) or not, callers should not attempt to modify the returned data structure. Thread safety note:
If this
Otherwise, if this | |
| getThreadLocalMap | back to summary |
|---|---|
| private StringMap getThreadLocalMap() | |
| getValue | back to summary |
|---|---|
| public <V> V getValue(final String key) Implements org. Doc from org. Returns the Object value for the specified key, or | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| init | back to summary |
|---|---|
| pack-priv static void init() Initializes static variables based on system properties. Normally called when this class is initialized by the VM and when Log4j is reconfigured. | |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Implements org. Doc from org. Returns true if the Map is empty.
| |
| put | back to summary |
|---|---|
| public void put(final String key, final String value) Implements org. Doc from org. Puts a context value (the If the current thread does not have a context map it is created as a side effect. | |
| putAll | back to summary |
|---|---|
| public void putAll(final Map<String, String> values) Implements org. Doc from org. Puts all given context map entries into the current thread's context map. If the current thread does not have a context map it is created as a side effect. | |
| putAllValues | back to summary |
|---|---|
| public <V> void putAllValues(final Map<String, V> values) Implements org. Doc from org. Puts all given key-value pairs into the collection. | |
| putValue | back to summary |
|---|---|
| public void putValue(final String key, final Object value) Implements org. Doc from org. Puts the specified key-value pair into the collection. | |
| remove | back to summary |
|---|---|
| public void remove(final String key) Implements org. Doc from org. Removes the context identified by the | |
| removeAll | back to summary |
|---|---|
| public void removeAll(final Iterable<String> keys) Implements org. Doc from org. Removes all given context map keys from the current thread's context map. If the current thread does not have a context map it is created as a side effect. | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |