Class MDCUtil


  • public class MDCUtil
    extends java.lang.Object
    Helper class for MDC manipulation.
    Since:
    9.0.0
    Version:
    $Revision: 24822 $ $Date: 2022-01-28 15:40:05 -0300 (Fri, 28 Jan 2022) $
    • Constructor Summary

      Constructors 
      Constructor Description
      MDCUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void clear()
      Clears current MDC context.
      static <T> T execWithValues​(java.lang.String key, java.lang.String value, java.util.concurrent.Callable<T> code)
      Executes the given code with the given value in MDC.
      static void execWithValues​(java.util.Map<java.lang.String,​java.lang.String> values, java.lang.Runnable code)
      Executes the given code with the given values in MDC.
      static <T> T execWithValues​(java.util.Map<java.lang.String,​java.lang.String> values, java.util.concurrent.Callable<T> code)
      Executes the given code with the given values in MDC.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MDCUtil

        public MDCUtil()
    • Method Detail

      • execWithValues

        public static void execWithValues​(java.util.Map<java.lang.String,​java.lang.String> values,
                                          java.lang.Runnable code)
        Executes the given code with the given values in MDC.
        Parameters:
        values - the values.
        code - the code.
        Since:
        9.0.0
      • execWithValues

        public static <T> T execWithValues​(java.lang.String key,
                                           java.lang.String value,
                                           java.util.concurrent.Callable<T> code)
        Executes the given code with the given value in MDC.
        Parameters:
        key - the value key.
        value - the value.
        code - the code.
        Returns:
        the code execution return.
        Since:
        9.0.0
      • execWithValues

        public static <T> T execWithValues​(java.util.Map<java.lang.String,​java.lang.String> values,
                                           java.util.concurrent.Callable<T> code)
        Executes the given code with the given values in MDC.
        Parameters:
        values - the values.
        code - the code.
        Returns:
        the code execution return.
        Since:
        9.0.0
      • clear

        public static void clear()
        Clears current MDC context.
        Since:
        9.0.0