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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations