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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ndc.java

?? apache的log4j源碼
?? JAVA
字號:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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;      }    }  }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品乱码一区二三区小蝌蚪| 9191成人精品久久| 国产在线乱码一区二区三区| 日韩成人伦理电影在线观看| 日韩国产高清在线| 美美哒免费高清在线观看视频一区二区 | 日韩经典中文字幕一区| 亚洲国产另类av| 视频一区欧美日韩| 美女www一区二区| 国产在线播放一区二区三区| 成人性生交大片免费看视频在线| 成人免费不卡视频| 色哟哟日韩精品| 777亚洲妇女| 欧美成人aa大片| 欧美激情一区二区三区蜜桃视频| 成人免费小视频| 亚洲一区二区视频在线观看| 香蕉乱码成人久久天堂爱免费| 久热成人在线视频| 成人国产精品视频| 在线观看免费一区| 欧美电影免费观看高清完整版在| 日本一区二区不卡视频| 亚洲午夜一二三区视频| 精品亚洲国产成人av制服丝袜| 成人免费va视频| 91精品国产综合久久精品app| 久久婷婷色综合| 亚洲激情图片qvod| 精品无码三级在线观看视频 | 91麻豆文化传媒在线观看| 欧美日韩视频一区二区| 亚洲精品一区二区三区蜜桃下载 | 久久理论电影网| 亚洲天堂网中文字| 久久国产免费看| www.欧美日韩| 91精品国产综合久久精品性色| 国产精品天干天干在线综合| 国产一区二区在线影院| av电影在线观看一区| 欧美成人乱码一区二区三区| 亚洲人成网站精品片在线观看 | 日本一区二区三区视频视频| 亚洲成人一区二区在线观看| 成人在线视频一区| 日韩精品一区二区三区在线| 亚洲综合激情网| 不卡av免费在线观看| 日韩欧美一区二区在线视频| 亚洲日本欧美天堂| 粉嫩av亚洲一区二区图片| 日韩欧美国产三级| 婷婷成人激情在线网| 91老司机福利 在线| 国产欧美1区2区3区| 国模无码大尺度一区二区三区| 日韩欧美一区二区在线视频| 日韩电影在线看| 99久久精品国产麻豆演员表| 欧美日本国产视频| 亚洲丝袜精品丝袜在线| 成人性视频免费网站| 精品日韩99亚洲| 麻豆成人在线观看| 91麻豆精品国产91久久久久| 亚洲第一综合色| 欧美日韩另类国产亚洲欧美一级| 亚洲日本丝袜连裤袜办公室| 色婷婷综合久久久久中文一区二区| 日本一区二区三区四区在线视频| 国产成人福利片| 国产色产综合色产在线视频| 国产成人精品一区二| 久久久久成人黄色影片| 国产成人免费av在线| 日本一区二区三区在线不卡| 91精品国产91综合久久蜜臀| 一区二区三区欧美日韩| 成人手机在线视频| 国产偷国产偷精品高清尤物 | 久久在线观看免费| 国产精品自拍三区| 国产欧美精品日韩区二区麻豆天美| 国产麻豆欧美日韩一区| 日本一区二区三区在线观看| 在线成人高清不卡| 日韩成人精品视频| 色美美综合视频| 亚洲精品一区二区三区在线观看| 精品女同一区二区| 亚洲日本一区二区三区| 午夜精品久久久久影视| 亚洲成av人片在线| 日韩影院精彩在线| 日本韩国精品在线| 国产精品无遮挡| 一区二区国产视频| 欧美日韩国产另类一区| 美女性感视频久久| 国产欧美日韩另类一区| 91视频免费观看| 国产传媒久久文化传媒| 风流少妇一区二区| 国产精品国产三级国产专播品爱网| 99久久99久久免费精品蜜臀| 午夜电影一区二区三区| 精品处破学生在线二十三| 白白色亚洲国产精品| 午夜精品久久久| 日本一区二区三区久久久久久久久不| 欧美人xxxx| 国产精品一区免费视频| 亚洲综合免费观看高清完整版| 欧美一区二区不卡视频| 91在线云播放| 精品一区二区三区欧美| 亚洲综合一区二区精品导航| 国产视频一区在线观看 | xnxx国产精品| 色噜噜久久综合| 国产一区二区不卡在线| 午夜激情综合网| 亚洲激情欧美激情| 国产女人18毛片水真多成人如厕| 91精品国产综合久久精品性色| 91色在线porny| 国产91精品露脸国语对白| 三级一区在线视频先锋| 夜夜嗨av一区二区三区中文字幕| 国产午夜亚洲精品不卡| 日韩一级片在线观看| 欧美日韩亚州综合| 欧美在线观看一二区| 夫妻av一区二区| 国产不卡视频在线观看| 久久国产精品99久久久久久老狼| 亚洲成a人片在线观看中文| 中文字幕制服丝袜成人av | 国产aⅴ精品一区二区三区色成熟| **性色生活片久久毛片| 久久久电影一区二区三区| 欧美一区二区成人| 制服.丝袜.亚洲.另类.中文| 91欧美一区二区| 99国产精品久久| 99久久夜色精品国产网站| 成人毛片在线观看| 国产高清精品在线| 国产91清纯白嫩初高中在线观看| 国内精品免费**视频| 精品午夜一区二区三区在线观看| 精品午夜久久福利影院| 寂寞少妇一区二区三区| 国产在线一区二区| 精品亚洲aⅴ乱码一区二区三区| 91国偷自产一区二区三区成为亚洲经典 | 岛国一区二区在线观看| 成人国产免费视频| 欧美吻胸吃奶大尺度电影 | 成人精品视频一区二区三区尤物| 国产麻豆成人精品| 国产激情视频一区二区三区欧美| 国产九色sp调教91| youjizz久久| 欧美在线三级电影| 欧美美女网站色| 久久久久久久综合狠狠综合| 国产午夜三级一区二区三| 亚洲视频小说图片| 亚洲成人你懂的| 国产在线视频一区二区三区| 成人av电影在线播放| 在线观看国产日韩| 日韩欧美高清在线| 国产精品视频你懂的| 亚洲图片欧美色图| 久久精品999| 99久久综合精品| 欧美丰满美乳xxx高潮www| 精品国产乱码久久久久久牛牛| 国产精品久久久久久一区二区三区| 亚洲精品一二三四区| 亚洲自拍与偷拍| 精品一区二区三区免费| 国产一区欧美二区| 91麻豆国产自产在线观看| 欧美日韩亚洲丝袜制服| 26uuu色噜噜精品一区| 成人免费小视频| 经典三级视频一区| 欧美体内she精视频| 国产精品视频第一区| 日韩专区中文字幕一区二区| 风间由美一区二区三区在线观看| 欧美日韩精品一二三区| 国产精品久久看| 成人免费毛片高清视频|