Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2011-03-11 11:58:34 +0000
committerGlyn Normington2011-03-11 11:58:34 +0000
commit5eaa7ec63738c07402c6968f9366f26f757f1683 (patch)
treef3d6248f7d83edeb15864ec35841cce14ee5b26e
parent36afe704889052aae229e3e04449a597cf202e8c (diff)
downloadorg.eclipse.virgo.kernel-5eaa7ec63738c07402c6968f9366f26f757f1683.tar.gz
org.eclipse.virgo.kernel-5eaa7ec63738c07402c6968f9366f26f757f1683.tar.xz
org.eclipse.virgo.kernel-5eaa7ec63738c07402c6968f9366f26f757f1683.zip
bug 336941: move visitor logic into visitor
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleFindHook.java47
1 files changed, 25 insertions, 22 deletions
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleFindHook.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleFindHook.java
index b0099615..60f49ba0 100644
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleFindHook.java
+++ b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleFindHook.java
@@ -86,12 +86,31 @@ public final class RegionBundleFindHook implements FindHook {
return this.bundles;
}
- private void pushAllowed() {
+ private void preEdge(FilteredRegion fr) {
synchronized (this.monitor) {
this.allowedStack.push(this.allowed);
this.allowed = new HashSet<Bundle>();
}
}
+
+ private void postEdge(FilteredRegion fr) {
+ Set<Bundle> a = getAllowed();
+ popAllowed();
+ filter(a, fr.getFilter());
+ getAllowed().addAll(a);
+ }
+
+ private void filter(Set<Bundle> bundles, RegionFilter filter) {
+ Iterator<Bundle> i = bundles.iterator();
+ while (i.hasNext()) {
+ Bundle b = i.next();
+ if (!filter.isBundleAllowed(b.getSymbolicName(), b.getVersion())) {
+ i.remove();
+ }
+ }
+ }
+
+
private void popAllowed() {
synchronized (this.monitor) {
@@ -99,7 +118,7 @@ public final class RegionBundleFindHook implements FindHook {
}
}
- private void allowInRegion(Region r) {
+ private void visit(Region r) {
for (Bundle b : this.bundles) {
if (r.contains(b)) {
getAllowed().add(b);
@@ -111,7 +130,7 @@ public final class RegionBundleFindHook implements FindHook {
private Set<Bundle> getAllowed(Region r, Visitor visitor, Set<Region> path) {
if (!path.contains(r)) {
- visitor.allowInRegion(r);
+ visitor.visit(r);
allowImportedBundles(r, visitor, path);
}
@@ -120,34 +139,18 @@ public final class RegionBundleFindHook implements FindHook {
private void allowImportedBundles(Region r, Visitor visitor, Set<Region> path) {
for (FilteredRegion fr : this.regionDigraph.getEdges(r)) {
- allowTransitive(r, visitor, path, fr);
+ visitor.preEdge(fr);
+ getAllowed(fr.getRegion(), visitor, extendPath(r, path));
+ visitor.postEdge(fr);
}
}
- private void allowTransitive(Region r, Visitor visitor, Set<Region> path, FilteredRegion fr) {
- visitor.pushAllowed();
- getAllowed(fr.getRegion(), visitor, extendPath(r, path));
- Set<Bundle> a = visitor.getAllowed();
- visitor.popAllowed();
- filter(a, fr.getFilter());
- visitor.getAllowed().addAll(a);
- }
-
private Set<Region> extendPath(Region r, Set<Region> path) {
Set<Region> newPath = new HashSet<Region>(path);
newPath.add(r);
return newPath;
}
- private void filter(Set<Bundle> bundles, RegionFilter filter) {
- Iterator<Bundle> i = bundles.iterator();
- while (i.hasNext()) {
- Bundle b = i.next();
- if (!filter.isBundleAllowed(b.getSymbolicName(), b.getVersion())) {
- i.remove();
- }
- }
- }
private Region getRegion(BundleContext context) {
Bundle b = context.getBundle();

Back to the top