aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1221251 - in /aries/trunk/sandbox/jmx-next: jmx-api/src/main/java/org/osgi/jmx/framework/wiring/ jmx-core/src/main/java/org/apache/aries/jmx/framework/wiring/ jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/
Date Tue, 20 Dec 2011 13:28:10 GMT
Author: davidb
Date: Tue Dec 20 13:28:10 2011
New Revision: 1221251

URL: http://svn.apache.org/viewvc?rev=1221251&view=rev
Log:
Add support for BundleWiringStateMBean.getRevisionsWiring()

Modified:
    aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/wiring/BundleWiringStateMBean.java
    aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/wiring/BundleWiringState.java
    aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanTest.java

Modified: aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/wiring/BundleWiringStateMBean.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/wiring/BundleWiringStateMBean.java?rev=1221251&r1=1221250&r2=1221251&view=diff
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/wiring/BundleWiringStateMBean.java
(original)
+++ aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/wiring/BundleWiringStateMBean.java
Tue Dec 20 13:28:10 2011
@@ -217,6 +217,12 @@ public interface BundleWiringStateMBean 
                 REQUIRED_WIRES_ITEM,          /* BUNDLE_WIRE_TYPE [] */
                 PROVIDED_WIRES_ITEM           /* BUNDLE_WIRE_TYPE [] */
                 );
+    TabularType REVISIONS_BUNDLE_WIRING_TYPE =
+        Item.tabularType("REVISIONS_BUNDLE_WIRING",
+            "The bundle wiring for all bundle revisions",
+            BUNDLE_WIRING_TYPE,
+            BUNDLE_ID, BUNDLE_REVISION_ID);
+    /*
     ArrayType BUNDLE_WIRING_TYPE_ARRAY =
         Item.arrayType(1, BUNDLE_WIRING_TYPE);
 
@@ -225,6 +231,7 @@ public interface BundleWiringStateMBean 
 
     ArrayType REVISIONS_CAPABILITY_TYPE_ARRAY =
         Item.arrayType(2, BUNDLE_CAPABILITY_TYPE);
+    */
 
     TabularType BUNDLE_WIRING_CLOSURE_TYPE = Item.tabularType("BUNDLE_WIRING_CLOSURE",
             "A table of bundle wirings describing a full wiring closure",
@@ -317,7 +324,7 @@ public interface BundleWiringStateMBean 
      * @param namespace
      * @return the wires for all revisions of <code>bundleId</code>
      */
-    ArrayType getRevisionsWiring(long bundleId, String namespace) throws IOException;
+    TabularData getRevisionsWiring(long bundleId, String namespace) throws IOException;
 
     /**
      * Returns a closure of all bundle wirings linked by their
@@ -331,22 +338,5 @@ public interface BundleWiringStateMBean 
      * @param namespace
      * @return a closure of bundle wirings linked together by wires.
      */
-    ArrayType getWiringClosure(long rootBundleId, String namespace) throws IOException;
-
-    /**
-     * Returns true if capability provided by <code>provider</code> matches
-     *  with the requirement being required by <code>requirer</code>.
-     * The <code>provider</code>'s CompositeType is typed by the
-     *  {@link #BUNDLE_CAPABILITY_TYPE}
-     * The <code>requirer</code>'s CompositeType is typed by the
-     *  {@link #BUNDLE_REQUIREMENT_TYPE}
-     *
-     * REVIEW This method would have worked better should the requirements and
-     *  capabilities have an ID
-     *
-     * @param requirer bundle id of the bundle requirer
-     * @param provider bundle id of the bundle provider
-     * @return true if capability matches with requirement.
-     */
-    boolean matches(CompositeType provider, CompositeType requirer) throws IOException;
+    TabularData getWiringClosure(long rootBundleId, String namespace) throws IOException;
 }
\ No newline at end of file

Modified: aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/wiring/BundleWiringState.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/wiring/BundleWiringState.java?rev=1221251&r1=1221250&r2=1221251&view=diff
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/wiring/BundleWiringState.java
(original)
+++ aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/wiring/BundleWiringState.java
Tue Dec 20 13:28:10 2011
@@ -21,9 +21,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.management.openmbean.ArrayType;
 import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeType;
 import javax.management.openmbean.TabularData;
 import javax.management.openmbean.TabularDataSupport;
 
@@ -97,10 +95,13 @@ public class BundleWiringState implement
     // The current revision being passed in always gets assigned revision ID 0
     // All the other revision IDs unique, but don't increase monotonous.
     private Map<BundleRevision, Integer> getCurrentRevisionTransitiveRevisionsClosure(long
rootBundleId, String namespace) throws IOException {
-        Map<BundleRevision, Integer> revisionIDMap = new HashMap<BundleRevision,
Integer>();
-
         Bundle rootBundle = FrameworkUtils.resolveBundle(bundleContext, rootBundleId);
         BundleRevision rootRevision = rootBundle.adapt(BundleRevision.class);
+        return getRevisionTransitiveClosure(rootRevision, namespace);
+    }
+
+    private Map<BundleRevision, Integer> getRevisionTransitiveClosure(BundleRevision
rootRevision, String namespace) {
+        Map<BundleRevision, Integer> revisionIDMap = new HashMap<BundleRevision,
Integer>();
         populateTransitiveRevisions(namespace, rootRevision, revisionIDMap);
 
         // Set the root revision ID to 0,
@@ -169,24 +170,23 @@ public class BundleWiringState implement
     /* (non-Javadoc)
      * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getRevisionsWiring(long, java.lang.String)
      */
-    public ArrayType getRevisionsWiring(long bundleId, String namespace) {
-        // TODO Auto-generated method stub
-        return null;
+    public TabularData getRevisionsWiring(long bundleId, String namespace) throws IOException
{
+        Bundle bundle = FrameworkUtils.resolveBundle(bundleContext, bundleId);
+        BundleRevisions revisions = bundle.adapt(BundleRevisions.class);
+
+        TabularData td = new TabularDataSupport(BundleWiringStateMBean.REVISIONS_BUNDLE_WIRING_TYPE);
+        for (BundleRevision revision : revisions.getRevisions()) {
+            Map<BundleRevision, Integer> revisionIDMap = getRevisionTransitiveClosure(revision,
namespace);
+            td.put(getRevisionWiring(revision, System.identityHashCode(revision), namespace,
revisionIDMap));
+        }
+        return td;
     }
 
     /* (non-Javadoc)
      * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getWiringClosure(long, java.lang.String)
      */
-    public ArrayType getWiringClosure(long rootBundleId, String namespace) {
+    public TabularData getWiringClosure(long rootBundleId, String namespace) {
         // TODO Auto-generated method stub
         return null;
     }
-
-    /* (non-Javadoc)
-     * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#matches(javax.management.openmbean.CompositeType,
javax.management.openmbean.CompositeType)
-     */
-    public boolean matches(CompositeType provider, CompositeType requirer) {
-        // TODO Auto-generated method stub
-        return false;
-    }
 }

Modified: aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanTest.java?rev=1221251&r1=1221250&r2=1221251&view=diff
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanTest.java
(original)
+++ aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanTest.java
Tue Dec 20 13:28:10 2011
@@ -206,6 +206,22 @@ public class BundleWiringStateMBeanTest 
         assertBundleWiring(bw, jmxWiring);
     }
 
+    @Test
+    public void testRevisionsWiring() throws IOException {
+        BundleWiringStateMBean brsMBean = getMBean(BundleWiringStateMBean.OBJECTNAME, BundleWiringStateMBean.class);
+
+        Bundle a = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
+        TabularData jmxWiringTable = brsMBean.getRevisionsWiring(a.getBundleId(), BundleWiringStateMBean.PACKAGE_NAMESPACE);
+
+        Assert.assertEquals(1, jmxWiringTable.size());
+        CompositeData jmxWiring = (CompositeData) jmxWiringTable.values().iterator().next();
+        Assert.assertEquals(BundleWiringStateMBean.BUNDLE_WIRING_TYPE, jmxWiring.getCompositeType());
+        Assert.assertEquals(a.getBundleId(), jmxWiring.get(BundleWiringStateMBean.BUNDLE_ID));
+
+        BundleWiring bw = a.adapt(BundleWiring.class);
+        assertBundleWiring(bw, jmxWiring);
+    }
+
     private void assertBundleWiring(BundleWiring bundleWiring, CompositeData jmxWiring) {
         CompositeData[] jmxCapabilities = (CompositeData[]) jmxWiring.get(BundleWiringStateMBean.CAPABILITIES);
         List<BundleCapability> capabilities = bundleWiring.getCapabilities(BundleRevision.PACKAGE_NAMESPACE);



Mime
View raw message