aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1209453 - in /aries/trunk/sandbox/jmx-next: jmx-api/src/main/java/org/osgi/jmx/framework/ jmx-core/src/main/java/org/apache/aries/jmx/codec/ jmx-core/src/main/java/org/apache/aries/jmx/framework/ jmx-itests/src/test/java/org/apache/aries/j...
Date Fri, 02 Dec 2011 13:11:00 GMT
Author: davidb
Date: Fri Dec  2 13:10:59 2011
New Revision: 1209453

URL: http://svn.apache.org/viewvc?rev=1209453&view=rev
Log:
Tentative implementation of BundleRevisionStateMBean.getCurrrentRevisionDeclaredRequirements()

Added:
    aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/BundleRequirementsData.java
  (with props)
Modified:
    aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/BundleRevisionsStateMBean.java
    aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/BundleWiringData.java
    aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/BundleRevisionsState.java
    aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleRevisionsStateMBeanTest.java

Modified: aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/BundleRevisionsStateMBean.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/BundleRevisionsStateMBean.java?rev=1209453&r1=1209452&r2=1209453&view=diff
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/BundleRevisionsStateMBean.java
(original)
+++ aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/framework/BundleRevisionsStateMBean.java
Fri Dec  2 13:10:59 2011
@@ -210,7 +210,7 @@ public interface BundleRevisionsStateMBe
      * and <code>namespace</code>
      *
      */
-    ArrayType getCurrentRevisionDeclaredRequirements(long bundleId,
+    CompositeData[] getCurrentRevisionDeclaredRequirements(long bundleId,
             String namespace) throws IOException;
 
     /**
@@ -245,12 +245,11 @@ public interface BundleRevisionsStateMBe
      *
      * @param bundleId
      * @param namespace
-     * @param inUse
      * @return the declared requirements for all revisions of <code>bundleId</code>
      *
      */
     ArrayType getRevisionsDeclaredRequirements(long bundleId,
-            String namespace, boolean inUse) throws IOException;
+            String namespace) throws IOException;
 
     /**
      * Returns the capabilities for all revisions of the bundle.
@@ -260,11 +259,10 @@ public interface BundleRevisionsStateMBe
      *
      * @param bundleId
      * @param namespace
-     * @param inUse
      * @return the declared capabilities for all revisions of <code>bundleId</code>
      */
     ArrayType getRevisionsDeclaredCapabilities(long bundleId,
-            String namespace, boolean inUse) throws IOException;
+            String namespace) throws IOException;
 
     /**
      * Returns the bundle wirings for all revisions of the bundle.

Added: aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/BundleRequirementsData.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/BundleRequirementsData.java?rev=1209453&view=auto
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/BundleRequirementsData.java
(added)
+++ aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/BundleRequirementsData.java
Fri Dec  2 13:10:59 2011
@@ -0,0 +1,51 @@
+/**
+ *  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.aries.jmx.codec;
+
+import java.util.List;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.OpenDataException;
+
+import org.osgi.framework.wiring.BundleRequirement;
+import org.osgi.jmx.framework.BundleRevisionsStateMBean;
+
+public class BundleRequirementsData {
+    private final List<BundleRequirement> requirements;
+
+    public BundleRequirementsData(List<BundleRequirement> requirements) {
+        this.requirements = requirements;
+    }
+
+    public CompositeData[] toCompositeData() {
+        try {
+            CompositeData[] data = new CompositeData[requirements.size()];
+
+            for (int i=0; i < requirements.size(); i++) {
+                BundleRequirement requirement = requirements.get(i);
+
+                CompositeData cd = BundleWiringData.getCapReqCompositeData(BundleRevisionsStateMBean.BUNDLE_REQUIREMENT_TYPE,
+                    requirement.getNamespace(), requirement.getAttributes().entrySet(), requirement.getDirectives().entrySet());
+                data[i] = cd;
+            }
+
+            return data;
+        } catch (OpenDataException e) {
+            throw new IllegalStateException("Can't create CompositeData", e);
+        }
+    }
+}

Propchange: aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/BundleRequirementsData.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/BundleWiringData.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/BundleWiringData.java?rev=1209453&r1=1209452&r2=1209453&view=diff
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/BundleWiringData.java
(original)
+++ aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/BundleWiringData.java
Fri Dec  2 13:10:59 2011
@@ -62,7 +62,7 @@ public class BundleWiringData {
 
             return new CompositeDataSupport(BundleRevisionsStateMBean.BUNDLE_WIRING_TYPE,
items);
         } catch (OpenDataException e) {
-            throw new IllegalStateException("Can't create CompositeData" + e);
+            throw new IllegalStateException("Can't create CompositeData", e);
         }
     }
 
@@ -86,7 +86,7 @@ public class BundleWiringData {
         return reqData;
     }
 
-    private CompositeData getCapReqCompositeData(CompositeType type, String namespace, Set<Map.Entry<String,Object>>
attributeSet, Set<Map.Entry<String,String>> directiveSet) throws OpenDataException
{
+    static CompositeData getCapReqCompositeData(CompositeType type, String namespace, Set<Map.Entry<String,Object>>
attributeSet, Set<Map.Entry<String,String>> directiveSet) throws OpenDataException
{
         Map<String, Object> reqItems = new HashMap<String, Object>();
 
         TabularData attributes = new TabularDataSupport(BundleRevisionsStateMBean.ATTRIBUTES_TYPE);

Modified: aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/BundleRevisionsState.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/BundleRevisionsState.java?rev=1209453&r1=1209452&r2=1209453&view=diff
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/BundleRevisionsState.java
(original)
+++ aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/BundleRevisionsState.java
Fri Dec  2 13:10:59 2011
@@ -24,6 +24,7 @@ import javax.management.openmbean.Compos
 import javax.management.openmbean.CompositeType;
 
 import org.apache.aries.jmx.Logger;
+import org.apache.aries.jmx.codec.BundleRequirementsData;
 import org.apache.aries.jmx.codec.BundleWiringData;
 import org.apache.aries.jmx.util.FrameworkUtils;
 import org.osgi.framework.Bundle;
@@ -48,9 +49,12 @@ public class BundleRevisionsState implem
     /* (non-Javadoc)
      * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getCurrentRevisionDeclaredRequirements(long,
java.lang.String)
      */
-    public ArrayType getCurrentRevisionDeclaredRequirements(long bundleId, String namespace)
{
-        // TODO Auto-generated method stub
-        return null;
+    public CompositeData[] getCurrentRevisionDeclaredRequirements(long bundleId, String namespace)
throws IOException {
+        Bundle bundle = FrameworkUtils.resolveBundle(bundleContext, bundleId);
+        BundleWiring wiring = bundle.adapt(BundleWiring.class);
+
+        BundleRequirementsData data = new BundleRequirementsData(wiring.getRequirements(namespace));
+        return data.toCompositeData();
     }
 
     /* (non-Javadoc)
@@ -88,7 +92,7 @@ public class BundleRevisionsState implem
     /* (non-Javadoc)
      * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getRevisionsDeclaredRequirements(long,
java.lang.String, boolean)
      */
-    public ArrayType getRevisionsDeclaredRequirements(long bundleId, String namespace, boolean
inUse) {
+    public ArrayType getRevisionsDeclaredRequirements(long bundleId, String namespace) {
         // TODO Auto-generated method stub
         return null;
     }
@@ -96,7 +100,7 @@ public class BundleRevisionsState implem
     /* (non-Javadoc)
      * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getRevisionsDeclaredCapabilities(long,
java.lang.String, boolean)
      */
-    public ArrayType getRevisionsDeclaredCapabilities(long bundleId, String namespace, boolean
inUse) {
+    public ArrayType getRevisionsDeclaredCapabilities(long bundleId, String namespace) {
         // TODO Auto-generated method stub
         return null;
     }

Modified: aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleRevisionsStateMBeanTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleRevisionsStateMBeanTest.java?rev=1209453&r1=1209452&r2=1209453&view=diff
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleRevisionsStateMBeanTest.java
(original)
+++ aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/BundleRevisionsStateMBeanTest.java
Fri Dec  2 13:10:59 2011
@@ -120,6 +120,19 @@ public class BundleRevisionsStateMBeanTe
     }
 
     @Test
+    public void testGetCurrentRevisionDeclaredRequirements() throws IOException {
+        BundleRevisionsStateMBean brsMBean = getMBean(BundleRevisionsStateMBean.OBJECTNAME,
BundleRevisionsStateMBean.class);
+
+        Bundle a = context().getBundleByName("org.apache.aries.jmx.test.bundlea");
+        BundleWiring bw = a.adapt(BundleWiring.class);
+
+        List<BundleRequirement> requirements = bw.getRequirements(BundleRevision.PACKAGE_NAMESPACE);
+        CompositeData[] jmxRequirements = brsMBean.getCurrentRevisionDeclaredRequirements(a.getBundleId(),
BundleRevisionsStateMBean.PACKAGE_NAMESPACE);
+        Assert.assertEquals(requirements.size(), jmxRequirements.length);
+
+    }
+
+    @Test
     public void testGetCurrentWiring() throws IOException {
         BundleRevisionsStateMBean brsMBean = getMBean(BundleRevisionsStateMBean.OBJECTNAME,
BundleRevisionsStateMBean.class);
 



Mime
View raw message