⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 framework.java

📁 JAVA实现的一个类库
💻 JAVA
字号:
package cn.edu.nju.software.sd.cll; import java.util.Hashtable;/** * FrameWork class ,some like the class of 'Hiererchy' in the Log4j project.  * @author SuSE * */public class FrameWork {     	private static  DefaultRootLogger root;	    private static Hashtable<String,Logger> RecordLogger=new Hashtable<String,Logger>();                //Hashtable to store the loggers;    	          private static  FrameWork framework;     private FrameWork(){}    /**     *     Singleton pattern     * @return     */     public static FrameWork getframework(){            if (framework==null){         framework=new FrameWork();      }       return framework;     }        	@SuppressWarnings("static-access")	/**	 * Default construct	 */	public FrameWork(DefaultRootLogger root) {	    this.root = root;	    RecordLogger.put("", root);            // as the root shows no name;	 }   /**   * initLog, complete the getLogger process.   * Something is hidden.   * return void;   *    * @param Name   * @return   */public static Logger initLog(String Name) {					RecordLogger.put(Name, new Logger(Name));                		configure(Name);            		return RecordLogger.get(Name);	}	     	private static   void configure(String Name) {                       if  (RecordLogger.get(Name).readConfig()!=true){            	           // System.out.println("No configuration file read in.");               String temp=Name;               String parent=temp;           			for(int i=temp.lastIndexOf(".");i>-1;i=temp.lastIndexOf("."))						{				parent=temp.substring(0,i);								if(RecordLogger.get(parent)!=null)								{					RecordLogger.get(Name).copy(RecordLogger.get(parent));					return;				}				temp=parent;			}			RecordLogger.get(Name).copy(root);		} 	}        	/**	 * getLogger function,which is called by getLogger method in the LoggerFactory class	 * the  final realization of the factory pattern.	 * @param name	 * @return	 */      	public static Logger getLogger(String name) {    		Logger logger =RecordLogger.get(name);    		 if (logger!=null)     		       		      return logger;    		 else                      return initLog(name);    	}   	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -