?? framework.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 + -