Class DefaultThreadContextMap

  • All Implemented Interfaces:
    ThreadContextMap


    public class DefaultThreadContextMap
    extends Object
    implements ThreadContextMap
    The actual ThreadContext Map. A new ThreadContext Map is created each time it is updated and the Map stored is always immutable. This means the Map can be passed to other threads without concern that it will be updated. Since it is expected that the Map will be passed to many more log events than the number of keys it contains the performance should be much better than if the Map was copied for each event.
    • Field Summary

      Fields

      Modifier and Type Field and Description
      static String INHERITABLE_MAP
      Property name ("isThreadContextMapInheritable" ) for selecting InheritableThreadLocal (value "true") or plain ThreadLocal (value is not "true") in the implementation.
    • 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
    • Constructor Detail

      • DefaultThreadContextMap

        public DefaultThreadContextMap(boolean useMap)
    • Method Detail

      • put

        public void put(String key,
                        String value)
        Description copied from interface: ThreadContextMap
        Put 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.
      • get

        public String get(String key)
        Description copied from interface: ThreadContextMap
        Get the context identified by the key parameter.

        This method has no side effects.

        Specified by:
        get in interface  ThreadContextMap
        Parameters:
        key - The key to locate.
        Returns:
        The value associated with the key or null.
      • remove

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

        public void clear()
        Description copied from interface: ThreadContextMap
        Clear the context.
      • containsKey

        public boolean containsKey(String key)
        Description copied from interface: ThreadContextMap
        Determine if the key is in the context.
        Specified by:
        containsKey in interface  ThreadContextMap
        Parameters:
        key - The key to locate.
        Returns:
        True if the key is in the context, false otherwise.
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: ThreadContextMap
        Returns true if the Map is empty.
        Specified by:
        isEmpty in interface  ThreadContextMap
        Returns:
        true if the Map is empty, false otherwise.
      • toString

        public String toString()
      • hashCode

        public int hashCode()
      • equals

        public boolean equals(Object obj)