Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2011-03-11 07:48:46 -0500
committerGlyn Normington2011-03-11 07:48:46 -0500
commit8f64e16cb93381c4532b57963d9b02e885e8e17d (patch)
treec0a2935675dcb8c9a3c5981db6a7577d463d801c
parente2845d1057e0808d51cf3caf640ae25a4c7a9e21 (diff)
downloadorg.eclipse.virgo.kernel-8f64e16cb93381c4532b57963d9b02e885e8e17d.tar.gz
org.eclipse.virgo.kernel-8f64e16cb93381c4532b57963d9b02e885e8e17d.tar.xz
org.eclipse.virgo.kernel-8f64e16cb93381c4532b57963d9b02e885e8e17d.zip
bug 336941: move classes and interfaces to appropriate locations
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraph.java8
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraphVisitor.java34
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/RegionBundleFindHook.java16
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/SubgraphTraverser.java44
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraph.java12
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/SubgraphTraverser.java58
6 files changed, 114 insertions, 58 deletions
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraph.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraph.java
index 908f8aca..3cd41908 100644
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraph.java
+++ b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraph.java
@@ -133,5 +133,13 @@ public interface RegionDigraph extends Iterable<Region> {
* @return a {@link Set} of {@link FilteredRegion FilteredRegions} of head regions and region filters
*/
Set<FilteredRegion> getEdges(Region tailRegion);
+
+ /**
+ * Visit the subgraph connected to the given region.
+ *
+ * @param startingRegion the region at which to start
+ * @param visitor a {@link RegionDigraphVisitor} to be called as the subgraph is navigated
+ */
+ void visitSubgraph(Region startingRegion, RegionDigraphVisitor visitor);
}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraphVisitor.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraphVisitor.java
new file mode 100644
index 00000000..a94dd3ca
--- /dev/null
+++ b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionDigraphVisitor.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * This file is part of the Virgo Web Server.
+ *
+ * Copyright (c) 2011 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SpringSource, a division of VMware - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.osgi.region;
+
+import org.eclipse.virgo.kernel.osgi.region.RegionDigraph.FilteredRegion;
+
+/**
+ * {@link RegionDigraphVisitor} is used to traverse a subgraph of a {@link RegionDigraph}.
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ *
+ * Implementations of this interface must be thread safe.
+ */
+public interface RegionDigraphVisitor {
+
+ void visit(Region r);
+
+ void preEdgeTraverse(FilteredRegion fr);
+
+ void postEdgeTraverse(FilteredRegion fr);
+
+} \ No newline at end of file
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 0d58e67e..8ab946a1 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
@@ -19,6 +19,7 @@ import java.util.Stack;
import org.eclipse.virgo.kernel.osgi.region.Region;
import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
+import org.eclipse.virgo.kernel.osgi.region.RegionDigraphVisitor;
import org.eclipse.virgo.kernel.osgi.region.RegionDigraph.FilteredRegion;
import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
import org.osgi.framework.Bundle;
@@ -36,11 +37,8 @@ public final class RegionBundleFindHook implements FindHook {
private final RegionDigraph regionDigraph;
- private final SubgraphTraverser subgraphTraverser;
-
public RegionBundleFindHook(RegionDigraph regionDigraph) {
this.regionDigraph = regionDigraph;
- this.subgraphTraverser = new SubgraphTraverser(regionDigraph);
}
/**
@@ -59,22 +57,12 @@ public final class RegionBundleFindHook implements FindHook {
}
Visitor visitor = new Visitor(bundles);
- subgraphTraverser.visitSubgraph(finderRegion, visitor);
+ this.regionDigraph.visitSubgraph(finderRegion, visitor);
Set<Bundle> allowed = visitor.getAllowed();
bundles.retainAll(allowed);
}
- public interface RegionDigraphVisitor {
-
- void visit(Region r);
-
- void preEdgeTraverse(FilteredRegion fr);
-
- void postEdgeTraverse(FilteredRegion fr);
-
- }
-
private class Visitor implements RegionDigraphVisitor {
private Object monitor = new Object();
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/SubgraphTraverser.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/SubgraphTraverser.java
deleted file mode 100644
index 0f19cef0..00000000
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/hook/SubgraphTraverser.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.eclipse.virgo.kernel.osgi.region.hook;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.virgo.kernel.osgi.region.Region;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
-import org.eclipse.virgo.kernel.osgi.region.RegionDigraph.FilteredRegion;
-import org.eclipse.virgo.kernel.osgi.region.hook.RegionBundleFindHook.RegionDigraphVisitor;
-
-public class SubgraphTraverser {
-
- public final RegionDigraph regionDigraph;
-
- public SubgraphTraverser(RegionDigraph regionDigraph) {
- this.regionDigraph = regionDigraph;
- }
-
- void traverseEdges(Region r, RegionDigraphVisitor visitor, Set<Region> path) {
- for (FilteredRegion fr : regionDigraph.getEdges(r)) {
- visitor.preEdgeTraverse(fr);
- visitRemainingSubgraph(fr.getRegion(), visitor, extendPath(r, path));
- visitor.postEdgeTraverse(fr);
- }
- }
-
- Set<Region> extendPath(Region r, Set<Region> path) {
- Set<Region> newPath = new HashSet<Region>(path);
- newPath.add(r);
- return newPath;
- }
-
- void visitRemainingSubgraph(Region r, RegionDigraphVisitor visitor, Set<Region> path) {
- if (!path.contains(r)) {
- visitor.visit(r);
- traverseEdges(r, visitor, path);
- }
- }
-
- void visitSubgraph(Region startingRegion, RegionDigraphVisitor visitor) {
- visitRemainingSubgraph(startingRegion, visitor, new HashSet<Region>());
- }
-
-} \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraph.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraph.java
index c64c8a1d..90caa684 100644
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraph.java
+++ b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionDigraph.java
@@ -22,6 +22,7 @@ import java.util.Set;
import org.eclipse.virgo.kernel.osgi.region.Region;
import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
+import org.eclipse.virgo.kernel.osgi.region.RegionDigraphVisitor;
import org.eclipse.virgo.kernel.osgi.region.RegionFilter;
import org.eclipse.virgo.kernel.osgi.region.RegionLifecycleListener;
import org.eclipse.virgo.kernel.serviceability.NonNull;
@@ -53,7 +54,10 @@ public final class StandardRegionDigraph implements RegionDigraph {
private final ThreadLocal<Region> threadLocal;
+ private SubgraphTraverser subgraphTraverser;
+
public StandardRegionDigraph(BundleContext bundleContext, ThreadLocal<Region> threadLocal) {
+ this.subgraphTraverser = new SubgraphTraverser();
this.systemBundleContext = bundleContext.getBundle(0L).getBundleContext();
this.threadLocal = threadLocal;
}
@@ -294,4 +298,12 @@ public final class StandardRegionDigraph implements RegionDigraph {
return listeners;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void visitSubgraph(Region startingRegion, RegionDigraphVisitor visitor) {
+ this.subgraphTraverser.visitSubgraph(startingRegion, visitor);
+ }
+
}
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/SubgraphTraverser.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/SubgraphTraverser.java
new file mode 100644
index 00000000..20d7ffae
--- /dev/null
+++ b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/SubgraphTraverser.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * This file is part of the Virgo Web Server.
+ *
+ * Copyright (c) 2011 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SpringSource, a division of VMware - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package org.eclipse.virgo.kernel.osgi.region.internal;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.virgo.kernel.osgi.region.Region;
+import org.eclipse.virgo.kernel.osgi.region.RegionDigraphVisitor;
+import org.eclipse.virgo.kernel.osgi.region.RegionDigraph.FilteredRegion;
+
+/**
+ * {@link SubgraphTraverser} is a utility for traversing a subgraph of a {@link RegionDigraph} calling a
+ * {@link RegionDigraphVisitor} on the way.
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * Thread safe.
+ */
+final class SubgraphTraverser {
+
+ void visitSubgraph(Region startingRegion, RegionDigraphVisitor visitor) {
+ visitRemainingSubgraph(startingRegion, visitor, new HashSet<Region>());
+ }
+
+ private void visitRemainingSubgraph(Region r, RegionDigraphVisitor visitor, Set<Region> path) {
+ if (!path.contains(r)) {
+ visitor.visit(r);
+ traverseEdges(r, visitor, path);
+ }
+ }
+
+ private void traverseEdges(Region r, RegionDigraphVisitor visitor, Set<Region> path) {
+ for (FilteredRegion fr : r.getEdges()) {
+ visitor.preEdgeTraverse(fr);
+ visitRemainingSubgraph(fr.getRegion(), visitor, extendPath(r, path));
+ visitor.postEdgeTraverse(fr);
+ }
+ }
+
+ private Set<Region> extendPath(Region r, Set<Region> path) {
+ Set<Region> newPath = new HashSet<Region>(path);
+ newPath.add(r);
+ return newPath;
+ }
+
+} \ No newline at end of file

Back to the top