Fixed FELIX-4559 : DS plugin should use Inventory instead of deprecated ConfigurationPrinter
https://issues.apache.org/jira/browse/FELIX-4559


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1610597 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole-plugins/ds/pom.xml b/webconsole-plugins/ds/pom.xml
index 75309ca..f00b417 100644
--- a/webconsole-plugins/ds/pom.xml
+++ b/webconsole-plugins/ds/pom.xml
@@ -100,6 +100,13 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.inventory</artifactId>
+		    <version>1.0.4</version>
+            <scope>provided</scope>
+        </dependency>
+        
+        <dependency>
             <groupId>org.json</groupId>
             <artifactId>json</artifactId>
             <version>20070829</version>
diff --git a/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/Activator.java b/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/Activator.java
index da31234..b723d29 100644
--- a/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/Activator.java
+++ b/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/Activator.java
@@ -16,7 +16,9 @@
  */

 package org.apache.felix.webconsole.plugins.ds.internal;

 

-import org.apache.felix.webconsole.ConfigurationPrinter;

+import java.util.Hashtable;

+

+import org.apache.felix.inventory.InventoryPrinter;

 import org.apache.felix.webconsole.SimpleWebConsolePlugin;

 import org.osgi.framework.BundleActivator;

 import org.osgi.framework.BundleContext;

@@ -79,8 +81,14 @@
         {

             this.plugin = plugin = new WebConsolePlugin().register(context);

             final Object service = context.getService(reference);

-            printerRegistration = context.registerService(ConfigurationPrinter.SERVICE,

-                new ComponentConfigurationPrinter(service), null);

+

+            final Hashtable props = new Hashtable();

+            final String name = "Declarative Services Components";

+            props.put(InventoryPrinter.NAME, name.replace(' ', '_'));

+            props.put(InventoryPrinter.TITLE, name);

+            printerRegistration = context.registerService(InventoryPrinter.SERVICE,

+                new ComponentConfigurationPrinter(service), props);

+

             infoRegistration = new InfoProvider(context.getBundle(), service).register(context);

         }

 

diff --git a/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ComponentConfigurationPrinter.java b/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ComponentConfigurationPrinter.java
index 9c9c4d5..2bad03f 100644
--- a/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ComponentConfigurationPrinter.java
+++ b/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ComponentConfigurationPrinter.java
@@ -25,10 +25,11 @@
 import java.util.TreeMap;
 import java.util.TreeSet;
 
+import org.apache.felix.inventory.Format;
+import org.apache.felix.inventory.InventoryPrinter;
 import org.apache.felix.scr.Component;
 import org.apache.felix.scr.Reference;
 import org.apache.felix.scr.ScrService;
-import org.apache.felix.webconsole.ConfigurationPrinter;
 import org.apache.felix.webconsole.WebConsoleUtil;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
@@ -37,7 +38,7 @@
 /**
  * ComponentConfigurationPrinter prints the available SCR services. 
  */
-class ComponentConfigurationPrinter implements ConfigurationPrinter
+class ComponentConfigurationPrinter implements InventoryPrinter
 {
 
     private final ScrService scrService;
@@ -48,21 +49,14 @@
     }
 
     /**
-     * @see org.apache.felix.webconsole.ConfigurationPrinter#getTitle()
+     * @see org.apache.felix.inventory.InventoryPrinter#print(java.io.PrintWriter, org.apache.felix.inventory.Format, boolean)
      */
-    public String getTitle()
-    {
-        return "Declarative Services Components";
-    }
-
-    /**
-     * @see org.apache.felix.webconsole.ConfigurationPrinter#printConfiguration(java.io.PrintWriter)
-     */
-    public void printConfiguration(PrintWriter pw)
+    public void print(PrintWriter pw, Format format, boolean isZip)
     {
         printComponents(pw, scrService.getComponents());
     }
-
+    
+    
     private static final void printComponents(final PrintWriter pw,
         final Component[] components)
     {
@@ -222,6 +216,8 @@
         {
             case Component.STATE_DISABLED:
                 return "disabled";
+            case Component.STATE_ENABLING:
+                return "enabling";
             case Component.STATE_ENABLED:
                 return "enabled";
             case Component.STATE_UNSATISFIED:
@@ -236,10 +232,16 @@
                 return "factory";
             case Component.STATE_DEACTIVATING:
                 return "deactivating";
+            case Component.STATE_DISABLING:
+                return "disabling";
+            case Component.STATE_DISPOSING:
+                return "disposing";
             case Component.STATE_DESTROYED:
-                return "destroyed";
+                return "destroyed/disposed";
             default:
                 return String.valueOf(state);
         }
     }
+
+
 }