diff options
author | Thomas Watson | 2012-02-27 15:27:46 +0000 |
---|---|---|
committer | Thomas Watson | 2012-02-27 15:27:46 +0000 |
commit | 1f744506dfe032383827e8a14775106e188a2d1f (patch) | |
tree | ca98449c32ae6fd4bb720de2ba9aa9d9cc04d6d6 /bundles/org.eclipse.equinox.region | |
parent | 09b390f082757960d96a1b6416b70e47bf6940ee (diff) | |
download | rt.equinox.bundles-1f744506dfe032383827e8a14775106e188a2d1f.tar.gz rt.equinox.bundles-1f744506dfe032383827e8a14775106e188a2d1f.tar.xz rt.equinox.bundles-1f744506dfe032383827e8a14775106e188a2d1f.zip |
Bug 347028 - [region] Add an isAllowed method to RegionFilter thatv20120227-1527
checks if a generic namespace/attributes are allowed
- Clarify javadoc for name spaces on RegionFilter.
Diffstat (limited to 'bundles/org.eclipse.equinox.region')
2 files changed, 49 insertions, 36 deletions
diff --git a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionFilter.java b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionFilter.java index 90016bc7c..a4cba8600 100644 --- a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionFilter.java +++ b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/internal/region/StandardRegionFilter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 VMware Inc. + * Copyright (c) 2011, 2012 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 @@ -33,12 +33,6 @@ final class StandardRegionFilter implements RegionFilter { } } - /** - * Determines whether this filter allows the given bundle - * - * @param bundle the bundle - * @return <code>true</code> if the bundle is allowed and <code>false</code>otherwise - */ public boolean isAllowed(Bundle bundle) { HashMap<String, Object> attrs = new HashMap<String, Object>(3); String bsn = bundle.getSymbolicName(); @@ -53,12 +47,6 @@ final class StandardRegionFilter implements RegionFilter { return isBundleAllowed(attrs); } - /** - * Determines whether this filter allows the given bundle - * - * @param bundle the bundle revision - * @return <code>true</code> if the bundle is allowed and <code>false</code>otherwise - */ public boolean isAllowed(BundleRevision bundle) { HashMap<String, Object> attrs = new HashMap<String, Object>(3); String bsn = bundle.getSymbolicName(); @@ -76,9 +64,7 @@ final class StandardRegionFilter implements RegionFilter { * @return <code>true</code> if the bundle is allowed and <code>false</code>otherwise */ private boolean isBundleAllowed(Map<String, ?> bundleAttributes) { - if (match(filters.get(VISIBLE_BUNDLE_NAMESPACE), bundleAttributes)) - return true; - return match(filters.get(VISIBLE_ALL_NAMESPACE), bundleAttributes); + return isAllowed(VISIBLE_BUNDLE_NAMESPACE, bundleAttributes); } private static boolean match(Collection<Filter> filters, Map<String, ?> attrs) { @@ -101,30 +87,24 @@ final class StandardRegionFilter implements RegionFilter { return false; } - /** - * Determines whether this filter allows the given service reference. - * - * @param service the service reference of the service - * @return <code>true</code> if the service is allowed and <code>false</code>otherwise - */ public boolean isAllowed(ServiceReference<?> service) { if (match(filters.get(VISIBLE_SERVICE_NAMESPACE), service)) return true; return match(filters.get(VISIBLE_ALL_NAMESPACE), service); } + public boolean isAllowed(BundleCapability capability) { + return isAllowed(capability.getNamespace(), capability.getAttributes()); + } + /** - * Determines whether this filter allows the given capability. - * - * @param capability the bundle capability - * @return <code>true</code> if the capability is allowed and <code>false</code>otherwise + * {@inheritDoc} */ - public boolean isAllowed(BundleCapability capability) { - String namespace = capability.getNamespace(); - Map<String, ?> attrs = capability.getAttributes(); - if (match(filters.get(namespace), attrs)) + @Override + public boolean isAllowed(String namespace, Map<String, ?> attributes) { + if (match(filters.get(namespace), attributes)) return true; - return match(filters.get(VISIBLE_ALL_NAMESPACE), attrs); + return match(filters.get(VISIBLE_ALL_NAMESPACE), attributes); } public Map<String, Collection<String>> getSharingPolicy() { diff --git a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/region/RegionFilter.java b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/region/RegionFilter.java index f8e9f3246..e9f8015ee 100644 --- a/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/region/RegionFilter.java +++ b/bundles/org.eclipse.equinox.region/src/org/eclipse/equinox/region/RegionFilter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2011 VMware Inc. + * Copyright (c) 2010, 2012 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 @@ -73,7 +73,10 @@ public interface RegionFilter { public static final String VISIBLE_ALL_NAMESPACE = "org.eclipse.equinox.allow.all"; //$NON-NLS-1$ /** - * Determines whether this filter allows the given bundle + * Determines whether this filter allows the given bundle. A + * Bundle is allowed if it successfully matches one or more filters + * specified using the {@link RegionFilter#VISIBLE_BUNDLE_NAMESPACE} + * name space. * * @param bundle the bundle * @return <code>true</code> if the bundle is allowed and <code>false</code>otherwise @@ -81,7 +84,10 @@ public interface RegionFilter { public boolean isAllowed(Bundle bundle); /** - * Determines whether this filter allows the given bundle + * Determines whether this filter allows the given bundle. A + * Bundle is allowed if it successfully matches one or more filters + * specified using the {@link RegionFilter#VISIBLE_BUNDLE_NAMESPACE} + * name space. * * @param bundle the bundle revision * @return <code>true</code> if the bundle is allowed and <code>false</code>otherwise @@ -89,7 +95,10 @@ public interface RegionFilter { public boolean isAllowed(BundleRevision bundle); /** - * Determines whether this filter allows the given service reference. + * Determines whether this filter allows the given service reference. A + * service is allowed if its service properties successfully matches one + * or more filters specified using the + * {@link RegionFilter#VISIBLE_SERVICE_NAMESPACE} name space. * * @param service the service reference of the service * @return <code>true</code> if the service is allowed and <code>false</code>otherwise @@ -97,7 +106,16 @@ public interface RegionFilter { public boolean isAllowed(ServiceReference<?> service); /** - * Determines whether this filter allows the given capability. + * Determines whether this filter allows the given capability. A + * capability is allowed if it successfully matches one or more filters + * specified using the {@link BundleCapability#getNamespace() name space} + * of the given capability. For example, the name spaces + * {@link RegionFilter#VISIBLE_PACKAGE_NAMESPACE osgi.wiring.package}, + * {@link RegionFilter#VISIBLE_HOST_NAMESPACE osgi.wiring.host}, and + * {@link RegionFilter#VISIBLE_REQUIRE_NAMESPACE osgi.wiring.bundle} + * may be used. Any other generic capability + * {@link RegionFilterBuilder#allow(String, String) name spaces} can also + * be allowed by the region filter. * * @param capability the bundle capability * @return <code>true</code> if the capability is allowed and <code>false</code>otherwise @@ -105,6 +123,21 @@ public interface RegionFilter { public boolean isAllowed(BundleCapability capability); /** + * Determines whether this filter allows the given name space with the given attributes. + * The name space can be any generic name space including but not limited to the following: + * {@link #VISIBLE_BUNDLE_NAMESPACE}, {@link #VISIBLE_PACKAGE_NAMESPACE}, + * {@link #VISIBLE_HOST_NAMESPACE}, {@link #VISIBLE_REQUIRE_NAMESPACE} and + * {@link #VISIBLE_SERVICE_NAMESPACE}. Any other generic capability + * {@link RegionFilterBuilder#allow(String, String) name spaces} can also + * be allowed by the region filter. + * + * @param namespace the name space + * @param attributes the attributes to check if they are allowed + * @return <code>true</code> if the name space and attributes are allowed and <code>false</code> otherwise + */ + public boolean isAllowed(String namespace, Map<String, ?> attributes); + + /** * Returns a map of the filters used by each name space for this region filter. The may key is the name space and * the value is a collection of filters for the name space. The returned map is a snapshot of the sharing policy. * Changes made to the returned map have no affect on this region filter. |