use of org.osgi.framework.wiring.BundleRevision in project aries by apache.
the class Subsystems method populateRootSubsystem.
private void populateRootSubsystem(BasicSubsystem root, Coordination coordination) throws Exception {
// TODO Begin proof of concept.
// This is a proof of concept for initializing the relationships between the root subsystem and bundles
// that already existed in its region. Not sure this will be the final resting place. Plus, there are issues
// since this does not take into account the possibility of already existing bundles going away or new bundles
// being installed out of band while this initialization is taking place. Need a bundle event hook for that.
BundleContext context = Activator.getInstance().getBundleContext().getBundle(org.osgi.framework.Constants.SYSTEM_BUNDLE_LOCATION).getBundleContext();
for (Bundle bundle : context.getBundles()) {
BundleRevision revision = bundle.adapt(BundleRevision.class);
if (revision == null)
// The bundle has been uninstalled. Do not process.
continue;
if (!resourceReferences.getSubsystems(revision).isEmpty())
continue;
ResourceInstaller.newInstance(coordination, revision, root).install();
}
// TODO End proof of concept.
}
use of org.osgi.framework.wiring.BundleRevision in project aries by apache.
the class BundleRevisionResourceTest method testNoModellerServiceCapabilities.
@Test
public void testNoModellerServiceCapabilities() {
BundleRevision br = createNiceMock(BundleRevision.class);
expect(br.getCapabilities(anyObject(String.class))).andReturn(Collections.<Capability>emptyList());
expect(br.getRequirements(anyObject(String.class))).andReturn(Collections.<Requirement>emptyList());
replay(br);
BundleRevisionResource brr = new BundleRevisionResource(br);
assertEquals(0, brr.getCapabilities("osgi.service").size());
}
use of org.osgi.framework.wiring.BundleRevision in project aries by apache.
the class Aries1417Test method testOsgiImplementation.
@Test
public void testOsgiImplementation() throws Exception {
Bundle bundle = getSubsystemCoreBundle();
BundleRevision revision = bundle.adapt(BundleRevision.class);
List<Capability> capabilities = revision.getCapabilities(ImplementationNamespace.IMPLEMENTATION_NAMESPACE);
assertEquals("Wrong capabilities", 1, capabilities.size());
Capability capability = capabilities.get(0);
Map<String, Object> attributes = capability.getAttributes();
assertEquals("Wrong namespace value", "osgi.subsystem", attributes.get(ImplementationNamespace.IMPLEMENTATION_NAMESPACE));
Object version = attributes.get(ImplementationNamespace.CAPABILITY_VERSION_ATTRIBUTE);
assertTrue("Wrong version type", version instanceof Version);
assertEquals("Wrong version", Version.parseVersion("1.1"), version);
assertEquals("Wrong uses", "org.osgi.service.subsystem", capability.getDirectives().get(ImplementationNamespace.CAPABILITY_USES_DIRECTIVE));
}
use of org.osgi.framework.wiring.BundleRevision in project aries by apache.
the class Aries1417Test method testOsgiService.
@Test
public void testOsgiService() throws Exception {
Bundle bundle = getSubsystemCoreBundle();
BundleRevision revision = bundle.adapt(BundleRevision.class);
List<Capability> capabilities = revision.getCapabilities(ServiceNamespace.SERVICE_NAMESPACE);
assertEquals("Wrong capabilities", 1, capabilities.size());
Capability capability = capabilities.get(0);
Map<String, Object> attributes = capability.getAttributes();
Object objectClass = attributes.get(ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE);
assertTrue("Wrong objectClass type", objectClass instanceof List);
@SuppressWarnings({ "rawtypes" }) List objectClassList = (List) objectClass;
assertEquals("Wrong objectClass size", 2, objectClassList.size());
Object objectClass1 = objectClassList.get(0);
assertTrue("Wrong objectClass type", objectClass1 instanceof String);
assertEquals("Wrong objectClass", "org.osgi.service.subsystem.Subsystem", objectClass1);
Object objectClass2 = objectClassList.get(1);
assertTrue("Wrong objectClass type", objectClass2 instanceof String);
assertEquals("Wrong objectClass", "org.apache.aries.subsystem.AriesSubsystem", objectClass2);
assertEquals("Wrong uses", "org.osgi.service.subsystem,org.apache.aries.subsystem", capability.getDirectives().get(ServiceNamespace.CAPABILITY_USES_DIRECTIVE));
}
use of org.osgi.framework.wiring.BundleRevision 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;
}
Aggregations