aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1209573 - in /aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx: codec/BundleRequirementsData.java codec/BundleWiringData.java framework/BundleRevisionsState.java
Date Fri, 02 Dec 2011 16:43:39 GMT
Author: davidb
Date: Fri Dec  2 16:43:38 2011
New Revision: 1209573

URL: http://svn.apache.org/viewvc?rev=1209573&view=rev
Log:
Small refactor in the jmx-next codebase.

Removed:
    aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/BundleRequirementsData.java
Modified:
    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

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=1209573&r1=1209572&r2=1209573&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 16:43:38 2011
@@ -91,7 +91,43 @@ public class BundleWiringData {
         return reqData;
     }
 
-    static CompositeData getCapReqCompositeData(CompositeType type, String namespace, Set<Map.Entry<String,Object>>
attributeSet, Set<Map.Entry<String,String>> directiveSet) throws OpenDataException
{
+    public static CompositeData[] getCapabilitiesCompositeData(List<BundleCapability>
bundleCapabilities) {
+        try {
+            CompositeData[] data = new CompositeData[bundleCapabilities.size()];
+
+            for (int i=0; i < bundleCapabilities.size(); i++) {
+                BundleCapability requirement = bundleCapabilities.get(i);
+
+                CompositeData cd = BundleWiringData.getCapReqCompositeData(BundleRevisionsStateMBean.BUNDLE_CAPABILITY_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);
+        }
+    }
+
+    public static CompositeData[] getRequirementsCompositeData(List<BundleRequirement>
bundleRequirements) {
+        try {
+            CompositeData[] data = new CompositeData[bundleRequirements.size()];
+
+            for (int i=0; i < bundleRequirements.size(); i++) {
+                BundleRequirement requirement = bundleRequirements.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);
+        }
+    }
+
+    private 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=1209573&r1=1209572&r2=1209573&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 16:43:38 2011
@@ -28,7 +28,6 @@ import javax.management.openmbean.Tabula
 import javax.management.openmbean.TabularDataSupport;
 
 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;
@@ -57,8 +56,7 @@ public class BundleRevisionsState implem
         Bundle bundle = FrameworkUtils.resolveBundle(bundleContext, bundleId);
         BundleRevision revision = bundle.adapt(BundleRevision.class);
 
-        BundleRequirementsData data = new BundleRequirementsData(revision.getDeclaredRequirements(namespace));
-        return data.toCompositeData();
+        return BundleWiringData.getRequirementsCompositeData(revision.getDeclaredRequirements(namespace));
     }
 
     /* (non-Javadoc)
@@ -79,17 +77,6 @@ public class BundleRevisionsState implem
         return getRevisionWiring(currentRevision, 0, namespace, revisionIDMap);
     }
 
-    private CompositeData getRevisionWiring(BundleRevision revision, int revisionID, String
namespace, Map<BundleRevision, Integer> revisionIDMap) {
-        BundleWiring wiring = revision.getWiring();
-        List<BundleCapability> capabilities = wiring.getCapabilities(namespace);
-        List<BundleRequirement> requirements = wiring.getRequirements(namespace);
-        List<BundleWire> providedWires = wiring.getProvidedWires(namespace);
-        List<BundleWire> requiredWires = wiring.getRequiredWires(namespace);
-
-        BundleWiringData data = new BundleWiringData(wiring.getBundle().getBundleId(), revisionID,
capabilities, requirements, providedWires, requiredWires, revisionIDMap);
-        return data.toCompositeData();
-    }
-
     /* (non-Javadoc)
      * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getCurrentWiringClosure(long)
      */
@@ -131,6 +118,17 @@ public class BundleRevisionsState implem
         }
     }
 
+    private CompositeData getRevisionWiring(BundleRevision revision, int revisionID, String
namespace, Map<BundleRevision, Integer> revisionIDMap) {
+        BundleWiring wiring = revision.getWiring();
+        List<BundleCapability> capabilities = wiring.getCapabilities(namespace);
+        List<BundleRequirement> requirements = wiring.getRequirements(namespace);
+        List<BundleWire> providedWires = wiring.getProvidedWires(namespace);
+        List<BundleWire> requiredWires = wiring.getRequiredWires(namespace);
+
+        BundleWiringData data = new BundleWiringData(wiring.getBundle().getBundleId(), revisionID,
capabilities, requirements, providedWires, requiredWires, revisionIDMap);
+        return data.toCompositeData();
+    }
+
     /* (non-Javadoc)
      * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getRevisionsDeclaredRequirements(long,
java.lang.String, boolean)
      */



Mime
View raw message