aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1199275 - in /aries/trunk/sandbox/jmx-next: jmx-core/src/main/java/org/apache/aries/jmx/framework/ServiceState.java jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java
Date Tue, 08 Nov 2011 15:04:16 GMT
Author: davidb
Date: Tue Nov  8 15:04:16 2011
New Revision: 1199275

URL: http://svn.apache.org/viewvc?rev=1199275&view=rev
Log:
Implement ServiceStateMBean.listServices(class, filter)

Modified:
    aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/ServiceState.java
    aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java

Modified: aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/ServiceState.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/ServiceState.java?rev=1199275&r1=1199274&r2=1199275&view=diff
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/ServiceState.java
(original)
+++ aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/ServiceState.java
Tue Nov  8 15:04:16 2011
@@ -137,10 +137,17 @@ public class ServiceState extends Notifi
      * @see org.osgi.jmx.framework.ServiceStateMBean#listServices()
      */
     public TabularData listServices() throws IOException {
+        return listServices(null, null);
+    }
+
+    /**
+     * @see org.osgi.jmx.framework.ServiceStateMBean#listServices(java.lang.String, java.lang.String)
+     */
+    public TabularData listServices(String clazz, String filter) throws IOException {
         TabularData servicesTable = new TabularDataSupport(SERVICES_TYPE);
         ServiceReference[] allServiceReferences = null;
         try {
-            allServiceReferences = bundleContext.getAllServiceReferences(null, null);
+            allServiceReferences = bundleContext.getAllServiceReferences(clazz, filter);
         } catch (InvalidSyntaxException e) {
             throw new IllegalStateException("Failed to retrieve all service references",
e);
         }
@@ -267,13 +274,6 @@ public class ServiceState extends Notifi
         return eventDispatcher;
     }
 
-    ////// TODO these
-
-    public TabularData listServices(String clazz, String filter) throws IOException {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
     public TabularData listServices(String clazz, String filter, String[] serviceTypeItems)
throws IOException {
         // TODO Auto-generated method stub
         return null;

Modified: aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java?rev=1199275&r1=1199274&r2=1199275&view=diff
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java
(original)
+++ aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java
Tue Nov  8 15:04:16 2011
@@ -277,4 +277,21 @@ public class ServiceStateMBeanTest exten
                    ocData.get("Value").equals(form2));
         assertEquals("Array of String", ocData.get("Type"));
     }
+
+    @Test
+    public void testListServices() throws Exception {
+        ServiceStateMBean mbean = getMBean(ServiceStateMBean.OBJECTNAME, ServiceStateMBean.class);
+
+        String filter = "(" + Constants.SERVICE_PID + "=*)";
+        ServiceReference<?>[] refs = bundleContext.getAllServiceReferences(null, filter);
+        TabularData svcData = mbean.listServices(null, filter);
+        assertEquals(refs.length, svcData.size());
+
+        ServiceReference<InterfaceA> sref = bundleContext.getServiceReference(InterfaceA.class);
+        TabularData svcAData = mbean.listServices(InterfaceA.class.getName(), null);
+        assertEquals(1, svcAData.size());
+        CompositeData actualSvc = (CompositeData) svcAData.values().iterator().next();
+        CompositeData expectedSvc = mbean.getService((Long) sref.getProperty(Constants.SERVICE_ID));
+        assertEquals(expectedSvc, actualSvc);
+    }
 }



Mime
View raw message