org.apache.logging.log4j.spi
Interface ThreadContextMap

All Known Implementing Classes:
DefaultThreadContextMap

public interface ThreadContextMap

Service provider interface to implement custom MDC behavior for ThreadContext.


Method Summary
 void clear()
          Clear the context.
 boolean containsKey(String key)
          Determine if the key is in the context.
 String get(String key)
          Get the context identified by the key parameter.
 Map<String,String> getCopy()
          Get a non-null mutable copy of current thread's context Map.
 Map<String,String> getImmutableMapOrNull()
          Return an immutable view on the context Map or null if the context map is empty.
 boolean isEmpty()
          Returns true if the Map is empty.
 void put(String key, String value)
          Put a context value (the o parameter) as identified with the key parameter into the current thread's context map.
 void remove(String key)
          Remove the the context identified by the key parameter.
 

Method Detail

put

void put(String key,
         String value)
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.

Parameters:
key - The key name.
value - The key value.

get

String get(String key)
Get the context identified by the key parameter.

This method has no side effects.

Parameters:
key - The key to locate.
Returns:
The value associated with the key or null.

remove

void remove(String key)
Remove the the context identified by the key parameter.

Parameters:
key - The key to remove.

clear

void clear()
Clear the context.


containsKey

boolean containsKey(String key)
Determine if the key is in the context.

Parameters:
key - The key to locate.
Returns:
True if the key is in the context, false otherwise.

getCopy

Map<String,String> getCopy()
Get a non-null mutable copy of current thread's context Map.

Returns:
a mutable copy of the context.

getImmutableMapOrNull

Map<String,String> getImmutableMapOrNull()
Return an immutable view on the context Map or null if the context map is empty.

Returns:
an immutable context Map or null.

isEmpty

boolean isEmpty()
Returns true if the Map is empty.

Returns:
true if the Map is empty, false otherwise.


Copyright © 1999-2015 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.