commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1710085 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration2/resolver/CatalogResolver.java test/java/org/apache/commons/configuration2/TestCatalogResolver.java
Date Thu, 22 Oct 2015 19:47:19 GMT
Author: oheger
Date: Thu Oct 22 19:47:19 2015
New Revision: 1710085

URL: http://svn.apache.org/viewvc?rev=1710085&view=rev
Log:
CatalogResolver now uses a ConfigurationLogger.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/resolver/CatalogResolver.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestCatalogResolver.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/resolver/CatalogResolver.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/resolver/CatalogResolver.java?rev=1710085&r1=1710084&r2=1710085&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/resolver/CatalogResolver.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/resolver/CatalogResolver.java
Thu Oct 22 19:47:19 2015
@@ -23,13 +23,12 @@ import java.net.URL;
 import java.net.URLConnection;
 import java.util.Vector;
 
+import org.apache.commons.configuration2.ConfigurationLogger;
 import org.apache.commons.configuration2.ex.ConfigurationException;
 import org.apache.commons.configuration2.interpol.ConfigurationInterpolator;
 import org.apache.commons.configuration2.io.FileLocator;
 import org.apache.commons.configuration2.io.FileLocatorUtils;
 import org.apache.commons.configuration2.io.FileSystem;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.xml.resolver.CatalogException;
 import org.apache.xml.resolver.readers.CatalogReader;
 import org.xml.sax.EntityResolver;
@@ -80,7 +79,7 @@ public class CatalogResolver implements
     /**
      * Stores the logger.
      */
-    private Log log;
+    private ConfigurationLogger log;
 
     /**
      * Constructs the CatalogResolver
@@ -90,7 +89,7 @@ public class CatalogResolver implements
         manager.setIgnoreMissingProperties(true);
         manager.setUseStaticCatalog(false);
         manager.setFileSystem(fs);
-        setLogger(null);
+        initLogger(null);
     }
 
     /**
@@ -218,23 +217,34 @@ public class CatalogResolver implements
      *
      * @return the logger
      */
-    public Log getLogger()
+    public ConfigurationLogger getLogger()
     {
         return log;
     }
 
     /**
-     * Allows to set the logger to be used by this configuration object. This
+     * Allows setting the logger to be used by this object. This
      * method makes it possible for clients to exactly control logging behavior.
      * Per default a logger is set that will ignore all log messages. Derived
      * classes that want to enable logging should call this method during their
-     * initialization with the logger to be used.
+     * initialization with the logger to be used. Passing in <b>null</b> as
+     * argument disables logging.
      *
      * @param log the new logger
      */
-    public void setLogger(Log log)
+    public void setLogger(ConfigurationLogger log)
     {
-        this.log = (log != null) ? log : LogFactory.getLog(CatalogResolver.class);
+        initLogger(log);
+    }
+
+    /**
+     * Initializes the logger. Checks for null parameters.
+     *
+     * @param log the new logger
+     */
+    private void initLogger(ConfigurationLogger log)
+    {
+        this.log = (log != null) ? log : ConfigurationLogger.newDummyLogger();
     }
 
     private synchronized org.apache.xml.resolver.tools.CatalogResolver getResolver()

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestCatalogResolver.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestCatalogResolver.java?rev=1710085&r1=1710084&r2=1710085&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestCatalogResolver.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestCatalogResolver.java
Thu Oct 22 19:47:19 2015
@@ -18,13 +18,11 @@
 package org.apache.commons.configuration2;
 
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertSame;
 
 import org.apache.commons.configuration2.ex.ConfigurationException;
 import org.apache.commons.configuration2.io.FileHandler;
 import org.apache.commons.configuration2.resolver.CatalogResolver;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -107,10 +105,10 @@ public class TestCatalogResolver
     @Test
     public void testLogger() throws Exception
     {
-        Log log = LogFactory.getLog(this.getClass());
+        ConfigurationLogger log = new ConfigurationLogger(this.getClass());
         resolver.setLogger(log);
         assertNotNull("No Logger returned", resolver.getLogger());
-        assertTrue("Incorrect Logger", log == resolver.getLogger());
+        assertSame("Incorrect Logger", log, resolver.getLogger());
     }
 
 }



Mime
View raw message