aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1226864 - in /aries/trunk/sandbox/jmx-next: jmx-api/src/main/java/org/osgi/jmx/framework/ jmx-core/src/main/java/org/apache/aries/jmx/framework/ jmx-itests/src/test/java/org/apache/aries/jmx/framework/
Date Tue, 03 Jan 2012 16:55:40 GMT
Author: davidb
Date: Tue Jan  3 16:55:40 2012
New Revision: 1226864

URL: http://svn.apache.org/viewvc?rev=1226864&view=rev
Log:
Added BundleStateMBean.BundleIds attribute.

Modified:
    aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/BundleStateMBean.java
    aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/BundleState.java
    aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java

Modified: aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/BundleStateMBean.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/BundleStateMBean.java?rev=1226864&r1=1226863&r2=1226864&view=diff
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/BundleStateMBean.java
(original)
+++ aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/BundleStateMBean.java
Tue Jan  3 16:55:40 2012
@@ -450,6 +450,8 @@ public interface BundleStateMBean {
 	 */
 	CompositeData getBundle(long id) throws IOException;
 
+	long[] getBundleIds() throws IOException;
+
 	/**
 	 * Answer the list of identifiers of the bundles this bundle depends upon
 	 *

Modified: aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/BundleState.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/BundleState.java?rev=1226864&r1=1226863&r2=1226864&view=diff
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/BundleState.java
(original)
+++ aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/BundleState.java
Tue Jan  3 16:55:40 2012
@@ -296,8 +296,6 @@ public class BundleState extends Notific
         return isBundleRequiredByOthers(bundle, packageAdmin);
     }
 
-
-
     public CompositeData getBundle(long id) throws IOException {
         Bundle bundle = bundleContext.getBundle(id);
         if (bundle == null)
@@ -307,6 +305,15 @@ public class BundleState extends Notific
         return data.toCompositeData();
     }
 
+    public long[] getBundleIds() throws IOException {
+        Bundle[] bundles = bundleContext.getBundles();
+        long[] ids = new long[bundles.length];
+        for (int i=0; i < bundles.length; i++) {
+            ids[i] = bundles[i].getBundleId();
+        }
+        return ids;
+    }
+
     /**
      * @see org.osgi.jmx.framework.BundleStateMBean#listBundles()
      */

Modified: aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java?rev=1226864&r1=1226863&r2=1226864&view=diff
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java
(original)
+++ aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleStateMBeanTest.java
Tue Jan  3 16:55:40 2012
@@ -35,6 +35,7 @@ import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
@@ -305,6 +306,23 @@ public class BundleStateMBeanTest extend
     }
 
     @Test
+    public void testBundleIDsAttribute() throws Exception{
+        Set<Long> expectedIDs = new HashSet<Long>();
+        for (Bundle b : context().getBundles()) {
+            expectedIDs.add(b.getBundleId());
+        }
+
+        BundleStateMBean mbean = getMBean(OBJECTNAME, BundleStateMBean.class);
+        long[] actual = mbean.getBundleIds();
+        Set<Long> actualIDs = new HashSet<Long>();
+        for (long id : actual) {
+            actualIDs.add(id);
+        }
+
+        assertEquals(expectedIDs, actualIDs);
+    }
+
+    @Test
     @SuppressWarnings({ "unchecked" })
     public void testHeaderLocalization() throws Exception {
         BundleStateMBean mbean = getMBean(OBJECTNAME, BundleStateMBean.class);



Mime
View raw message