FELIX-3945 Remove Dependency on SLF4J

Add static log method using LogService if available;
otherwise write to stdou

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1452040 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/inventory/pom.xml b/inventory/pom.xml
index fb113c9..1b1f70c 100644
--- a/inventory/pom.xml
+++ b/inventory/pom.xml
@@ -74,12 +74,6 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <version>1.5.0</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>servlet-api</artifactId>
             <version>2.4</version>
diff --git a/inventory/src/main/java/org/apache/felix/inventory/impl/Activator.java b/inventory/src/main/java/org/apache/felix/inventory/impl/Activator.java
index 12b44c4..4872284 100644
--- a/inventory/src/main/java/org/apache/felix/inventory/impl/Activator.java
+++ b/inventory/src/main/java/org/apache/felix/inventory/impl/Activator.java
@@ -5,9 +5,9 @@
  * 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.
@@ -19,6 +19,9 @@
 import org.apache.felix.inventory.impl.webconsole.WebConsoleAdapter;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
 
 /**
  * Activate bridges and internal manager.
@@ -26,6 +29,10 @@
 public class Activator implements BundleActivator
 {
 
+    private static Object logService;
+
+    private ServiceTracker logServiceTracker;
+
     private InventoryPrinterManagerImpl printerManager;
 
     private WebConsoleAdapter webAdapter;
@@ -35,8 +42,26 @@
      */
     public void start(final BundleContext context) throws Exception
     {
-        this.webAdapter = new WebConsoleAdapter(context);
-        this.printerManager = new InventoryPrinterManagerImpl(context);
+        this.logServiceTracker = new ServiceTracker(context, "org.osgi.service.log.LogService", null)
+        {
+            public Object addingService(ServiceReference reference)
+            {
+                Activator.logService = super.addingService(reference);
+                return Activator.logService;
+            }
+
+            public void removedService(ServiceReference reference, Object service)
+            {
+                Activator.logService = null;
+                super.removedService(reference, service);
+            }
+        };
+        this.logServiceTracker.open();
+
+//        this.webAdapter = new WebConsoleAdapter(context);
+//        this.printerManager = new InventoryPrinterManagerImpl(context);
+
+        log(null, LogService.LOG_INFO, "Starting Framework Inventory Support", null);
     }
 
     /**
@@ -54,5 +79,48 @@
             this.webAdapter.dispose();
             this.webAdapter = null;
         }
+        Activator.logService = null;
+        if (this.logServiceTracker != null)
+        {
+            this.logServiceTracker.close();
+            this.logServiceTracker = null;
+        }
+    }
+
+    public static void log(final ServiceReference sr, final int level, final String message, final Throwable exception)
+    {
+        Object logService = Activator.logService;
+        if (logService != null)
+        {
+            ((LogService) logService).log(sr, level, message, exception);
+        }
+        else
+        {
+            final String code;
+            switch (level)
+            {
+                case LogService.LOG_INFO:
+                    code = "*INFO *";
+                    break;
+
+                case LogService.LOG_WARNING:
+                    code = "*WARN *";
+                    break;
+
+                case LogService.LOG_ERROR:
+                    code = "*ERROR*";
+                    break;
+
+                case LogService.LOG_DEBUG:
+                default:
+                    code = "*DEBUG*";
+            }
+
+            System.err.println(code + " " + message);
+            if (exception != null)
+            {
+                exception.printStackTrace(System.out);
+            }
+        }
     }
 }
diff --git a/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java b/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java
index df3f48a..82d8d6d 100644
--- a/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java
+++ b/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java
@@ -5,9 +5,9 @@
  * 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.
@@ -33,10 +33,9 @@
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.log.LogService;
 import org.osgi.util.tracker.ServiceTracker;
 import org.osgi.util.tracker.ServiceTrackerCustomizer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * The manager keeps track of all inventory printers and maintains them
@@ -46,9 +45,6 @@
 public class InventoryPrinterManagerImpl implements ServiceTrackerCustomizer
 {
 
-    /** Logger. */
-    private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
     /** Bundle Context . */
     private final BundleContext bundleContext;
 
@@ -69,7 +65,7 @@
 
     /**
      * Create the inventory printer manager
-     * 
+     *
      * @param btx Bundle Context
      * @throws InvalidSyntaxException Should only happen if we have an error in
      *             the code
@@ -132,17 +128,20 @@
         boolean valid = true;
         if (desc.getModes() == null)
         {
-            logger.info("Ignoring inventory printer - printer modes configuration is missing: {}", reference);
+            Activator.log(null, LogService.LOG_INFO,
+                "Ignoring inventory printer - printer modes configuration is missing: " + reference, null);
             valid = false;
         }
         if (desc.getName() == null)
         {
-            logger.info("Ignoring inventory printer - name configuration is missing: {}", reference);
+            Activator.log(null, LogService.LOG_INFO, "Ignoring inventory printer - name configuration is missing: "
+                + reference, null);
             valid = false;
         }
         if (desc.getTitle() == null)
         {
-            logger.info("Ignoring inventory printer - title configuration is missing: {}", reference);
+            Activator.log(null, LogService.LOG_INFO, "Ignoring inventory printer - title configuration is missing: "
+                + reference, null);
             valid = false;
         }
         if (valid)
@@ -150,7 +149,8 @@
             final InventoryPrinterAdapter adapter = InventoryPrinterAdapter.createAdapter(desc, obj);
             if (adapter == null)
             {
-                logger.info("Ignoring inventory printer - printer method is missing: {}", reference);
+                Activator.log(null, LogService.LOG_INFO, "Ignoring inventory printer - printer method is missing: "
+                    + reference, null);
             }
             else
             {
@@ -271,7 +271,7 @@
 
     /**
      * Get all inventory printer handlers.
-     * 
+     *
      * @return A list of handlers - might be empty.
      */
     public InventoryPrinterHandler[] getAllHandlers()
@@ -282,7 +282,7 @@
 
     /**
      * Get all handlers supporting the mode.
-     * 
+     *
      * @return A list of handlers - might be empty.
      */
     public InventoryPrinterHandler[] getHandlers(final PrinterMode mode)
@@ -302,7 +302,7 @@
 
     /**
      * Return a handler for the unique name.
-     * 
+     *
      * @return The corresponding handler or <code>null</code>.
      */
     public InventoryPrinterHandler getHandler(final String name)