Пример #1
0
 /**
  * Setup the cell diagnostic context of the calling thread. Threads created from the calling
  * thread automatically inherit this information. The old diagnostic context is captured and
  * returned.
  */
 public static CDC reset(String cellName, String domainName) {
   CDC cdc = new CDC();
   setMdc(MDC_CELL, cellName);
   setMdc(MDC_DOMAIN, domainName);
   MDC.remove(MDC_SESSION);
   NDC.clear();
   return cdc;
 }
Пример #2
0
 private void apply() {
   setMdc(MDC_DOMAIN, _domain);
   setMdc(MDC_CELL, _cell);
   setMdc(MDC_SESSION, _session);
   if (_ndc == null) {
     NDC.clear();
   } else {
     NDC.set(_ndc);
   }
 }
Пример #3
0
 /** Execute the given runnable within the context of this CDC. */
 public void execute(Runnable r) {
   String session = MDC.get(MDC_SESSION);
   String cell = MDC.get(MDC_CELL);
   String domain = MDC.get(MDC_DOMAIN);
   NDC ndc = NDC.cloneNdc();
   try {
     apply();
     r.run();
   } finally {
     setMdc(MDC_DOMAIN, domain);
     setMdc(MDC_CELL, cell);
     setMdc(MDC_SESSION, session);
     NDC.set(ndc);
   }
 }
Пример #4
0
 /**
  * Setup message related diagnostic context for the calling thread. Adds information about a
  * message to the MDC and NDC.
  *
  * @see clearMessageContext
  */
 public static void setMessageContext(CellMessage envelope) {
   Object session = envelope.getSession();
   NDC.push(getMessageContext(envelope));
   setMdc(MDC_SESSION, (session == null) ? null : session.toString());
 }
Пример #5
0
 /**
  * Sets the session in the MDC for the calling thread.
  *
  * @param session Session identifier.
  */
 public static void setSession(String session) {
   setMdc(MDC_SESSION, session);
 }