incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1138846 - in /sling/trunk/bundles/extensions/adapter: pom.xml src/main/java/org/apache/sling/adapter/internal/AdapterManagerImpl.java
Date Thu, 23 Jun 2011 12:07:24 GMT
Author: bdelacretaz
Date: Thu Jun 23 12:07:24 2011
New Revision: 1138846

URL: http://svn.apache.org/viewvc?rev=1138846&view=rev
Log:
SLING-2106 - Use slf4j logging in AdapterManagerImpl

Modified:
    sling/trunk/bundles/extensions/adapter/pom.xml
    sling/trunk/bundles/extensions/adapter/src/main/java/org/apache/sling/adapter/internal/AdapterManagerImpl.java

Modified: sling/trunk/bundles/extensions/adapter/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/adapter/pom.xml?rev=1138846&r1=1138845&r2=1138846&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/adapter/pom.xml (original)
+++ sling/trunk/bundles/extensions/adapter/pom.xml Thu Jun 23 12:07:24 2011
@@ -115,6 +115,11 @@
             <artifactId>slf4j-api</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
         </dependency>

Modified: sling/trunk/bundles/extensions/adapter/src/main/java/org/apache/sling/adapter/internal/AdapterManagerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/adapter/src/main/java/org/apache/sling/adapter/internal/AdapterManagerImpl.java?rev=1138846&r1=1138845&r2=1138846&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/adapter/src/main/java/org/apache/sling/adapter/internal/AdapterManagerImpl.java
(original)
+++ sling/trunk/bundles/extensions/adapter/src/main/java/org/apache/sling/adapter/internal/AdapterManagerImpl.java
Thu Jun 23 12:07:24 2011
@@ -38,7 +38,8 @@ import org.osgi.framework.ServiceReferen
 import org.osgi.service.component.ComponentContext;
 import org.osgi.service.event.Event;
 import org.osgi.service.event.EventAdmin;
-import org.osgi.service.log.LogService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * The <code>AdapterManagerImpl</code> class implements the
@@ -55,12 +56,8 @@ import org.osgi.service.log.LogService;
  */
 public class AdapterManagerImpl implements AdapterManager {
 
-    /** @scr.reference cardinality="0..1" policy="dynamic" */
-    private LogService log;
-
-    /** Whether to debug this class or not */
-    private boolean debug = false;
-
+    private Logger log = LoggerFactory.getLogger(getClass());
+    
     /**
      * The OSGi <code>ComponentContext</code> to retrieve
      * {@link AdapterFactory} service instances.
@@ -118,19 +115,14 @@ public class AdapterManagerImpl implemen
 
         // have the factory adapt the adaptable if the factory exists
         if (factory != null) {
-            if (debug) {
-                log(LogService.LOG_DEBUG, "Using adapter factory " + factory
-                    + " to map " + adaptable + " to " + type, null);
-            }
+            log.debug("Using adapter factory {} to map {} to {}",
+                    new Object [] { factory, adaptable, type });
 
             return factory.getAdapter(adaptable, type);
         }
 
         // no factory has been found, so we cannot adapt
-        if (debug) {
-            log(LogService.LOG_DEBUG, "No adapter factory found to map "
-                + adaptable + " to " + type, null);
-        }
+        log.debug("No adapter factory found to map {} to {}", adaptable, type);
 
         return null;
     }
@@ -203,20 +195,6 @@ public class AdapterManagerImpl implemen
         return factoryCache;
     }
 
-    // ---------- internal -----------------------------------------------------
-
-    private void log(int level, String message, Throwable t) {
-        LogService logger = this.log;
-        if (logger != null) {
-            logger.log(level, message, t);
-        } else {
-            System.out.println(message);
-            if (t != null) {
-                t.printStackTrace(System.out);
-            }
-        }
-    }
-
     /**
      * Unregisters the {@link AdapterFactory} referred to by the service
      * <code>reference</code> from the registry.
@@ -439,4 +417,4 @@ public class AdapterManagerImpl implemen
             }
         }
     }
-}
+}
\ No newline at end of file



Mime
View raw message