[logback-dev] svn commit: r997 - in logback/trunk: logback-access/src/main/java/ch/qos/logback/access/jetty logback-core/src/main/java/ch/qos/logback/core/util

noreply.seb at qos.ch noreply.seb at qos.ch
Fri Nov 24 11:00:58 CET 2006


Author: seb
Date: Fri Nov 24 11:00:58 2006
New Revision: 997

Added:
   logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogMapper.java
Modified:
   logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java

Log:
RequestLog objects now register themselves to the RequestLogMapper to be accessible later on
Added a trick in OptionHelper to load classes 

Modified: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java
==============================================================================
--- logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java	(original)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java	Fri Nov 24 11:00:58 2006
@@ -20,6 +20,7 @@
 import ch.qos.logback.core.spi.FilterAttachableImpl;
 import ch.qos.logback.core.spi.FilterReply;
 import ch.qos.logback.core.status.ErrorStatus;
+import ch.qos.logback.core.status.InfoStatus;
 import ch.qos.logback.core.status.WarnStatus;
 import ch.qos.logback.core.util.StatusPrinter;
 
@@ -154,16 +155,20 @@
       getStatusManager().add(
           new ErrorStatus("[" + filename + "] does not exist", this));
     }
-
+    
+    if (getName() == null) {
+      setName("LogbackRequestLog");
+    }
+    RequestLogMapper.addRequestLog(this);
+    getStatusManager().add(
+        new InfoStatus("RequestLog added to RequestLogMapper with name: " + getName(), this));
   }
 
   public void stop() throws Exception {
-    // System.out.println("RequestLogImpl-stop called");
     aai.detachAndStopAllAppenders();
   }
 
   public boolean isRunning() {
-    // System.out.println("RequestLogImpl-isRunning called");
     return false;
   }
 
@@ -172,22 +177,18 @@
   }
 
   public boolean isStarted() {
-    // System.out.println("RequestLogImpl-isStarted called");
     return true;
   }
 
   public boolean isStarting() {
-    // System.out.println("RequestLogImpl-isStarting called");
     return false;
   }
 
   public boolean isStopping() {
-    // System.out.println("RequestLogImpl-isStopping called");
     return false;
   }
 
   public boolean isFailed() {
-    // System.out.println("RequestLogImpl-isFailed called");
     return false;
   }
 

Added: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogMapper.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogMapper.java	Fri Nov 24 11:00:58 2006
@@ -0,0 +1,18 @@
+package ch.qos.logback.access.jetty;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class RequestLogMapper {
+  
+  private static Map<String, RequestLogImpl> requestLogMap = new HashMap<String, RequestLogImpl>();
+  
+  public static void addRequestLog(RequestLogImpl requestLogImpl) {
+    requestLogMap.put(requestLogImpl.getName(), requestLogImpl);
+  }
+  
+  public static RequestLogImpl get(String key) {
+    return requestLogMap.get(key);
+  }
+
+}

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java	Fri Nov 24 11:00:58 2006
@@ -26,8 +26,16 @@
     if (className == null) {
       throw new NullPointerException();
     }
-    Class classObj = Class.forName(className);
-
+    
+    // FIXME This is temporary (really!).
+    Class classObj = null;
+    try {
+       classObj = Class.forName(className);
+    } catch(ClassNotFoundException e) {
+      ClassLoader cccl = Thread.currentThread().getContextClassLoader();
+      classObj = cccl.loadClass(className);
+    }
+    
     if (!superClass.isAssignableFrom(classObj)) {
       throw new IncompatibleClassException(superClass, classObj);
     }



More information about the logback-dev mailing list