use of org.eclipse.equinox.region.RegionDigraph in project aries by apache.
the class BundleEventHook method handleExplicitlyInstalledBundleRegionDigraph.
private void handleExplicitlyInstalledBundleRegionDigraph(Bundle origin, BundleRevision bundleRevision) {
// The bundle needs to be associated with the scoped subsystem of
// the region used to install the bundle.
RegionDigraph digraph = activator.getRegionDigraph();
Region region = digraph.getRegion(origin);
for (BasicSubsystem s : getSubsystems().getSubsystems()) {
if ((s.isApplication() || s.isComposite()) && region.equals(s.getRegion())) {
Utils.installResource(bundleRevision, s);
return;
}
}
throw new IllegalStateException("No subsystem found for bundle " + bundleRevision + " in region " + region);
}
use of org.eclipse.equinox.region.RegionDigraph in project aries by apache.
the class SubsystemTest method uninstallSubsystem.
protected void uninstallSubsystem(Subsystem subsystem, boolean quietly) throws Exception {
BasicSubsystem basicSubsystem = (BasicSubsystem) subsystem;
AriesProvisionDependenciesDirective directive = basicSubsystem.getAriesProvisionDependenciesDirective();
Bundle b = null;
Region region = null;
RegionDigraph digraph = context().getService(RegionDigraph.class);
if (!quietly) {
if (directive.isResolve()) {
assertState(EnumSet.of(State.INSTALLING, State.INSTALLED, State.RESOLVED), subsystem);
} else {
assertState(EnumSet.of(State.INSTALLED, State.RESOLVED), subsystem);
}
subsystemEvents.clear();
if (subsystem.getType().equals(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION) || subsystem.getType().equals(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE)) {
b = getRegionContextBundle(subsystem);
region = digraph.getRegion(b);
}
}
State state = subsystem.getState();
subsystem.uninstall();
if (quietly) {
return;
}
Collection<Subsystem> parents = subsystem.getParents();
if (!EnumSet.of(State.INSTALL_FAILED, State.INSTALLED, State.INSTALLING).contains(state)) {
assertEvent(subsystem, State.INSTALLED, 5000);
}
assertEvent(subsystem, State.UNINSTALLING, 5000);
assertEvent(subsystem, State.UNINSTALLED, 5000);
assertState(State.UNINSTALLED, subsystem);
for (Subsystem parent : parents) {
assertNotChild(parent, subsystem);
}
if (subsystem.getType().equals(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION) || subsystem.getType().equals(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE)) {
assertEquals("Region context bundle not uninstalled", Bundle.UNINSTALLED, b.getState());
assertNull("Region not removed", digraph.getRegion(region.getName()));
}
}
use of org.eclipse.equinox.region.RegionDigraph in project aries by apache.
the class SubsystemTest method getRegion.
protected Region getRegion(Subsystem subsystem) {
RegionDigraph digraph = context().getService(RegionDigraph.class);
String name = getRegionName(subsystem);
Region region = digraph.getRegion(name);
assertNotNull("Region not found: " + name, region);
return region;
}
use of org.eclipse.equinox.region.RegionDigraph in project aries by apache.
the class SubsystemTest method tearDown.
@SuppressWarnings("rawtypes")
@After
public void tearDown() throws Exception {
for (Subsystem subsystem : stoppableSubsystems) {
stopSubsystemSilently(subsystem);
}
for (Subsystem subsystem : uninstallableSubsystems) {
uninstallSubsystemSilently(subsystem);
}
RegionDigraph digraph = context().getService(RegionDigraph.class);
for (Region region : deletableRegions) {
digraph.removeRegion(region);
}
for (Bundle bundle : uninstallableBundles) {
uninstallSilently(bundle);
}
bundleContext.removeServiceListener(subsystemEvents);
for (ServiceRegistration registration : serviceRegistrations) Utils.unregisterQuietly(registration);
}
use of org.eclipse.equinox.region.RegionDigraph in project aries by apache.
the class RootSubsystemTest method testRegion.
/*
* The root subsystem should be associated with the region in which the
* subsystems implementation bundle is installed.
*/
@Test
public void testRegion() throws Exception {
RegionDigraph digraph = context().getService(RegionDigraph.class);
Bundle core = getSubsystemCoreBundle();
Region kernel = digraph.getRegion(core);
Subsystem root = getRootSubsystem();
Bundle rootRegionContext = root.getBundleContext().getBundle();
// Get the region containing the subsystem's region context bundle,
// which is the same thing as getting the region with which the
// subsystem is associated.
Region region = digraph.getRegion(root.getBundleContext().getBundle());
assertEquals("Wrong region", kernel, region);
// Uninstall the core bundle to remove the persisted root subsystem.
core.uninstall();
// Clean up the lingering region context bundle.
rootRegionContext.uninstall();
// Create a new region and install the core bundle into it.
Region user = digraph.createRegion("user");
// Allow everything from the kernel region into the user region so the
// core bundle will resolve.
user.connectRegion(kernel, digraph.createRegionFilterBuilder().allowAll(RegionFilter.VISIBLE_ALL_NAMESPACE).build());
// Allow everything from the user region into the kernel region so the
// root subsystem service can be found.
kernel.connectRegion(user, digraph.createRegionFilterBuilder().allowAll(RegionFilter.VISIBLE_ALL_NAMESPACE).build());
core = user.installBundle(normalizeBundleLocation(core.getLocation()));
user = digraph.getRegion(core);
core.start();
root = getRootSubsystem();
region = digraph.getRegion(root.getBundleContext().getBundle());
// The root subsystem should now be in the new region.
assertEquals("Wrong region", user, region);
// should still be found and used.
try {
Subsystem applicationA = installSubsystemFromFile(root, APPLICATION_A);
uninstallSubsystemSilently(applicationA);
} catch (Exception e) {
e.printStackTrace();
fail("Subsystem should have installed");
}
}
Aggregations