cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r580934 - in /incubator/cxf/trunk: common/common/src/main/java/org/apache/cxf/common/logging/ integration/jca/src/main/java/org/apache/cxf/jca/core/logging/ integration/jca/src/main/java/org/apache/cxf/jca/cxf/
Date Mon, 01 Oct 2007 12:41:00 GMT
Author: dkulp
Date: Mon Oct  1 05:40:59 2007
New Revision: 580934

URL: http://svn.apache.org/viewvc?rev=580934&view=rev
Log:
[cXF-1082] Update to support older log4j versions

Modified:
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/Log4jLogger.java
    incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/core/logging/LoggerHelper.java
    incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/cxf/AssociatedManagedConnectionFactoryImpl.java

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/Log4jLogger.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/Log4jLogger.java?rev=580934&r1=580933&r2=580934&view=diff
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/Log4jLogger.java
(original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/Log4jLogger.java
Mon Oct  1 05:40:59 2007
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.common.logging;
 
+import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -45,19 +46,30 @@
 public class Log4jLogger extends AbstractDelegatingLogger {
     private static final Map<Level, org.apache.log4j.Level> TO_LOG4J = 
                                                 new HashMap<Level, org.apache.log4j.Level>();
+    private static final org.apache.log4j.Level TRACE;
 
-    private final org.apache.log4j.Logger log;
 
+    private final org.apache.log4j.Logger log;
 
     static {
+        //older versions of log4j don't have TRACE, use debug
+        org.apache.log4j.Level t = org.apache.log4j.Level.DEBUG;
+        try {
+            Field f = org.apache.log4j.Level.class.getField("TRACE");
+            t = (org.apache.log4j.Level)f.get(null);
+        } catch (Exception ex) {
+            //ignore, assume old version of log4j
+        }
+        TRACE = t;
+        
         TO_LOG4J.put(Level.ALL,     org.apache.log4j.Level.ALL);
         TO_LOG4J.put(Level.SEVERE,  org.apache.log4j.Level.ERROR);
         TO_LOG4J.put(Level.WARNING, org.apache.log4j.Level.WARN);
         TO_LOG4J.put(Level.INFO,    org.apache.log4j.Level.INFO);
         TO_LOG4J.put(Level.CONFIG,  org.apache.log4j.Level.DEBUG);
         TO_LOG4J.put(Level.FINE,    org.apache.log4j.Level.DEBUG);
-        TO_LOG4J.put(Level.FINER,   org.apache.log4j.Level.TRACE);
-        TO_LOG4J.put(Level.FINEST,  org.apache.log4j.Level.TRACE);
+        TO_LOG4J.put(Level.FINER,   TRACE);
+        TO_LOG4J.put(Level.FINEST,  TRACE);
         TO_LOG4J.put(Level.OFF,     org.apache.log4j.Level.OFF);
     }
 
@@ -125,14 +137,15 @@
         case org.apache.log4j.Level.DEBUG_INT:
             l2 = Level.FINE;
             break;
-        case org.apache.log4j.Level.TRACE_INT:
-            l2 = Level.FINEST;
-            break;
         case org.apache.log4j.Level.OFF_INT:
             l2 = Level.OFF;
             break;
         default:
-            l2 = null;
+            if (l.toInt() == TRACE.toInt()) {
+                l2 = Level.FINEST;
+            } else {
+                l2 = null;
+            }
         } 
         return l2;
     } 
@@ -166,12 +179,12 @@
             getFullInfoForLogUtils(lr, event.fqnOfCategoryClass);
             handler.publish(lr);
         }
-        @Override
+
         public void close() {
             handler.close();
             closed = true;
         }
-        @Override
+
         public boolean requiresLayout() {
             return false;
         }    

Modified: incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/core/logging/LoggerHelper.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/core/logging/LoggerHelper.java?rev=580934&r1=580933&r2=580934&view=diff
==============================================================================
--- incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/core/logging/LoggerHelper.java
(original)
+++ incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/core/logging/LoggerHelper.java
Mon Oct  1 05:40:59 2007
@@ -18,13 +18,16 @@
  */
 package org.apache.cxf.jca.core.logging;
 
-import java.io.*;
+import java.io.Writer;
 import java.util.logging.ConsoleHandler;
 import java.util.logging.Handler;
 import java.util.logging.Level;
-import java.util.logging.LogManager;
 import java.util.logging.Logger;
 
+import org.apache.cxf.common.logging.Log4jLogger;
+import org.apache.cxf.common.logging.LogUtils;
+
+
 public final class LoggerHelper {
     public static final Level DEFAULT_LOG_LEVEL = Level.WARNING;    
     public static final String CONSOLE_HANDLER = "ConsoleHandler";
@@ -43,9 +46,10 @@
                 // jboss writer will redirect to log4j which will cause an
                 // infinite loop if we install an appender over this writer.
                 // Continue logging via log4j and ignore this writer.
-                //
+                LogUtils.setLoggerClass(Log4jLogger.class);
                 return;
             }
+
             Logger cxfLogger = getRootCXFLogger();
 
             // test if the stream handler were setted
@@ -70,7 +74,7 @@
 
     // true if log output is already going somewhere
     public static boolean loggerInitialisedOutsideConnector() {       
-        final Handler[] handlers = Logger.getLogger("").getHandlers(); //NOPMD        
+        final Handler[] handlers = getConsoleLogger().getHandlers(); //NOPMD        
         return handlers != null && handlers.length > 0;
     }
 
@@ -86,14 +90,14 @@
     }
 
     public static void disableConsoleLogging() {        
-        final Handler handler = getHandler(Logger.getLogger(""), CONSOLE_HANDLER);  //NOPMD
-        Logger.getLogger("").removeHandler(handler);  //NOPMD
+        final Handler handler = getHandler(getConsoleLogger(), CONSOLE_HANDLER);  //NOPMD
+        getConsoleLogger().removeHandler(handler);  //NOPMD
     }
 
     public static void enableConsoleLogging() {        
-        if (getHandler(Logger.getLogger(""), CONSOLE_HANDLER) == null) {  //NOPMD
-            final ConsoleHandler console = new ConsoleHandler();
-            Logger.getLogger("").addHandler(console);  //NOPMD
+        if (getHandler(getConsoleLogger(), CONSOLE_HANDLER) == null) {  //NOPMD
+            final Handler console = new ConsoleHandler();
+            getConsoleLogger().addHandler(console);  //NOPMD
         }
     }
 
@@ -112,13 +116,11 @@
     }
 
     public static Logger getRootCXFLogger() {
-        Logger rootCXFLogger = null;
-        rootCXFLogger = LogManager.getLogManager().getLogger(getRootLoggerName());
-        if (rootCXFLogger == null) {
-            rootCXFLogger = Logger.getLogger(getRootLoggerName()); //NOPMD
-        }
-
-        return rootCXFLogger;
+        return LogUtils.getLogger(LoggerHelper.class, null, getRootLoggerName());
+    }
+    
+    public static Logger getConsoleLogger() {
+        return LogUtils.getLogger(LoggerHelper.class, null, "");
     }
 
     public static void init() {

Modified: incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/cxf/AssociatedManagedConnectionFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/cxf/AssociatedManagedConnectionFactoryImpl.java?rev=580934&r1=580933&r2=580934&view=diff
==============================================================================
--- incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/cxf/AssociatedManagedConnectionFactoryImpl.java
(original)
+++ incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/cxf/AssociatedManagedConnectionFactoryImpl.java
Mon Oct  1 05:40:59 2007
@@ -94,6 +94,16 @@
     protected Object getBootstrapContext() {
         return ((ResourceAdapterImpl)ra).getBootstrapContext();
     }
+    
+    //Explicit override these two methods, 
+    //otherwise when deploy rar to weblogic9.1, it would complaint about this.
+    public int hashCode() {
+        return super.hashCode();
+    }
+    
+    public boolean equals(Object o) {
+        return super.equals(o);
+    }
 }
 
 



Mime
View raw message