use of org.osgi.framework.wiring.BundleRevision in project aries by apache.
the class BundleWiringStateMBeanTest method testGetCurrentRevisionDeclaredRequirements.
@Test
public void testGetCurrentRevisionDeclaredRequirements() throws Exception {
Bundle a = getBundleByName("org.apache.aries.jmx.test.bundlea");
BundleRevision br = (BundleRevision) a.adapt(BundleRevision.class);
List<BundleRequirement> requirements = br.getDeclaredRequirements(BundleRevision.PACKAGE_NAMESPACE);
CompositeData[] jmxRequirements = brsMBean.getCurrentRevisionDeclaredRequirements(a.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
Assert.assertEquals(requirements.size(), jmxRequirements.length);
Map<Map<String, Object>, Map<String, String>> expectedRequirements = requirementsToMap(requirements);
Map<Map<String, Object>, Map<String, String>> actualRequirements = jmxCapReqToMap(jmxRequirements);
Assert.assertEquals(expectedRequirements, actualRequirements);
}
use of org.osgi.framework.wiring.BundleRevision in project aries by apache.
the class BundleEventHook method handleUninstalledEvent.
@SuppressWarnings("unchecked")
private void handleUninstalledEvent(BundleEvent event) {
Bundle bundle = event.getBundle();
BundleRevision revision = bundleToRevision.remove(bundle);
if (ThreadLocalSubsystem.get() != null || (revision == null ? false : // Region context bundles must be treated as explicit installations.
revision.getSymbolicName().startsWith(Constants.RegionContextBundleSymbolicNamePrefix))) {
return;
}
Collection<BasicSubsystem> subsystems;
if (revision == null) {
// The bundle was installed while the bundle event hook was unregistered.
Object[] o = activator.getSubsystems().getSubsystemsByBundle(bundle);
if (o == null)
return;
revision = (BundleRevision) o[0];
subsystems = (Collection<BasicSubsystem>) o[1];
} else {
subsystems = activator.getSubsystems().getSubsystemsByConstituent(new BundleConstituent(null, revision));
}
for (BasicSubsystem subsystem : subsystems) {
ResourceUninstaller.newInstance(revision, subsystem).uninstall();
}
}
use of org.osgi.framework.wiring.BundleRevision in project aries by apache.
the class BundleResourceUninstaller method uninstall.
public void uninstall() {
removeReference();
// Always remove the bundle as a constituent of the subsystem being
// acted upon. The bundle may or may not actually be a constituent.
// This covers the case of unscoped subsystems with shared content
// where the resource may not be uninstallable.
removeConstituent(subsystem, new BundleConstituent(null, (BundleRevision) resource));
if (!isResourceUninstallable())
return;
// If the resource is uninstallable, remove it from the "provisioned to"
// subsystem in case it was a dependency. The "provisioned to" subsystem
// may be the same subsystem as the one being acted upon. This covers
// the case where a dependency of the subsystem being acted upon was
// provisioned to another subsystem but is not content of the other
// subsystem.
removeConstituent(provisionTo, new BundleConstituent(null, (BundleRevision) resource));
if (isBundleUninstallable())
uninstallBundle();
}
use of org.osgi.framework.wiring.BundleRevision in project aries by apache.
the class StartAction method getBundles.
private static Collection<Bundle> getBundles(BasicSubsystem subsystem) {
Collection<Resource> constituents = Activator.getInstance().getSubsystems().getConstituents(subsystem);
ArrayList<Bundle> result = new ArrayList<Bundle>(constituents.size());
for (Resource resource : constituents) {
if (resource instanceof BundleRevision)
result.add(((BundleRevision) resource).getBundle());
}
result.trimToSize();
return result;
}
use of org.osgi.framework.wiring.BundleRevision in project aries by apache.
the class RegionContextBundleHelper method uninstallRegionContextBundle.
public static void uninstallRegionContextBundle(BasicSubsystem subsystem) {
String symbolicName = SYMBOLICNAME_PREFIX + subsystem.getSubsystemId();
Bundle bundle = subsystem.getRegion().getBundle(symbolicName, VERSION);
if (bundle == null)
return;
BundleRevision revision = bundle.adapt(BundleRevision.class);
try {
bundle.uninstall();
} catch (BundleException e) {
// TODO Should we really eat this? At least log it?
}
ResourceUninstaller.newInstance(revision, subsystem).uninstall();
subsystem.setRegionContextBundle(null);
}
Aggregations