Return-Path: X-Original-To: apmail-aries-commits-archive@www.apache.org Delivered-To: apmail-aries-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C561F93A2 for ; Tue, 20 Dec 2011 13:28:36 +0000 (UTC) Received: (qmail 51174 invoked by uid 500); 20 Dec 2011 13:28:36 -0000 Delivered-To: apmail-aries-commits-archive@aries.apache.org Received: (qmail 51123 invoked by uid 500); 20 Dec 2011 13:28:36 -0000 Mailing-List: contact commits-help@aries.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aries.apache.org Delivered-To: mailing list commits@aries.apache.org Received: (qmail 51115 invoked by uid 99); 20 Dec 2011 13:28:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Dec 2011 13:28:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Dec 2011 13:28:33 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1DB1C23888FD; Tue, 20 Dec 2011 13:28:11 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@aries.apache.org From: davidb@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111220132811.1DB1C23888FD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 bundleId */ - 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 provider matches - * with the requirement being required by requirer. - * The provider's CompositeType is typed by the - * {@link #BUNDLE_CAPABILITY_TYPE} - * The requirer'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 getCurrentRevisionTransitiveRevisionsClosure(long rootBundleId, String namespace) throws IOException { - Map revisionIDMap = new HashMap(); - Bundle rootBundle = FrameworkUtils.resolveBundle(bundleContext, rootBundleId); BundleRevision rootRevision = rootBundle.adapt(BundleRevision.class); + return getRevisionTransitiveClosure(rootRevision, namespace); + } + + private Map getRevisionTransitiveClosure(BundleRevision rootRevision, String namespace) { + Map revisionIDMap = new HashMap(); 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 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 capabilities = bundleWiring.getCapabilities(BundleRevision.PACKAGE_NAMESPACE);