use of org.eclipse.equinox.region.RegionFilterBuilder in project aries by apache.
the class StartAction method setExportIsolationPolicy.
private static void setExportIsolationPolicy(final BasicSubsystem subsystem, Coordination coordination) throws InvalidSyntaxException {
if (!subsystem.isComposite())
return;
final Region from = ((BasicSubsystem) subsystem.getParents().iterator().next()).getRegion();
final Region to = subsystem.getRegion();
RegionFilterBuilder builder = from.getRegionDigraph().createRegionFilterBuilder();
setExportIsolationPolicy(builder, subsystem.getDeploymentManifest().getExportPackageHeader(), subsystem);
setExportIsolationPolicy(builder, subsystem.getDeploymentManifest().getProvideCapabilityHeader(), subsystem);
setExportIsolationPolicy(builder, subsystem.getDeploymentManifest().getSubsystemExportServiceHeader(), subsystem);
RegionFilter regionFilter = builder.build();
if (regionFilter.getSharingPolicy().isEmpty())
return;
if (logger.isDebugEnabled())
logger.debug("Establishing region connection: from=" + from + ", to=" + to + ", filter=" + regionFilter);
try {
from.connectRegion(to, regionFilter);
} catch (BundleException e) {
// been set. Bad assumption?
return;
}
coordination.addParticipant(new Participant() {
@Override
public void ended(Coordination coordination) throws Exception {
// It may be necessary to rollback the export sharing policy
// even when the coordination did not fail. For example, this
// might have been a subsystem whose export sharing policy was
// set just in case it offered dependencies for some other
// subsystem.
unsetExportIsolationPolicyIfNecessary();
}
@Override
public void failed(Coordination coordination) throws Exception {
// Nothing to do because a coordination is always ended.
}
private void unsetExportIsolationPolicyIfNecessary() throws BundleException, InvalidSyntaxException {
if (!EnumSet.of(State.INSTALLING, State.INSTALLED).contains(subsystem.getState())) {
// does not require a rollback.
return;
}
// The subsystem is either INSTALLING or INSTALLED and therefore
// requires a rollback since the export sharing policy must only
// be set upon entering the RESOLVED state.
RegionUpdater updater = new RegionUpdater(from, to);
updater.addRequirements(null);
}
});
}
use of org.eclipse.equinox.region.RegionFilterBuilder in project aries by apache.
the class RegionUpdater method addHeadRegions.
private void addHeadRegions(Map<String, RegionFilterBuilder> heads, Region tail, RegionDigraph digraph) throws BundleException {
for (Map.Entry<String, RegionFilterBuilder> entry : heads.entrySet()) {
RegionFilterBuilder builder = entry.getValue();
if (builder == null) {
continue;
}
tail.connectRegion(digraph.getRegion(entry.getKey()), builder.build());
}
}
use of org.eclipse.equinox.region.RegionFilterBuilder in project karaf by apache.
the class BundleInstallSupportImpl method replaceDigraph.
/* (non-Javadoc)
* @see org.apache.karaf.features.internal.service.Regions#replaceDigraph(java.util.Map, java.util.Map)
*/
@Override
public void replaceDigraph(Map<String, Map<String, Map<String, Set<String>>>> policies, Map<String, Set<Long>> bundles) throws BundleException, InvalidSyntaxException {
RegionDigraph temp = digraph.copy();
// Remove everything
for (Region region : temp.getRegions()) {
temp.removeRegion(region);
}
// Re-create regions
for (String name : policies.keySet()) {
temp.createRegion(name);
}
// Dispatch bundles
for (Map.Entry<String, Set<Long>> entry : bundles.entrySet()) {
Region region = temp.getRegion(entry.getKey());
for (long bundleId : entry.getValue()) {
region.addBundle(bundleId);
}
}
// Add policies
for (Map.Entry<String, Map<String, Map<String, Set<String>>>> entry1 : policies.entrySet()) {
Region region1 = temp.getRegion(entry1.getKey());
for (Map.Entry<String, Map<String, Set<String>>> entry2 : entry1.getValue().entrySet()) {
Region region2 = temp.getRegion(entry2.getKey());
RegionFilterBuilder rfb = temp.createRegionFilterBuilder();
for (Map.Entry<String, Set<String>> entry3 : entry2.getValue().entrySet()) {
for (String flt : entry3.getValue()) {
rfb.allow(entry3.getKey(), flt);
}
}
region1.connectRegion(region2, rfb.build());
}
}
digraph.replace(temp);
}
Aggregations