Class GarbageFreeSortedArrayThreadContextMap

    • Field Detail

      • INHERITABLE_MAP

        public static final String INHERITABLE_MAP
        Property name ("isThreadContextMapInheritable" ) for selecting InheritableThreadLocal (value "true") or plain ThreadLocal (value is not "true") in the implementation.
        See Also:
        Constant Field Values
      • DEFAULT_INITIAL_CAPACITY

        protected static final int DEFAULT_INITIAL_CAPACITY
        The default initial capacity.
        See Also:
        Constant Field Values
      • PROPERTY_NAME_INITIAL_CAPACITY

        protected static final String PROPERTY_NAME_INITIAL_CAPACITY
        System property name that can be used to control the data structure's initial capacity.
        See Also:
        Constant Field Values
    • Constructor Detail

      • GarbageFreeSortedArrayThreadContextMap

        public GarbageFreeSortedArrayThreadContextMap()
    • Method Detail

      • createStringMap

        protected StringMap createStringMap()
        Returns an implementation of the StringMap used to back this thread context map.

        Subclasses may override.

        Returns:
        an implementation of the StringMap used to back this thread context map
      • createStringMap

        protected StringMap createStringMap​(ReadOnlyStringMap original)
        Returns an implementation of the StringMap used to back this thread context map, pre-populated with the contents of the specified context data.

        Subclasses may override.

        Parameters:
        original - the key-value pairs to initialize the returned context data with
        Returns:
        an implementation of the StringMap used to back this thread context map
      • put

        public void put​(String key,
                        String value)
        Description copied from interface: ThreadContextMap
        Puts a context value (the o parameter) as identified with the key parameter into the current thread's context map.

        If the current thread does not have a context map it is created as a side effect.

        Specified by:
        put in interface ThreadContextMap
        Parameters:
        key - The key name.
        value - The key value.
      • putValue

        public void putValue​(String key,
                             Object value)
        Description copied from interface: ObjectThreadContextMap
        Puts the specified key-value pair into the collection.
        Specified by:
        putValue in interface ObjectThreadContextMap
        Parameters:
        key - the key to add or remove. Keys may be null.
        value - the value to add. Values may be null.
      • putAll

        public void putAll​(Map<String,​String> values)
        Description copied from interface: ThreadContextMap2
        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.

        Specified by:
        putAll in interface ThreadContextMap2
        Parameters:
        values - The map.
      • getValue

        public <V> V getValue​(String key)
        Description copied from interface: ObjectThreadContextMap
        Returns the Object value for the specified key, or null if the specified key does not exist in this collection.
        Specified by:
        getValue in interface ObjectThreadContextMap
        Parameters:
        key - the key whose value to return
        Returns:
        the value for the specified key or null
      • remove

        public void remove​(String key)
        Description copied from interface: ThreadContextMap
        Removes the context identified by the key parameter.
        Specified by:
        remove in interface ThreadContextMap
        Parameters:
        key - The key to remove.
      • removeAll

        public void removeAll​(Iterable<String> keys)
        Description copied from interface: CleanableThreadContextMap
        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.

        Specified by:
        removeAll in interface CleanableThreadContextMap
        Parameters:
        keys - The keys.
      • getReadOnlyContextData

        public StringMap getReadOnlyContextData()
        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 ReadOnlyThreadContextMap implements CopyOnWrite, then the returned StringMap can safely be passed to another thread: future changes in the underlying context data will not be reflected in the returned StringMap.

        Otherwise, if this ReadOnlyThreadContextMap does not implement CopyOnWrite, then it is not safe to pass the returned StringMap to another thread because changes in the underlying context may be reflected in the returned object. It is the responsibility of the caller to make a copy to pass to another thread.

        Specified by:
        getReadOnlyContextData in interface ReadOnlyThreadContextMap
        Specified by:
        getReadOnlyContextData in interface ThreadContextMap2
        Returns:
        a StringMap containing context data key-value pairs
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object