Author: ebourg
Date: Fri Jun 19 10:54:36 2009
New Revision: 786449

URL: http://svn.apache.org/viewvc?rev=786449&view=rev
Log:
Replaced Commons Logging in the new classes

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

Modified: 
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/FileSystem.java
URL: 
http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/FileSystem.java?rev=786449&r1=786448&r2=786449&view=diff
==============================================================================
--- 
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/FileSystem.java
 (original)
+++ 
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/FileSystem.java
 Fri Jun 19 10:54:36 2009
@@ -14,23 +14,22 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.configuration2;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.impl.NoOpLog;
+package org.apache.commons.configuration2;
 
+import java.io.File;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.File;
-import java.net.URL;
 import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 /**
  * Abstract layer to allow various types of file systems.
+ * 
  * @since 1.7
- * @author <a
- * href="http://commons.apache.org/configuration/team-list.html";>Commons 
Configuration team</a>
+ * @author <a 
href="http://commons.apache.org/configuration/team-list.html";>Commons 
Configuration team</a>
  */
 public abstract class FileSystem
 {
@@ -41,7 +40,7 @@
     private static FileSystem fileSystem;
 
     /** The Logger */
-    private Log log;
+    private Logger log;
 
     /** FileSystem options provider */
     private FileOptionsProvider optionsProvider;
@@ -56,7 +55,7 @@
      *
      * @return the logger
      */
-    public Log getLogger()
+    public Logger getLogger()
     {
         return log;
     }
@@ -70,9 +69,16 @@
      *
      * @param log the new logger
      */
-    public void setLogger(Log log)
+    public void setLogger(Logger log)
     {
-        this.log = (log != null) ? log : new NoOpLog();
+        if (log == null)
+        {
+            // create a NoOp logger
+            log = Logger.getLogger(getClass().getName() + "." + hashCode());
+            log.setLevel(Level.OFF);
+        }
+        
+        this.log = log;
     }
 
     static
@@ -80,7 +86,7 @@
         String fsClassName = System.getProperty(FILE_SYSTEM);
         if (fsClassName != null)
         {
-            Log log = LogFactory.getLog(FileSystem.class);
+            Logger log = Logger.getLogger(FileSystem.class.getName());
 
             try
             {
@@ -93,15 +99,15 @@
             }
             catch (InstantiationException ex)
             {
-                log.error("Unable to create " + fsClassName, ex);
+                log.log(Level.SEVERE, "Unable to create " + fsClassName, ex);
             }
             catch (IllegalAccessException ex)
             {
-                log.error("Unable to create " + fsClassName, ex);
+                log.log(Level.SEVERE, "Unable to create " + fsClassName, ex);
             }
             catch (ClassNotFoundException ex)
             {
-                log.error("Unable to create " + fsClassName, ex);
+                log.log(Level.SEVERE, "Unable to create " + fsClassName, ex);
             }
         }
 

Modified: 
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/resolver/CatalogResolver.java
URL: 
http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/resolver/CatalogResolver.java?rev=786449&r1=786448&r2=786449&view=diff
==============================================================================
--- 
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/resolver/CatalogResolver.java
 (original)
+++ 
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/resolver/CatalogResolver.java
 Fri Jun 19 10:54:36 2009
@@ -23,13 +23,13 @@
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import org.apache.commons.configuration2.ConfigurationException;
 import org.apache.commons.configuration2.ConfigurationUtils;
 import org.apache.commons.configuration2.FileSystem;
 import org.apache.commons.lang.text.StrSubstitutor;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.impl.NoOpLog;
 import org.apache.xml.resolver.CatalogException;
 import org.apache.xml.resolver.readers.CatalogReader;
 import org.xml.sax.EntityResolver;
@@ -64,7 +64,7 @@
     private org.apache.xml.resolver.tools.CatalogResolver resolver;
 
     /** Stores the logger. */
-    private Log log;
+    private Logger log;
 
     /**
      * Constructs the CatalogResolver
@@ -183,8 +183,7 @@
             }
             catch (Exception e)
             {
-                log.debug("Failed to create InputSource for " + resolved + " ("
-                                + e.toString() + ")");
+                log.log(Level.FINE, "Failed to create InputSource for " + 
resolved, e);
                 return null;
             }
         }
@@ -197,7 +196,7 @@
      *
      * @return the logger
      */
-    public Log getLogger()
+    public Logger getLogger()
     {
         return log;
     }
@@ -211,9 +210,16 @@
      *
      * @param log the new logger
      */
-    public void setLogger(Log log)
+    public void setLogger(Logger log)
     {
-        this.log = (log != null) ? log : new NoOpLog();
+        if (log == null)
+        {
+            // create a NoOp logger
+            log = Logger.getLogger(getClass().getName() + "." + hashCode());
+            log.setLevel(Level.OFF);
+        }
+        
+        this.log = log;
     }
 
     private synchronized org.apache.xml.resolver.tools.CatalogResolver 
getResolver()

Modified: 
commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestCatalogResolver.java
URL: 
http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestCatalogResolver.java?rev=786449&r1=786448&r2=786449&view=diff
==============================================================================
--- 
commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestCatalogResolver.java
 (original)
+++ 
commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestCatalogResolver.java
 Fri Jun 19 10:54:36 2009
@@ -17,10 +17,10 @@
 
 package org.apache.commons.configuration2;
 
+import java.util.logging.Logger;
+
 import junit.framework.TestCase;
 import org.apache.commons.configuration2.resolver.CatalogResolver;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 public class TestCatalogResolver extends TestCase
 {
@@ -80,7 +80,7 @@
 
     public void testLogger() throws Exception
     {
-        Log log = LogFactory.getLog(this.getClass());
+        Logger log = Logger.getLogger(getClass().getName());
         resolver.setLogger(log);
         assertNotNull("No Logger returned", resolver.getLogger());
         assertTrue("Incorrect Logger", log == resolver.getLogger());


Reply via email to