Author: joakime
Date: Wed Feb 20 20:49:03 2008
New Revision: 629691

URL: http://svn.apache.org/viewvc?rev=629691&view=rev
Log:
MRM-708 - Migrate from Plexus Logging to Slf4J
* Adding slf4j-api to top level depMan
* Adding slf4j-simple to top level depMan
* Adding slf4j to archiva-common
* Changing references to AbstractLogEnabled to slf4j Logger.
* Creating Slf4JPlexusLogger to provide for non-archiva managed plexus 
components that require a Plexus Logger.


Added:
    
maven/archiva/trunk/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/Slf4JPlexusLogger.java
   (with props)
Modified:
    maven/archiva/trunk/archiva-base/archiva-common/pom.xml
    
maven/archiva/trunk/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/Checksums.java
    maven/archiva/trunk/pom.xml

Modified: maven/archiva/trunk/archiva-base/archiva-common/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-common/pom.xml?rev=629691&r1=629690&r2=629691&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-common/pom.xml (original)
+++ maven/archiva/trunk/archiva-base/archiva-common/pom.xml Wed Feb 20 20:49:03 
2008
@@ -39,6 +39,10 @@
       <artifactId>commons-lang</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-digest</artifactId>
     </dependency>
@@ -49,6 +53,11 @@
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-container-default</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <scope>test</scope>
     </dependency>
   </dependencies>
   <build>

Modified: 
maven/archiva/trunk/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/Checksums.java
URL: 
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/Checksums.java?rev=629691&r1=629690&r2=629691&view=diff
==============================================================================
--- 
maven/archiva/trunk/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/Checksums.java
 (original)
+++ 
maven/archiva/trunk/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/Checksums.java
 Wed Feb 20 20:49:03 2008
@@ -19,15 +19,16 @@
  * under the License.
  */
 
-import org.codehaus.plexus.digest.ChecksumFile;
-import org.codehaus.plexus.digest.Digester;
-import org.codehaus.plexus.digest.DigesterException;
-import org.codehaus.plexus.logging.AbstractLogEnabled;
-
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 
+import org.codehaus.plexus.digest.ChecksumFile;
+import org.codehaus.plexus.digest.Digester;
+import org.codehaus.plexus.digest.DigesterException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * Checksums utility component to validate or update checksums on Files. 
  *
@@ -37,8 +38,9 @@
  * @plexus.component role="org.apache.maven.archiva.common.utils.Checksums"
  */
 public class Checksums
-    extends AbstractLogEnabled
 {
+    private static final Logger LOG = LoggerFactory.getLogger(Checksums.class);
+    
     /**
      * @plexus.requirement role-hint="sha1"
      */
@@ -64,7 +66,7 @@
         // Both files missing is a failure.
         if ( !sha1File.exists() && !md5File.exists() )
         {
-            getLogger().error( "File " + file.getPath() + " has no checksum 
files (sha1 or md5)." );
+            LOG.error( "File " + file.getPath() + " has no checksum files 
(sha1 or md5)." );
             checksPass = false;
         }
 
@@ -73,7 +75,7 @@
             // Bad sha1 checksum is a failure.
             if ( !validateChecksum( sha1File, "sha1" ) )
             {
-                getLogger().warn( "SHA1 is incorrect for " + file.getPath() );
+                LOG.warn( "SHA1 is incorrect for " + file.getPath() );
                 checksPass = false;
             }
         }
@@ -83,7 +85,7 @@
             // Bad md5 checksum is a failure.
             if ( !validateChecksum( md5File, "md5" ) )
             {
-                getLogger().warn( "MD5 is incorrect for " + file.getPath() );
+                LOG.warn( "MD5 is incorrect for " + file.getPath() );
                 checksPass = false;
             }
         }
@@ -137,12 +139,12 @@
         }
         catch ( DigesterException e )
         {
-            getLogger().warn( "Unable to create " + 
digester.getFilenameExtension() + " file: " + e.getMessage(), e );
+            LOG.warn( "Unable to create " + digester.getFilenameExtension() + 
" file: " + e.getMessage(), e );
             return false;
         }
         catch ( IOException e )
         {
-            getLogger().warn( "Unable to create " + 
digester.getFilenameExtension() + " file: " + e.getMessage(), e );
+            LOG.warn( "Unable to create " + digester.getFilenameExtension() + 
" file: " + e.getMessage(), e );
             return false;
         }
     }
@@ -167,28 +169,28 @@
         {
             if ( checksumFile.isValidChecksum( hashFile ) )
             {
-                getLogger().debug( "Valid checksum: " + hashFile.getPath() );
+                LOG.debug( "Valid checksum: " + hashFile.getPath() );
                 return true;
             }
             else
             {
-                getLogger().debug( "Not valid checksum: " + hashFile.getPath() 
);
+                LOG.debug( "Not valid checksum: " + hashFile.getPath() );
                 return createChecksum( localFile, digester );
             }
         }
         catch ( FileNotFoundException e )
         {
-            getLogger().warn( "Unable to find " + ext + " file: " + 
hashFile.getAbsolutePath(), e );
+            LOG.warn( "Unable to find " + ext + " file: " + 
hashFile.getAbsolutePath(), e );
             return false;
         }
         catch ( DigesterException e )
         {
-            getLogger().warn( "Unable to process " + ext + " file: " + 
hashFile.getAbsolutePath(), e );
+            LOG.warn( "Unable to process " + ext + " file: " + 
hashFile.getAbsolutePath(), e );
             return false;
         }
         catch ( IOException e )
         {
-            getLogger().warn( "Unable to process " + ext + " file: " + 
hashFile.getAbsolutePath(), e );
+            LOG.warn( "Unable to process " + ext + " file: " + 
hashFile.getAbsolutePath(), e );
             return false;
         }
     }
@@ -211,27 +213,27 @@
             boolean validity = checksumFile.isValidChecksum( hashFile );
             if ( validity )
             {
-                getLogger().debug( "Valid checksum: " + hashFile.getPath() );
+                LOG.debug( "Valid checksum: " + hashFile.getPath() );
             }
             else
             {
-                getLogger().debug( "Not valid checksum: " + hashFile.getPath() 
);
+                LOG.debug( "Not valid checksum: " + hashFile.getPath() );
             }
             return validity;
         }
         catch ( FileNotFoundException e )
         {
-            getLogger().warn( "Unable to find " + type + " file: " + 
hashFile.getAbsolutePath(), e );
+            LOG.warn( "Unable to find " + type + " file: " + 
hashFile.getAbsolutePath(), e );
             return false;
         }
         catch ( DigesterException e )
         {
-            getLogger().warn( "Unable to process " + type + " file: " + 
hashFile.getAbsolutePath(), e );
+            LOG.warn( "Unable to process " + type + " file: " + 
hashFile.getAbsolutePath(), e );
             return false;
         }
         catch ( IOException e )
         {
-            getLogger().warn( "Unable to process " + type + " file: " + 
hashFile.getAbsolutePath(), e );
+            LOG.warn( "Unable to process " + type + " file: " + 
hashFile.getAbsolutePath(), e );
             return false;
         }
     }

Added: 
maven/archiva/trunk/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/Slf4JPlexusLogger.java
URL: 
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/Slf4JPlexusLogger.java?rev=629691&view=auto
==============================================================================
--- 
maven/archiva/trunk/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/Slf4JPlexusLogger.java
 (added)
+++ 
maven/archiva/trunk/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/Slf4JPlexusLogger.java
 Wed Feb 20 20:49:03 2008
@@ -0,0 +1,130 @@
+package org.apache.maven.archiva.common.utils;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Slf4JPlexusLogger - temporary logger to provide an Slf4j Logger to those 
components
+ * outside of the archiva codebase that require a plexus logger.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class Slf4JPlexusLogger implements org.codehaus.plexus.logging.Logger {
+    private Logger log;
+
+    public Slf4JPlexusLogger(Class<?> clazz) {
+        log = LoggerFactory.getLogger(clazz);
+    }
+
+    public Slf4JPlexusLogger(String name) {
+        log = LoggerFactory.getLogger(name);
+    }
+
+    public void debug(String message) {
+        log.debug(message);
+    }
+
+    public void debug(String message, Throwable throwable) {
+        log.debug(message, throwable);
+    }
+
+    public void error(String message) {
+        log.error(message);
+    }
+
+    public void error(String message, Throwable throwable) {
+        log.error(message, throwable);
+    }
+
+    public void fatalError(String message) {
+        log.error(message);
+    }
+
+    public void fatalError(String message, Throwable throwable) {
+        log.error(message, throwable);
+    }
+
+    public org.codehaus.plexus.logging.Logger getChildLogger(String name) {
+        return new Slf4JPlexusLogger(log.getName() + "." + name);
+    }
+
+    public String getName() {
+        return log.getName();
+    }
+
+    public int getThreshold() {
+        if (log.isTraceEnabled()) {
+            return org.codehaus.plexus.logging.Logger.LEVEL_DEBUG;
+        } else if (log.isDebugEnabled()) {
+            return org.codehaus.plexus.logging.Logger.LEVEL_DEBUG;
+        } else if (log.isInfoEnabled()) {
+            return org.codehaus.plexus.logging.Logger.LEVEL_INFO;
+        } else if (log.isWarnEnabled()) {
+            return org.codehaus.plexus.logging.Logger.LEVEL_WARN;
+        } else if (log.isErrorEnabled()) {
+            return org.codehaus.plexus.logging.Logger.LEVEL_ERROR;
+        }
+
+        return org.codehaus.plexus.logging.Logger.LEVEL_DISABLED;
+    }
+
+    public void info(String message) {
+        log.info(message);
+    }
+
+    public void info(String message, Throwable throwable) {
+        log.info(message, throwable);
+    }
+
+    public boolean isDebugEnabled() {
+        return log.isDebugEnabled();
+    }
+
+    public boolean isErrorEnabled() {
+        return log.isErrorEnabled();
+    }
+
+    public boolean isFatalErrorEnabled() {
+        return log.isErrorEnabled();
+    }
+
+    public boolean isInfoEnabled() {
+        return log.isInfoEnabled();
+    }
+
+    public boolean isWarnEnabled() {
+        return log.isWarnEnabled();
+    }
+
+    public void setThreshold(int threshold) {
+        /* do nothing */
+    }
+
+    public void warn(String message) {
+        log.warn(message);
+    }
+
+    public void warn(String message, Throwable throwable) {
+        log.warn(message, throwable);
+    }
+}

Propchange: 
maven/archiva/trunk/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/Slf4JPlexusLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/archiva/trunk/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/Slf4JPlexusLogger.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/archiva/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/archiva/trunk/pom.xml?rev=629691&r1=629690&r2=629691&view=diff
==============================================================================
--- maven/archiva/trunk/pom.xml (original)
+++ maven/archiva/trunk/pom.xml Wed Feb 20 20:49:03 2008
@@ -24,7 +24,7 @@
   <prerequisites>
     <maven>2.0.6</maven>
   </prerequisites>
-  
+
   <parent>
     <groupId>org.apache.maven.archiva</groupId>
     <artifactId>archiva-parent</artifactId>
@@ -303,6 +303,17 @@
         <groupId>org.apache.maven.archiva</groupId>
         <artifactId>archiva-xml-tools</artifactId>
         <version>1.1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-api</artifactId>
+        <version>1.4.3</version>
+      </dependency>
+      <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-simple</artifactId>
+        <version>1.4.3</version>
+        <scope>test</scope>
       </dependency>
       <dependency>
         <groupId>commons-collections</groupId>


Reply via email to