Search in sources :

Example 6 with BundleRevisions

use of org.osgi.framework.wiring.BundleRevisions in project felix by apache.

the class DTOFactory method createBundleWiringDTOArray.

private static BundleWiringDTO[] createBundleWiringDTOArray(Bundle bundle) {
    BundleRevisions brs = bundle.adapt(BundleRevisions.class);
    if (brs == null || brs.getRevisions() == null)
        return null;
    List<BundleRevision> revisions = brs.getRevisions();
    BundleWiringDTO[] dtos = new BundleWiringDTO[revisions.size()];
    for (int i = 0; i < revisions.size(); i++) {
        BundleWiring wiring = revisions.get(i).getWiring();
        dtos[i] = createBundleWiringDTO(wiring);
    }
    return dtos;
}
Also used : BundleWiring(org.osgi.framework.wiring.BundleWiring) BundleRevision(org.osgi.framework.wiring.BundleRevision) BundleWiringDTO(org.osgi.framework.wiring.dto.BundleWiringDTO) BundleRevisions(org.osgi.framework.wiring.BundleRevisions)

Example 7 with BundleRevisions

use of org.osgi.framework.wiring.BundleRevisions in project aries by apache.

the class BundleWiringState method getRevisionsWiring.

/* (non-Javadoc)
     * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getRevisionsWiring(long, java.lang.String)
     */
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.BUNDLES_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;
}
Also used : Bundle(org.osgi.framework.Bundle) TabularDataSupport(javax.management.openmbean.TabularDataSupport) BundleRevision(org.osgi.framework.wiring.BundleRevision) BundleRevisions(org.osgi.framework.wiring.BundleRevisions) TabularData(javax.management.openmbean.TabularData)

Example 8 with BundleRevisions

use of org.osgi.framework.wiring.BundleRevisions in project aries by apache.

the class BundleWiringState method getRevisionsWiringClosure.

/* (non-Javadoc)
     * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getWiringClosure(long, java.lang.String)
     */
public TabularData getRevisionsWiringClosure(long rootBundleId, String namespace) throws IOException {
    Bundle bundle = FrameworkUtils.resolveBundle(bundleContext, rootBundleId);
    BundleRevisions revisions = bundle.adapt(BundleRevisions.class);
    Map<BundleRevision, Integer> revisionIDMap = new HashMap<BundleRevision, Integer>();
    for (BundleRevision revision : revisions.getRevisions()) {
        populateTransitiveRevisions(namespace, revision, revisionIDMap);
    }
    // Set the root current revision ID to 0,
    // TODO check if there is already a revision with ID 0 and if so swap them. Quite a small chance that this will be needed
    BundleRevision revision = bundle.adapt(BundleRevision.class);
    revisionIDMap.put(revision, 0);
    TabularData td = new TabularDataSupport(BundleWiringStateMBean.BUNDLES_WIRING_TYPE);
    for (Map.Entry<BundleRevision, Integer> entry : revisionIDMap.entrySet()) {
        td.put(getRevisionWiring(entry.getKey(), entry.getValue(), namespace, revisionIDMap));
    }
    return td;
}
Also used : HashMap(java.util.HashMap) Bundle(org.osgi.framework.Bundle) TabularDataSupport(javax.management.openmbean.TabularDataSupport) BundleRevision(org.osgi.framework.wiring.BundleRevision) HashMap(java.util.HashMap) Map(java.util.Map) BundleRevisions(org.osgi.framework.wiring.BundleRevisions) TabularData(javax.management.openmbean.TabularData)

Example 9 with BundleRevisions

use of org.osgi.framework.wiring.BundleRevisions in project aries by apache.

the class BundleWiringState method getRevisionsDeclaredRequirements.

/* (non-Javadoc)
     * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getRevisionsDeclaredRequirements(long, java.lang.String, boolean)
     */
public TabularData getRevisionsDeclaredRequirements(long bundleId, String namespace) throws IOException {
    Bundle bundle = FrameworkUtils.resolveBundle(bundleContext, bundleId);
    BundleRevisions revisions = bundle.adapt(BundleRevisions.class);
    TabularData td = new TabularDataSupport(BundleWiringStateMBean.REVISIONS_REQUIREMENTS_TYPE);
    for (BundleRevision revision : revisions.getRevisions()) {
        td.put(BundleWiringData.getRevisionRequirements(System.identityHashCode(revision), revision.getDeclaredRequirements(namespace)));
    }
    return td;
}
Also used : Bundle(org.osgi.framework.Bundle) TabularDataSupport(javax.management.openmbean.TabularDataSupport) BundleRevision(org.osgi.framework.wiring.BundleRevision) BundleRevisions(org.osgi.framework.wiring.BundleRevisions) TabularData(javax.management.openmbean.TabularData)

Example 10 with BundleRevisions

use of org.osgi.framework.wiring.BundleRevisions in project aries by apache.

the class BundleWiringStateMBeanTest method testGetRevisionsDeclaredRequirements.

@Test
public void testGetRevisionsDeclaredRequirements() throws Exception {
    BundleRevisions revisions = (BundleRevisions) bundleA.adapt(BundleRevisions.class);
    Assert.assertEquals("Precondition", 1, revisions.getRevisions().size());
    TabularData jmxRequirementsTable = brsMBean.getRevisionsDeclaredRequirements(bundleA.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
    Assert.assertEquals(1, jmxRequirementsTable.size());
    List<BundleRequirement> requirements = ((BundleRevision) revisions.getRevisions().iterator().next()).getDeclaredRequirements(BundleRevision.PACKAGE_NAMESPACE);
    CompositeData jmxRevRequirements = (CompositeData) jmxRequirementsTable.values().iterator().next();
    CompositeData[] jmxRequirements = (CompositeData[]) jmxRevRequirements.get(BundleWiringStateMBean.REQUIREMENTS);
    Map<Map<String, Object>, Map<String, String>> expectedRequirements = requirementsToMap(requirements);
    Map<Map<String, Object>, Map<String, String>> actualRequirements = jmxCapReqToMap(jmxRequirements);
    Assert.assertEquals(expectedRequirements, actualRequirements);
}
Also used : CompositeData(javax.management.openmbean.CompositeData) BundleRevision(org.osgi.framework.wiring.BundleRevision) HashMap(java.util.HashMap) Map(java.util.Map) BundleRequirement(org.osgi.framework.wiring.BundleRequirement) BundleRevisions(org.osgi.framework.wiring.BundleRevisions) TabularData(javax.management.openmbean.TabularData) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.jmx.AbstractIntegrationTest)

Aggregations

BundleRevisions (org.osgi.framework.wiring.BundleRevisions)14 BundleRevision (org.osgi.framework.wiring.BundleRevision)11 Bundle (org.osgi.framework.Bundle)8 TabularData (javax.management.openmbean.TabularData)6 AbstractIntegrationTest (org.apache.aries.jmx.AbstractIntegrationTest)5 Test (org.junit.Test)5 BundleWiring (org.osgi.framework.wiring.BundleWiring)5 CompositeData (javax.management.openmbean.CompositeData)4 TabularDataSupport (javax.management.openmbean.TabularDataSupport)4 BundleWire (org.osgi.framework.wiring.BundleWire)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 JarOutputStream (java.util.jar.JarOutputStream)3 Manifest (java.util.jar.Manifest)3 Version (org.osgi.framework.Version)3 FrameworkMBean (org.osgi.jmx.framework.FrameworkMBean)2 HashSet (java.util.HashSet)1