亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? ndc.java

?? log4j的源碼
?? JAVA
字號(hào):
/* * Copyright 1999-2005 The Apache Software Foundation. *  * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at *  *      http://www.apache.org/licenses/LICENSE-2.0 *  * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *///      Contributors:      Dan Milstein //                         Ray Millardpackage org.apache.log4j;import java.util.Hashtable;import java.util.Stack;import java.util.Enumeration;import java.util.Vector;import org.apache.log4j.helpers.LogLog;/**   The NDC class implements <i>nested diagnostic contexts</i> as   defined by Neil Harrison in the article "Patterns for Logging   Diagnostic Messages" part of the book "<i>Pattern Languages of   Program Design 3</i>" edited by Martin et al.   <p>A Nested Diagnostic Context, or NDC in short, is an instrument   to distinguish interleaved log output from different sources. Log   output is typically interleaved when a server handles multiple   clients near-simultaneously.   <p>Interleaved log output can still be meaningful if each log entry   from different contexts had a distinctive stamp. This is where NDCs   come into play.   <p><em><b>Note that NDCs are managed on a per thread   basis</b></em>. NDC operations such as {@link #push push}, {@link   #pop}, {@link #clear}, {@link #getDepth} and {@link #setMaxDepth}   affect the NDC of the <em>current</em> thread only. NDCs of other   threads remain unaffected.   <p>For example, a servlet can build a per client request NDC   consisting the clients host name and other information contained in   the the request. <em>Cookies</em> are another source of distinctive   information. To build an NDC one uses the {@link #push push}   operation. Simply put,   <p><ul>     <li>Contexts can be nested.     <p><li>When entering a context, call <code>NDC.push</code>. As a     side effect, if there is no nested diagnostic context for the     current thread, this method will create it.     <p><li>When leaving a context, call <code>NDC.pop</code>.     <p><li><b>When exiting a thread make sure to call {@link #remove     NDC.remove()}</b>.     </ul>      <p>There is no penalty for forgetting to match each   <code>push</code> operation with a corresponding <code>pop</code>,   except the obvious mismatch between the real application context   and the context set in the NDC.   <p>If configured to do so, {@link PatternLayout} and {@link   TTCCLayout} instances automatically retrieve the nested diagnostic   context for the current thread without any user intervention.   Hence, even if a servlet is serving multiple clients   simultaneously, the logs emanating from the same code (belonging to   the same category) can still be distinguished because each client   request will have a different NDC tag.   <p>Heavy duty systems should call the {@link #remove} method when   leaving the run method of a thread. This ensures that the memory   used by the thread can be freed by the Java garbage   collector. There is a mechanism to lazily remove references to dead   threads. In practice, this means that you can be a little sloppy   and sometimes forget to call {@link #remove} before exiting a   thread.      <p>A thread may inherit the nested diagnostic context of another   (possibly parent) thread using the {@link #inherit inherit}   method. A thread may obtain a copy of its NDC with the {@link   #cloneStack cloneStack} method and pass the reference to any other   thread, in particular to a child.      @author Ceki G&uuml;lc&uuml;   @since 0.7.0  */ public class NDC {  // The synchronized keyword is not used in this class. This may seem  // dangerous, especially since the class will be used by  // multiple-threads. In particular, all threads share the same  // hashtable (the "ht" variable). This is OK since java hashtables  // are thread safe. Same goes for Stacks.  // More importantly, when inheriting diagnostic contexts the child  // thread is handed a clone of the parent's NDC.  It follows that  // each thread has its own NDC (i.e. stack).  static Hashtable ht = new Hashtable();  static int pushCounter = 0; // the number of times push has been called                              // after the latest call to lazyRemove  // The number of times we allow push to be called before we call lazyRemove  // 5 is a relatively small number. As such, lazyRemove is not called too  // frequently. We thus avoid the cost of creating an Enumeration too often.  // The higher this number, the longer is the avarage period for which all  // logging calls in all threads are blocked.  static final int REAP_THRESHOLD = 5;    // No instances allowed.  private NDC() {}    /**   *   Get NDC stack for current thread.   *   @return NDC stack for current thread.   */  private static Stack getCurrentStack() {      if (ht != null) {          return (Stack) ht.get(Thread.currentThread());      }      return null;  }  /**     Clear any nested diagnostic information if any. This method is     useful in cases where the same thread can be potentially used     over and over in different unrelated contexts.     <p>This method is equivalent to calling the {@link #setMaxDepth}     method with a zero <code>maxDepth</code> argument.          @since 0.8.4c */  public  static  void clear() {    Stack stack = getCurrentStack();        if(stack != null)       stack.setSize(0);      }    /**     Clone the diagnostic context for the current thread.     <p>Internally a diagnostic context is represented as a stack.  A     given thread can supply the stack (i.e. diagnostic context) to a     child thread so that the child can inherit the parent thread's     diagnostic context.     <p>The child thread uses the {@link #inherit inherit} method to     inherit the parent's diagnostic context.          @return Stack A clone of the current thread's  diagnostic context.  */  public  static  Stack cloneStack() {    Stack stack = getCurrentStack();    if(stack == null)      return null;    else {      return (Stack) stack.clone();    }  }    /**     Inherit the diagnostic context of another thread.     <p>The parent thread can obtain a reference to its diagnostic     context using the {@link #cloneStack} method.  It should     communicate this information to its child so that it may inherit     the parent's diagnostic context.     <p>The parent's diagnostic context is cloned before being     inherited. In other words, once inherited, the two diagnostic     contexts can be managed independently.          <p>In java, a child thread cannot obtain a reference to its     parent, unless it is directly handed the reference. Consequently,     there is no client-transparent way of inheriting diagnostic     contexts. Do you know any solution to this problem?     @param stack The diagnostic context of the parent thread.  */  public  static  void inherit(Stack stack) {    if(stack != null)      ht.put(Thread.currentThread(), stack);  }  /**     <font color="#FF4040"><b>Never use this method directly, use the {@link     org.apache.log4j.spi.LoggingEvent#getNDC} method instead</b></font>.  */  static  public  String get() {    Stack s = getCurrentStack();    if(s != null && !s.isEmpty())       return ((DiagnosticContext) s.peek()).fullMessage;    else      return null;  }    /**   * Get the current nesting depth of this diagnostic context.   *   * @see #setMaxDepth   * @since 0.7.5   */  public  static  int getDepth() {    Stack stack = getCurrentStack();              if(stack == null)      return 0;    else      return stack.size();        }  private  static  void lazyRemove() {    if (ht == null) return;         // The synchronization on ht is necessary to prevent JDK 1.2.x from    // throwing ConcurrentModificationExceptions at us. This sucks BIG-TIME.    // One solution is to write our own hashtable implementation.    Vector v;        synchronized(ht) {      // Avoid calling clean-up too often.      if(++pushCounter <= REAP_THRESHOLD) {	return; // We release the lock ASAP.      } else {	pushCounter = 0; // OK let's do some work.      }      int misses = 0;      v = new Vector();       Enumeration enumeration = ht.keys();      // We give up after 4 straigt missses. That is 4 consecutive      // inspected threads in 'ht' that turn out to be alive.      // The higher the proportion on dead threads in ht, the higher the      // chances of removal.      while(enumeration.hasMoreElements() && (misses <= 4)) {	Thread t = (Thread) enumeration.nextElement();	if(t.isAlive()) {	  misses++;	} else {	  misses = 0;	  v.addElement(t);	}      }    } // synchronized    int size = v.size();    for(int i = 0; i < size; i++) {      Thread t = (Thread) v.elementAt(i);      LogLog.debug("Lazy NDC removal for thread [" + t.getName() + "] ("+ 		   ht.size() + ").");      ht.remove(t);    }  }  /**     Clients should call this method before leaving a diagnostic     context.     <p>The returned value is the value that was pushed last. If no     context is available, then the empty string "" is returned.          @return String The innermost diagnostic context.          */  public  static  String pop() {    Stack stack = getCurrentStack();    if(stack != null && !stack.isEmpty())       return ((DiagnosticContext) stack.pop()).message;    else      return "";  }  /**     Looks at the last diagnostic context at the top of this NDC     without removing it.     <p>The returned value is the value that was pushed last. If no     context is available, then the empty string "" is returned.          @return String The innermost diagnostic context.          */  public  static  String peek() {    Stack stack = getCurrentStack();    if(stack != null && !stack.isEmpty())      return ((DiagnosticContext) stack.peek()).message;    else      return "";  }    /**     Push new diagnostic context information for the current thread.     <p>The contents of the <code>message</code> parameter is     determined solely by the client.            @param message The new diagnostic context information.  */  public  static  void push(String message) {    Stack stack = getCurrentStack();          if(stack == null) {      DiagnosticContext dc = new DiagnosticContext(message, null);            stack = new Stack();      Thread key = Thread.currentThread();      ht.put(key, stack);      stack.push(dc);    } else if (stack.isEmpty()) {      DiagnosticContext dc = new DiagnosticContext(message, null);                  stack.push(dc);    } else {      DiagnosticContext parent = (DiagnosticContext) stack.peek();      stack.push(new DiagnosticContext(message, parent));    }      }  /**     Remove the diagnostic context for this thread.     <p>Each thread that created a diagnostic context by calling     {@link #push} should call this method before exiting. Otherwise,     the memory used by the <b>thread</b> cannot be reclaimed by the     VM.     <p>As this is such an important problem in heavy duty systems and     because it is difficult to always guarantee that the remove     method is called before exiting a thread, this method has been     augmented to lazily remove references to dead threads. In     practice, this means that you can be a little sloppy and     occasionally forget to call {@link #remove} before exiting a     thread. However, you must call <code>remove</code> sometime. If     you never call it, then your application is sure to run out of     memory.       */  static  public  void remove() {    ht.remove(Thread.currentThread());        // Lazily remove dead-thread references in ht.    lazyRemove();      }  /**     Set maximum depth of this diagnostic context. If the current     depth is smaller or equal to <code>maxDepth</code>, then no     action is taken.     <p>This method is a convenient alternative to multiple {@link     #pop} calls. Moreover, it is often the case that at the end of     complex call sequences, the depth of the NDC is     unpredictable. The <code>setMaxDepth</code> method circumvents     this problem.     <p>For example, the combination     <pre>       void foo() {       &nbsp;  int depth = NDC.getDepth();       &nbsp;  ... complex sequence of calls       &nbsp;  NDC.setMaxDepth(depth);       }     </pre>     ensures that between the entry and exit of foo the depth of the     diagnostic stack is conserved.          @see #getDepth     @since 0.7.5 */  static  public  void setMaxDepth(int maxDepth) {    Stack stack = getCurrentStack();        if(stack != null && maxDepth < stack.size())       stack.setSize(maxDepth);  }    // =====================================================================   private static class DiagnosticContext {    String fullMessage;    String message;        DiagnosticContext(String message, DiagnosticContext parent) {      this.message = message;      if(parent != null) {	fullMessage = parent.fullMessage + ' ' + message;      } else {	fullMessage = message;      }    }  }}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区女| 亚洲精品免费在线观看| 蜜臀久久久久久久| 日韩一卡二卡三卡国产欧美| 免费久久99精品国产| 欧美成人aa大片| 国产一区福利在线| 午夜精品久久久久久久久久| 欧美欧美午夜aⅴ在线观看| 蜜臀久久99精品久久久画质超高清| 日韩欧美色综合网站| 国产精品亚洲一区二区三区妖精 | 国产清纯白嫩初高生在线观看91| 懂色一区二区三区免费观看| 亚洲美女一区二区三区| 欧美精品18+| 国产河南妇女毛片精品久久久 | 国产精品99久久久久久宅男| 国产精品免费免费| 欧美精品高清视频| 国产精品 日产精品 欧美精品| 亚洲欧洲日产国产综合网| 欧美精品色综合| 成人性生交大合| 日韩不卡一二三区| 国产精品久久久久久久久免费樱桃 | 国产三级精品三级在线专区| 欧洲亚洲精品在线| 久久精品av麻豆的观看方式| 国产精品久久久久久久久免费丝袜 | 男女男精品视频网| 国产精品毛片a∨一区二区三区 | 不卡的av在线| 久久99久久久欧美国产| 久久超碰97人人做人人爱| 国产日韩v精品一区二区| 欧美三级日韩在线| 国产成人在线看| 午夜精品一区二区三区电影天堂 | 国产精品沙发午睡系列990531| 91福利社在线观看| 成人性生交大片| 激情综合网天天干| 亚洲高清不卡在线观看| 国产欧美日韩精品一区| 日韩一级精品视频在线观看| 99久久99久久综合| 国产精品1区2区3区在线观看| 亚洲成在线观看| 亚洲精品国产一区二区三区四区在线| 精品伦理精品一区| 91精品久久久久久久91蜜桃| 99免费精品在线观看| 国产一区二区三区免费观看| 丝袜美腿成人在线| 亚洲成人动漫在线观看| 一区二区三区av电影| 中文字幕一区二区三区四区不卡| 久久久精品日韩欧美| 精品日韩99亚洲| 欧美一区二区久久久| 欧美三级中文字幕| 91日韩精品一区| 97精品国产露脸对白| 成人av电影免费在线播放| 国产精品一区免费在线观看| 免费成人av资源网| 免费av成人在线| 日日摸夜夜添夜夜添国产精品| 亚洲一区欧美一区| 亚洲一区二区黄色| 亚洲福利一区二区| 日韩精品1区2区3区| 日韩成人av影视| 久久99精品国产| 国产成人午夜高潮毛片| 国产suv一区二区三区88区| 国产一区二区视频在线播放| 国产综合久久久久久久久久久久| 久久www免费人成看片高清| 国内精品视频666| 国产盗摄一区二区三区| 成人的网站免费观看| 92精品国产成人观看免费| 日本乱码高清不卡字幕| 欧美性一二三区| 51午夜精品国产| 欧美成人a∨高清免费观看| 久久奇米777| 成人欧美一区二区三区黑人麻豆 | 欧美成人精品高清在线播放 | www.亚洲激情.com| 91麻豆精东视频| 欧美另类变人与禽xxxxx| 亚洲人成网站精品片在线观看| 亚洲视频香蕉人妖| 图片区小说区区亚洲影院| 蜜臀av亚洲一区中文字幕| 国产精品99久久久久久久女警| 99久久免费精品高清特色大片| 欧美视频一二三区| 日韩一区二区三区四区| 国产精品视频免费| 夜夜精品浪潮av一区二区三区| 日本亚洲三级在线| 成人动漫一区二区三区| 欧美三级日韩三级国产三级| 精品对白一区国产伦| 亚洲天堂av老司机| 琪琪久久久久日韩精品| 成人高清免费观看| 欧美日本韩国一区二区三区视频| 日韩美女视频在线| 亚洲欧美在线另类| 日韩福利视频导航| www.亚洲在线| 日韩一区二区三区免费看 | 亚洲综合丝袜美腿| 久久精品国产一区二区三| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 午夜天堂影视香蕉久久| 国产成人精品影视| 欧美日韩色一区| 中文字幕不卡在线观看| 午夜精品一区在线观看| 成人av网站免费| 日韩欧美你懂的| 伊人夜夜躁av伊人久久| 国产成人精品亚洲777人妖| 欧美精品一二三四| 中文字幕一区二区三区四区| 久久99深爱久久99精品| 欧美色图第一页| 国产精品女人毛片| 精品一区二区三区欧美| 欧美色欧美亚洲另类二区| 三级成人在线视频| 99久久精品一区| 久久亚洲精品小早川怜子| 午夜激情久久久| 91国产免费看| 亚洲欧美中日韩| 成人免费视频播放| 久久视频一区二区| 麻豆freexxxx性91精品| 欧美日韩和欧美的一区二区| 亚洲视频每日更新| 不卡视频一二三| 欧美激情在线一区二区三区| 国内精品写真在线观看| 欧美一区二区三区免费视频| 亚洲777理论| 在线观看www91| 亚洲综合区在线| 在线观看日韩电影| 一区二区免费视频| 色综合久久99| 亚洲一区二区美女| 欧美在线你懂的| 亚洲综合一二三区| 在线观看免费成人| 亚洲第一二三四区| 欧美区在线观看| 三级不卡在线观看| 日韩美女主播在线视频一区二区三区 | 欧美片在线播放| 日韩精品乱码免费| 欧美日韩国产美| 日韩在线播放一区二区| 91精品婷婷国产综合久久性色 | 久久精品一区四区| 国内精品视频666| 日本一区二区三区国色天香| 懂色av一区二区三区蜜臀 | 2022国产精品视频| 91亚洲永久精品| 亚洲欧洲性图库| 日本一区二区视频在线| 日本二三区不卡| 成人精品小蝌蚪| 26uuu国产一区二区三区| 久久99精品一区二区三区三区| 国产精品乱码一区二区三区软件| 欧美日韩国产精选| 粉嫩13p一区二区三区| 水蜜桃久久夜色精品一区的特点| 国产欧美一二三区| 91 com成人网| 91一区一区三区| 韩日欧美一区二区三区| 亚洲曰韩产成在线| 欧美国产综合一区二区| 亚洲国产成人在线| 欧美一区二区三区在线观看视频| 成人精品国产福利| 加勒比av一区二区| 五月天丁香久久| 亚洲欧美另类小说视频| 国产片一区二区三区| 欧美一区二区三区性视频|