You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by io...@apache.org on 2013/08/08 17:59:34 UTC

svn commit: r1511844 - in /karaf/branches/karaf-2.3.x/management/mbeans/scr: ./ src/main/java/org/apache/karaf/management/mbeans/scr/ src/main/java/org/apache/karaf/management/mbeans/scr/codec/ src/main/java/org/apache/karaf/management/mbeans/scr/inter...

Author: iocanel
Date: Thu Aug  8 15:59:33 2013
New Revision: 1511844

URL: http://svn.apache.org/r1511844
Log:
[KARAF-2438] Add an openmbean codec for scr related types. Provide a tabular data attribute of components in the ScrServiceMBean.

Added:
    karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/codec/
    karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/codec/JmxComponent.java
    karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/codec/JmxProperty.java
    karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/codec/JmxReference.java
Modified:
    karaf/branches/karaf-2.3.x/management/mbeans/scr/pom.xml
    karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/ScrServiceMBean.java
    karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/internal/ScrServiceMBeanImpl.java

Modified: karaf/branches/karaf-2.3.x/management/mbeans/scr/pom.xml
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/management/mbeans/scr/pom.xml?rev=1511844&r1=1511843&r2=1511844&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/management/mbeans/scr/pom.xml (original)
+++ karaf/branches/karaf-2.3.x/management/mbeans/scr/pom.xml Thu Aug  8 15:59:33 2013
@@ -30,7 +30,7 @@
 
     <artifactId>org.apache.karaf.management.mbeans.scr</artifactId>
     <packaging>bundle</packaging>
-    <name>Apache Karaf :: Management :: MBeans :: Services</name>
+    <name>Apache Karaf :: Management :: MBeans :: SCR</name>
     <description>This bundle provides MBeans to manipulate Service Components via JMX.</description>
 
     <properties>
@@ -88,7 +88,9 @@
                 <configuration>
                     <instructions>
                         <Export-Package>
-                            org.apache.karaf.management.mbeans.scr
+                            org.apache.karaf.management.mbeans.scr,
+                            org.apache.karaf.management.mbeans.scr.codec
+
                         </Export-Package>
                         <Private-Package>
                             org.apache.karaf.management.mbeans.scr.internal

Modified: karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/ScrServiceMBean.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/ScrServiceMBean.java?rev=1511844&r1=1511843&r2=1511844&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/ScrServiceMBean.java (original)
+++ karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/ScrServiceMBean.java Thu Aug  8 15:59:33 2013
@@ -16,11 +16,54 @@
  */
 package org.apache.karaf.management.mbeans.scr;
 
+import javax.management.openmbean.TabularData;
+
 /**
  * The management interface for SCR Components.
  */
 public interface ScrServiceMBean {
-    
+
+    String COMPONENT_ID = "Id";
+    String COMPONENT_NAME = "Name";
+    String COMPONENT_STATE = "State";
+    String COMPONENT_PROPERTIES = "Properties";
+    String COMPONENT_REFERENCES = "References";
+
+    String PROPERTY_KEY = "Key";
+    String PROPERTY_VALUE = "Value";
+
+    String REFERENCE_NAME = "Name";
+    String REFERENCE_SATISFIED = "Satisfied";
+
+    String REFERENCE_CARDINALITY = "Cardinality";
+    String REFERENCE_CARDINALITY_SINGLE = "Single";
+    String REFERENCE_CARDINALITY_MULTIPLE = "Multiple";
+    String REFERENCE_AVAILABILITY = "Availability";
+    String REFERENCE_AVAILABILITY_OPTIONAL = "Optional";
+    String REFERENCE_AVAILABILITY_MANDATORY = "Mandatory";
+
+    String REFERENCE_POLICY = "Policy";
+    String REFERENCE_POLICY_DYNAMIC = "Dynamic";
+    String REFERENCE_POLICY_STATIC = "Static";
+
+    String REFERENCE_BOUND_SERVICES = "Bound Services";
+
+    /**
+     * The item names in the CompositeData representing a component
+     */
+    String[] COMPONENT = { COMPONENT_ID, COMPONENT_NAME, COMPONENT_STATE,
+            COMPONENT_PROPERTIES, COMPONENT_REFERENCES };
+
+    String[] PROPERTY = { PROPERTY_KEY, PROPERTY_VALUE };
+
+    String[] REFERENCE = { REFERENCE_NAME, REFERENCE_SATISFIED, REFERENCE_CARDINALITY, REFERENCE_AVAILABILITY, REFERENCE_POLICY, REFERENCE_BOUND_SERVICES};
+
+    /**
+     * Displays a {@link TabularData} with all the component details.
+     * @return
+     * @throws Exception
+     */
+    TabularData getComponents() throws Exception;
     
     /**
      * Presents a {@ String} array of components currently registered with the SCR.

Added: karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/codec/JmxComponent.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/codec/JmxComponent.java?rev=1511844&view=auto
==============================================================================
--- karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/codec/JmxComponent.java (added)
+++ karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/codec/JmxComponent.java Thu Aug  8 15:59:33 2013
@@ -0,0 +1,141 @@
+/*
+ * 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.
+ */
+package org.apache.karaf.management.mbeans.scr.codec;
+
+import org.apache.felix.scr.Component;
+import org.apache.karaf.management.mbeans.scr.ScrServiceMBean;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+
+public class JmxComponent {
+
+
+    /**
+     * The CompositeType which represents a single component
+     */
+    public final static CompositeType COMPONENT = createComponenetType();
+
+    /**
+     * The TabularType which represents a list of components
+     */
+    public final static TabularType COMPONENT_TABLE = createComponentTableType();
+
+    private final CompositeData data;
+    
+    public JmxComponent(Component component) {
+        try {
+            String[] itemNames = ScrServiceMBean.COMPONENT;
+            Object[] itemValues = new Object[itemNames.length];
+            itemValues[0] = component.getId();
+            itemValues[1] = component.getName();
+            itemValues[2] = getState(component);
+            itemValues[3] = JmxProperty.tableFrom(component.getProperties());
+            itemValues[4] = JmxReference.tableFrom(component.getReferences());
+            data = new CompositeDataSupport(COMPONENT, itemNames, itemValues);
+        } catch (OpenDataException e) {
+            throw new IllegalStateException("Cannot form feature open data", e);
+        }
+    }
+
+    public CompositeData asCompositeData() {
+        return data;
+    }
+
+    public static TabularData tableFrom(Component... components) {
+        TabularDataSupport table = new TabularDataSupport(COMPONENT_TABLE);
+        for (Component component : components) {
+            table.put(new JmxComponent(component).asCompositeData());
+        }
+        return table;
+    }
+
+    private static CompositeType createComponenetType() {
+        try {
+            String description = "This type encapsulates Scr references";
+            String[] itemNames = ScrServiceMBean.COMPONENT;
+            OpenType[] itemTypes = new OpenType[itemNames.length];
+            String[] itemDescriptions = new String[itemNames.length];
+            itemTypes[0] = SimpleType.LONG;
+            itemTypes[1] = SimpleType.STRING;
+            itemTypes[2] = SimpleType.STRING;
+            itemTypes[3] = JmxProperty.PROPERTY_TABLE;
+            itemTypes[4] = JmxReference.REFERENCE_TABLE;
+
+            itemDescriptions[0] = "The id of the component";
+            itemDescriptions[1] = "The name of the component";
+            itemDescriptions[2] = "The state of the component";
+            itemDescriptions[3] = "The properties of the component";
+            itemDescriptions[4] = "The references of the component";
+
+            return new CompositeType("Component", description, itemNames,
+                    itemDescriptions, itemTypes);
+        } catch (OpenDataException e) {
+            throw new IllegalStateException("Unable to build component type", e);
+        }
+    }
+
+    private static TabularType createComponentTableType() {
+        try {
+            return new TabularType("Component", "The table of all components",
+                    COMPONENT, ScrServiceMBean.COMPONENT);
+        } catch (OpenDataException e) {
+            throw new IllegalStateException("Unable to build components table type", e);
+        }
+    }
+
+
+    /**
+     * Returns a literal for the {@link Component} state.
+     * @param component     The target {@link Component}.
+     * @return
+     */
+    private static String getState(Component component) {
+        switch (component.getState()) {
+            case Component.STATE_ACTIVE:
+                return "Active";
+            case Component.STATE_ACTIVATING:
+                return "Activating";
+            case Component.STATE_DEACTIVATING:
+                return "Deactivating";
+            case Component.STATE_DISABLED:
+                return "Disabled";
+            case Component.STATE_DISABLING:
+                return "Disabling";
+            case Component.STATE_DISPOSED:
+                return "Disposed";
+            case Component.STATE_DISPOSING:
+                return "Disposing";
+            case Component.STATE_ENABLING:
+                return "Enabling";
+            case Component.STATE_FACTORY:
+                return "Factory";
+            case Component.STATE_REGISTERED:
+                return "Registered";
+            case Component.STATE_UNSATISFIED:
+                return "Unsatisfied";
+        }
+        return "Unknown";
+    }
+}

Added: karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/codec/JmxProperty.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/codec/JmxProperty.java?rev=1511844&view=auto
==============================================================================
--- karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/codec/JmxProperty.java (added)
+++ karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/codec/JmxProperty.java Thu Aug  8 15:59:33 2013
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+package org.apache.karaf.management.mbeans.scr.codec;
+
+
+import org.apache.karaf.management.mbeans.scr.ScrServiceMBean;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+import java.util.Dictionary;
+import java.util.Enumeration;
+
+public class JmxProperty {
+
+
+    /**
+     * The CompositeType which represents a single property
+     */
+    public final static CompositeType PROPERTY = createPropertyType();
+
+    /**
+     * The TabularType which represents a list of properties
+     */
+    public final static TabularType PROPERTY_TABLE = createPropertyTableType();
+
+    private final CompositeData data;
+
+    public JmxProperty(String key, String value) {
+        try {
+            String[] itemNames = ScrServiceMBean.PROPERTY;
+            Object[] itemValues = new Object[itemNames.length];
+            itemValues[0] = key;
+            itemValues[1] = value;
+            data = new CompositeDataSupport(PROPERTY, itemNames, itemValues);
+        } catch (OpenDataException e) {
+            throw new IllegalStateException("Cannot form property open data", e);
+        }
+    }
+
+    public CompositeData asCompositeData() {
+        return data;
+    }
+
+    public static TabularData tableFrom(Dictionary properties) {
+        TabularDataSupport table = new TabularDataSupport(PROPERTY_TABLE);
+        Enumeration p = properties.keys();
+        while (p.hasMoreElements()) {
+            Object key = p.nextElement();
+            Object value = properties.get(key);
+            table.put(new JmxProperty(String.valueOf(key), String.valueOf(value)).asCompositeData());
+        }
+        return table;
+    }
+
+    private static CompositeType createPropertyType() {
+        try {
+            String description = "This type encapsulates Scr properties";
+            String[] itemNames = ScrServiceMBean.PROPERTY;
+            OpenType[] itemTypes = new OpenType[itemNames.length];
+            String[] itemDescriptions = new String[itemNames.length];
+            itemTypes[0] = SimpleType.STRING;
+            itemTypes[1] = SimpleType.STRING;
+
+            itemDescriptions[0] = "The property key";
+            itemDescriptions[1] = "The property value";
+
+            return new CompositeType("Property", description, itemNames,
+                    itemDescriptions, itemTypes);
+        } catch (OpenDataException e) {
+            throw new IllegalStateException("Unable to build property type", e);
+        }
+    }
+
+    private static TabularType createPropertyTableType() {
+        try {
+            return new TabularType("References", "The table of all properties",
+                    PROPERTY, ScrServiceMBean.PROPERTY);
+        } catch (OpenDataException e) {
+            throw new IllegalStateException("Unable to build properties table type", e);
+        }
+    }
+}

Added: karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/codec/JmxReference.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/codec/JmxReference.java?rev=1511844&view=auto
==============================================================================
--- karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/codec/JmxReference.java (added)
+++ karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/codec/JmxReference.java Thu Aug  8 15:59:33 2013
@@ -0,0 +1,169 @@
+/*
+ * 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.
+ */
+package org.apache.karaf.management.mbeans.scr.codec;
+
+import org.apache.felix.scr.Reference;
+import org.apache.karaf.management.mbeans.scr.ScrServiceMBean;
+import org.osgi.framework.Constants;
+
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+
+public class JmxReference {
+
+    /**
+     * The CompositeType which represents a single reference
+     */
+    public final static CompositeType REFERENCE = createReferenceType();
+
+    /**
+     * The TabularType which represents a list of references
+     */
+    public final static TabularType REFERENCE_TABLE = createReferenceTableType();
+
+    private final CompositeData data;
+    //String[] COMPONENT = { REFERENCE_NAME, REFERENCE_STATE, REFERENCE_CARDINALITY, REFERENCE_AVAILABILITY, REFERENCE_POLICY, REFERENCE_BOUND_SERVICES};
+
+    public JmxReference(Reference reference) {
+        try {
+            String[] itemNames = ScrServiceMBean.REFERENCE;
+            Object[] itemValues = new Object[itemNames.length];
+            itemValues[0] = reference.getName();
+            itemValues[1] = reference.isSatisfied();
+            itemValues[2] = getCardinality(reference);
+            itemValues[3] = getAvailability(reference);
+            itemValues[4] = getPolicy(reference);
+            itemValues[5] = getBoundServices(reference);
+            data = new CompositeDataSupport(REFERENCE, itemNames, itemValues);
+        } catch (OpenDataException e) {
+            throw new IllegalStateException("Cannot form feature open data", e);
+        }
+    }
+
+    public CompositeData asCompositeData() {
+        return data;
+    }
+
+    public static TabularData tableFrom(Reference... references) {
+        TabularDataSupport table = new TabularDataSupport(REFERENCE_TABLE);
+        for (Reference reference : references) {
+            table.put(new JmxReference(reference).asCompositeData());
+        }
+        return table;
+    }
+
+    private static CompositeType createReferenceType() {
+        try {
+            String description = "This type encapsulates Scr references";
+            String[] itemNames = ScrServiceMBean.REFERENCE;
+            OpenType[] itemTypes = new OpenType[itemNames.length];
+            String[] itemDescriptions = new String[itemNames.length];
+            itemTypes[0] = SimpleType.STRING;
+            itemTypes[1] = SimpleType.BOOLEAN;
+            itemTypes[2] = SimpleType.STRING;
+            itemTypes[3] = SimpleType.STRING;
+            itemTypes[4] = SimpleType.STRING;
+            itemTypes[5] = new ArrayType(1, SimpleType.STRING);
+
+            itemDescriptions[0] = "The name of the reference";
+            itemDescriptions[1] = "The state of the reference";
+            itemDescriptions[2] = "The cardinality of the reference";
+            itemDescriptions[3] = "The availability of the reference";
+            itemDescriptions[4] = "The policy of the reference";
+            itemDescriptions[5] = "The bound services";
+
+            return new CompositeType("Reference", description, itemNames,
+                    itemDescriptions, itemTypes);
+        } catch (OpenDataException e) {
+            throw new IllegalStateException("Unable to build reference type", e);
+        }
+    }
+
+    private static TabularType createReferenceTableType() {
+        try {
+            return new TabularType("References", "The table of all references",
+                    REFERENCE,  ScrServiceMBean.REFERENCE);
+        } catch (OpenDataException e) {
+            throw new IllegalStateException("Unable to build references table type", e);
+        }
+    }
+
+
+    /**
+     * Returns a literal for the {@link Reference} cardinality.
+     * @param reference     The target {@link Reference}.
+     * @return              "Multiple" or "Single".
+     */
+    private static String getCardinality(Reference reference) {
+        if (reference.isMultiple()) {
+            return ScrServiceMBean.REFERENCE_CARDINALITY_MULTIPLE;
+        } else {
+            return ScrServiceMBean.REFERENCE_CARDINALITY_SINGLE;
+        }
+    }
+
+    /**
+     * Returns a literal for the {@link Reference} availability.
+     * @param reference     The target {@link Reference}.
+     * @return              "Mandatory" or "Optional".
+     */
+    private static String getAvailability(Reference reference) {
+        if (reference.isOptional()) {
+            return ScrServiceMBean.REFERENCE_AVAILABILITY_OPTIONAL;
+        } else {
+            return ScrServiceMBean.REFERENCE_AVAILABILITY_MANDATORY;
+        }
+    }
+
+    /**
+     * Returns a literal for the {@link Reference} policy.
+     * @param reference     The target {@link Reference}.
+     * @return              "Static" or "Dynamic".
+     */
+    private static String getPolicy(Reference reference) {
+        if (reference.isStatic()) {
+            return ScrServiceMBean.REFERENCE_POLICY_STATIC;
+        } else {
+            return ScrServiceMBean.REFERENCE_POLICY_DYNAMIC;
+        }
+    }
+
+    /**
+     * Returns The bound service ids.
+     * @param reference     The target {@link Reference}.
+     * @return
+     */
+    private static String[] getBoundServices(Reference reference) {
+        if (reference.getBoundServiceReferences() == null || reference.getBoundServiceReferences().length == 0) {
+            return new String[0];
+        } else {
+            String[] ids = new String[reference.getBoundServiceReferences().length];
+            for (int i=0; i < reference.getBoundServiceReferences().length; i++) {
+                ids[i] = String.valueOf(reference.getBoundServiceReferences()[i].getProperty(Constants.SERVICE_ID));
+            }
+            return ids;
+        }
+    }
+}

Modified: karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/internal/ScrServiceMBeanImpl.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/internal/ScrServiceMBeanImpl.java?rev=1511844&r1=1511843&r2=1511844&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/internal/ScrServiceMBeanImpl.java (original)
+++ karaf/branches/karaf-2.3.x/management/mbeans/scr/src/main/java/org/apache/karaf/management/mbeans/scr/internal/ScrServiceMBeanImpl.java Thu Aug  8 15:59:33 2013
@@ -25,6 +25,7 @@ import javax.management.MBeanServer;
 import javax.management.NotCompliantMBeanException;
 import javax.management.ObjectName;
 import javax.management.StandardMBean;
+import javax.management.openmbean.TabularData;
 
 import aQute.bnd.annotation.component.Activate;
 import aQute.bnd.annotation.component.Deactivate;
@@ -34,6 +35,7 @@ import org.apache.felix.scr.Component;
 import org.apache.felix.scr.ScrService;
 import org.apache.karaf.management.mbeans.scr.ScrServiceMBean;
 
+import org.apache.karaf.management.mbeans.scr.codec.JmxComponent;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -108,12 +110,16 @@ public class ScrServiceMBeanImpl extends
         }
     }
 
+    public TabularData getComponents() throws Exception {
+        return JmxComponent.tableFrom(safe(scrService.getComponents()));
+    }
+
     /*
-     * @see org.apache.karaf.management.mbeans.scr.ScrServiceMBean#listComponents()
-     *
-     * @return
-     * @throws Exception
-     */
+         * @see org.apache.karaf.management.mbeans.scr.ScrServiceMBean#listComponents()
+         *
+         * @return
+         * @throws Exception
+         */
     public String[] listComponents() throws Exception {
         Component[] components = safe(scrService.getComponents());
         String[] componentNames = new String[components.length];