use of org.osgi.framework.Filter in project aries by apache.
the class DeploymentMetadataImpl method getFilters.
private Collection<Filter> getFilters(String filterString) throws InvalidAttributeException {
Collection<Filter> filters = new ArrayList<Filter>();
List<String> fs = ManifestProcessor.split(filterString, ",");
if ((fs != null) && (!!!fs.isEmpty())) {
for (String filter : fs) {
try {
filters.add(FrameworkUtil.createFilter(FilterUtils.removeMandatoryFilterToken(filter)));
} catch (InvalidSyntaxException ise) {
InvalidAttributeException iae = new InvalidAttributeException(ise);
throw iae;
}
}
}
return filters;
}
use of org.osgi.framework.Filter in project aries by apache.
the class DeploymentMetadataImpl method convertFiltersToString.
private String convertFiltersToString(Collection<Filter> contents, String separator) {
StringBuilder newContent = new StringBuilder();
if ((contents != null) && (!!!contents.isEmpty())) {
boolean beginning = true;
for (Filter content : contents) {
if (beginning)
newContent.append(separator);
newContent.append(content.toString());
beginning = false;
}
}
return newContent.toString();
}
use of org.osgi.framework.Filter in project aries by apache.
the class OSGiImpl method buildFilter.
static Filter buildFilter(BundleContext bundleContext, String filterString, Class<?> clazz) {
Filter filter;
String string = buildFilterString(filterString, clazz);
try {
filter = bundleContext.createFilter(string);
} catch (InvalidSyntaxException e) {
throw new RuntimeException(e);
}
return filter;
}
use of org.osgi.framework.Filter in project aries by apache.
the class ConsumerHeaderProcessor method findRequirement.
private static GenericMetadata findRequirement(List<GenericMetadata> requirements, String namespace, String type) throws InvalidSyntaxException {
Dictionary<String, String> nsAttr = new Hashtable<String, String>();
nsAttr.put(namespace, type);
for (GenericMetadata req : requirements) {
if (namespace.equals(req.getNamespace())) {
String filterString = req.getDirectives().get(SpiFlyConstants.FILTER_DIRECTIVE);
if (filterString != null) {
Filter filter = FrameworkUtil.createFilter(filterString);
if (filter.match(nsAttr)) {
return req;
}
}
}
}
return null;
}
use of org.osgi.framework.Filter in project aries by apache.
the class SubsystemPermissionCollection method implies0.
/**
* Internal implies method. Used by the implies and the permission
* collection implies methods.
*
* @param requested The requested SubsystemPermision which has already been
* validated as a proper argument. The requested SubsystemPermission
* must not have a filter expression.
* @param effective The effective actions with which to start.
* @return {@code true} if the specified permission is implied by this
* object; {@code false} otherwise.
*/
boolean implies0(SubsystemPermission requested, int effective) {
/* check actions first - much faster */
effective |= action_mask;
final int desired = requested.action_mask;
if ((effective & desired) != desired) {
return false;
}
/* Get our filter */
Filter f = filter;
if (f == null) {
// it's "*"
return true;
}
/* is requested a wildcard filter? */
if (requested.subsystem == null) {
return false;
}
Map<String, Object> requestedProperties = requested.getProperties();
if (requestedProperties == null) {
/*
* If the requested properties are null, then we have detected a
* recursion getting the subsystem location. So we return true to
* permit the subsystem location request in the SubsystemPermission
* check up the stack to succeed.
*/
return true;
}
return f.matches(requestedProperties);
}
Aggregations