aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2011-03-11 14:32:48 (EST)
committerGlyn Normington2011-03-11 14:32:48 (EST)
commit8964d85c633329444d87d8b6139ce1209a8947d8 (patch)
tree856e809b417fb52ab591d3c725060770ab7830cc
parent438a11cff913708ca5cff24f8c43638fdd761702 (diff)
downloadorg.eclipse.virgo.kernel-8964d85c633329444d87d8b6139ce1209a8947d8.zip
org.eclipse.virgo.kernel-8964d85c633329444d87d8b6139ce1209a8947d8.tar.gz
org.eclipse.virgo.kernel-8964d85c633329444d87d8b6139ce1209a8947d8.tar.bz2
Add RegionFilterBuilder.allowAll method.
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionFilterBuilder.java12
-rw-r--r--org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionFilterBuilder.java29
-rw-r--r--org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFramework.java7
3 files changed, 40 insertions, 8 deletions
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionFilterBuilder.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionFilterBuilder.java
index 8c03214..92152ab 100644
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionFilterBuilder.java
+++ b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/RegionFilterBuilder.java
@@ -24,15 +24,23 @@ import org.osgi.framework.InvalidSyntaxException;
public interface RegionFilterBuilder {
/**
- * Allow capabilities with the given namespace matching the given filter.
+ * Allow capabilities with the given name space matching the given filter.
*
- * @param namespace the namespace of the capabilities to be allowed
+ * @param namespace the name space of the capabilities to be allowed
* @param filter the filter matching the capabilities to be allowed
* @return this builder (for method chaining)
*/
RegionFilterBuilder allow(String namespace, String filter) throws InvalidSyntaxException;
/**
+ * Allow all capabilities with the given name space.
+ *
+ * @param namespace the name space of the capabilities to be allowed
+ * @return this builder (for method chaining)
+ */
+ RegionFilterBuilder allowAll(String namespace);
+
+ /**
* Build a {@link RegionFilter} from the current state of this builder.
*
* @return the {@link RegionFilter} built
diff --git a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionFilterBuilder.java b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionFilterBuilder.java
index 13ace2b..421429f 100644
--- a/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionFilterBuilder.java
+++ b/org.eclipse.virgo.kernel.osgi/src/main/java/org/eclipse/virgo/kernel/osgi/region/internal/StandardRegionFilterBuilder.java
@@ -24,6 +24,19 @@ import org.osgi.framework.InvalidSyntaxException;
final class StandardRegionFilterBuilder implements RegionFilterBuilder {
+ private final static String ALL_SPEC = "(|(!(all=*))(all=*))";
+
+ private final static Filter ALL;
+ static {
+ try {
+ ALL = FrameworkUtil.createFilter(ALL_SPEC);
+ } catch (InvalidSyntaxException e) {
+ // should never happen!
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
private final Object monitor = new Object();
private final Map<String, Collection<Filter>> policy = new HashMap<String, Collection<Filter>>();
@@ -46,6 +59,22 @@ final class StandardRegionFilterBuilder implements RegionFilterBuilder {
return this;
}
+ public RegionFilterBuilder allowAll(String namespace) {
+ if (namespace == null)
+ throw new IllegalArgumentException("The namespace must not be null.");
+ synchronized (this.monitor) {
+ Collection<Filter> namespaceFilters = policy.get(namespace);
+ if (namespaceFilters == null) {
+ namespaceFilters = new ArrayList<Filter>();
+ policy.put(namespace, namespaceFilters);
+ }
+ // remove any other filters since this will override them all.
+ namespaceFilters.clear();
+ namespaceFilters.add(ALL);
+ }
+ return this;
+ }
+
@Override
public RegionFilter build() {
synchronized (this.monitor) {
diff --git a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFramework.java b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFramework.java
index ac9d3f5..64965ea 100644
--- a/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFramework.java
+++ b/org.eclipse.virgo.kernel.userregion/src/main/java/org/eclipse/virgo/kernel/userregion/internal/quasi/StandardQuasiFramework.java
@@ -52,7 +52,6 @@ import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
import org.osgi.framework.hooks.resolver.ResolverHookFactory;
@@ -115,11 +114,7 @@ final class StandardQuasiFramework implements QuasiFramework {
StandardQuasiFramework(BundleContext bundleContext, State state, PlatformAdmin platformAdmin, ResolutionFailureDetective detective,
Repository repository, TransformedManifestProvidingBundleFileWrapper bundleTransformationHandler, RegionDigraph regionDigraph) {
- try {
- TOP = regionDigraph.createRegionFilterBuilder().allow(RegionFilter.VISIBLE_ALL_NAMESPACE, TOP_FILTER).build();
- } catch (InvalidSyntaxException e) {
- throw new RuntimeException(e);
- }
+ TOP = regionDigraph.createRegionFilterBuilder().allowAll(RegionFilter.VISIBLE_ALL_NAMESPACE).build();
this.bundleContext = bundleContext;
this.state = state;
this.stateObjectFactory = platformAdmin.getFactory();