public class TestMDCAdapter extends BasicMDCAdapter
| Constructor and Description |
|---|
TestMDCAdapter() |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
String |
get(String key) |
boolean |
getAllowNullValues()
Whether null values are allowed in the MDC.
|
Map<String,String> |
getCopyOfContextMap()
Return a copy of the current thread's context map.
|
boolean |
getEnable()
Whether the MDC functionality is enabled.
|
boolean |
getInherit()
Whether child threads inherit a copy of the MDC from its parent thread.
|
static TestMDCAdapter |
getInstance()
Access the current MDC adapter.
|
boolean |
getReturnNullCopyWhenMdcNotSet()
Whether
getCopyOfContextMap() returns null when no values have been set. |
void |
put(String key,
String val) |
void |
remove(String key) |
void |
restoreOptions()
Reset the options to values defined by the static configuration.
|
void |
setAllowNullValues(boolean allowNullValues)
Define whether null values are allowed in the MDC.
|
void |
setContextMap(Map<String,String> contextMap) |
void |
setEnable(boolean enable)
Enable the MDC functionality for all threads.
|
void |
setInherit(boolean inherit)
Define whether child threads inherit a copy of the MDC from its parent thread.
|
void |
setReturnNullCopyWhenMdcNotSet(boolean returnNullCopyWhenMdcNotSet)
Define whether
getCopyOfContextMap() returns null when no values have been set. |
clearDequeByKey, getCopyOfDequeByKey, getKeys, popByKey, pushByKeypublic void put(String key, String val)
put in interface MDCAdapterput in class BasicMDCAdapterpublic String get(String key)
get in interface MDCAdapterget in class BasicMDCAdapterpublic void remove(String key)
remove in interface MDCAdapterremove in class BasicMDCAdapterpublic void clear()
clear in interface MDCAdapterclear in class BasicMDCAdapterpublic Map<String,String> getCopyOfContextMap()
null is returned if
setEnable, or
setReturnNullCopyWhenMdcNotSet,
and put has not been called.
getCopyOfContextMap in interface MDCAdaptergetCopyOfContextMap in class BasicMDCAdapterpublic void setContextMap(Map<String,String> contextMap)
setContextMap in interface MDCAdaptersetContextMap in class BasicMDCAdapterpublic void setEnable(boolean enable)
enable - Whether to enable the MDC functionality. The default value is true.public void setInherit(boolean inherit)
Thread is constructed. This affects all threads.inherit - Whether to enable inheritance. The default value is false.public void setAllowNullValues(boolean allowNullValues)
allowNullValues - Whether to allow nulls. The default value is true.public void setReturnNullCopyWhenMdcNotSet(boolean returnNullCopyWhenMdcNotSet)
getCopyOfContextMap() returns null when no values have been set.
This affects all threads.returnNullCopyWhenMdcNotSet - Whether to return null. The default value is false.
If false, an empty map is returned instead.public boolean getEnable()
public boolean getInherit()
public boolean getAllowNullValues()
public boolean getReturnNullCopyWhenMdcNotSet()
getCopyOfContextMap() returns null when no values have been set.public void restoreOptions()
setEnable(boolean), setInherit(boolean), setAllowNullValues(boolean), and setReturnNullCopyWhenMdcNotSet(boolean).public static TestMDCAdapter getInstance()
Copyright © 2023. All rights reserved.