- Should improve handling of the root logger (sorry, I don't know who submitted this...
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 7 Jul 2006 22:42:46 +0000 (22:42 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 7 Jul 2006 22:42:46 +0000 (22:42 +0000)
  ago).

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@420008 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/juli/ClassLoaderLogManager.java

index 528bf3c..af79155 100644 (file)
@@ -51,14 +51,15 @@ public class ClassLoaderLogManager extends LogManager {
      * weak hashmap is used to ensure no classloader reference is leaked from \r
      * application redeployment.\r
      */\r
-    protected final Map classLoaderLoggers = new WeakHashMap();\r
+    protected final Map<ClassLoader, ClassLoaderLogInfo> classLoaderLoggers = \r
+        new WeakHashMap<ClassLoader, ClassLoaderLogInfo>();\r
 \r
     \r
     /**\r
      * This prefix is used to allow using prefixes for the properties names\r
      * of handlers and their subcomponents.\r
      */\r
-    protected ThreadLocal prefix = new ThreadLocal();\r
+    protected ThreadLocal<String> prefix = new ThreadLocal<String>();\r
 \r
     \r
     // --------------------------------------------------------- Public Methods\r
@@ -179,7 +180,7 @@ public class ClassLoaderLogManager extends LogManager {
      * Get an enumeration of the logger names currently defined in the \r
      * classloader local configuration.\r
      */\r
-    public synchronized Enumeration getLoggerNames() {\r
+    public synchronized Enumeration<String> getLoggerNames() {\r
         ClassLoader classLoader = Thread.currentThread()\r
                 .getContextClassLoader();\r
         return Collections.enumeration(getClassLoaderInfo(classLoader).loggers.keySet());\r
@@ -334,12 +335,12 @@ public class ClassLoaderLogManager extends LogManager {
         }\r
         ClassLoaderLogInfo info = \r
             new ClassLoaderLogInfo(new LogNode(null, localRootLogger));\r
-        info.loggers.put("", localRootLogger);\r
         classLoaderLoggers.put(classLoader, info);\r
         \r
         if (is != null) {\r
             readConfiguration(is, classLoader);\r
         }\r
+        addLogger(localRootLogger);\r
         \r
     }\r
     \r
@@ -472,7 +473,8 @@ public class ClassLoaderLogManager extends LogManager {
     protected static final class LogNode {\r
         Logger logger;\r
 \r
-        protected final Map children = new HashMap();\r
+        protected final Map<String, LogNode> children = \r
+            new HashMap<String, LogNode>();\r
 \r
         protected final LogNode parent;\r
 \r
@@ -487,6 +489,9 @@ public class ClassLoaderLogManager extends LogManager {
 \r
         LogNode findNode(String name) {\r
             LogNode currentNode = this;\r
+            if (logger.getName().equals(name)) {\r
+                return this;\r
+            }\r
             while (name != null) {\r
                 final int dotIndex = name.indexOf('.');\r
                 final String nextName;\r
@@ -538,8 +543,8 @@ public class ClassLoaderLogManager extends LogManager {
 \r
     protected static final class ClassLoaderLogInfo {\r
         final LogNode rootNode;\r
-        final Map loggers = new HashMap();\r
-        final Map handlers = new HashMap();\r
+        final Map<String, Logger> loggers = new HashMap<String, Logger>();\r
+        final Map<String, Handler> handlers = new HashMap<String, Handler>();\r
         final Properties props = new Properties();\r
 \r
         ClassLoaderLogInfo(final LogNode rootNode) {\r