use of org.apache.karaf.features.internal.resolver.SimpleFilter in project karaf by apache.
the class XmlRepository method hasResource.
private boolean hasResource(String type, String name, Version version) {
CapabilitySet set = capSets.get(IDENTITY_NAMESPACE);
if (set != null) {
Map<String, Object> attrs = new HashMap<>();
attrs.put(CAPABILITY_TYPE_ATTRIBUTE, type);
attrs.put(IDENTITY_NAMESPACE, name);
attrs.put(CAPABILITY_VERSION_ATTRIBUTE, version);
SimpleFilter sf = SimpleFilter.convert(attrs);
return !set.match(sf, true).isEmpty();
} else {
return false;
}
}
use of org.apache.karaf.features.internal.resolver.SimpleFilter in project karaf by apache.
the class SubsystemResolver method associateFragments.
private void associateFragments() {
SimpleFilter sf = createFilter(IDENTITY_NAMESPACE, "*", CAPABILITY_TYPE_ATTRIBUTE, TYPE_SUBSYSTEM);
for (Map.Entry<Resource, List<Wire>> entry : wiring.entrySet()) {
final Resource resource = entry.getKey();
final Requirement requirement = getSubsystemRequirement(resource);
if (ResolverUtil.isFragment(resource) && requirement != null) {
List<Wire> wires = entry.getValue();
final Resource host = wires.get(0).getProvider();
final Wire wire = findMatchingWire(sf, wiring.get(host));
if (wire != null) {
wires.add(new Wire() {
@Override
public Capability getCapability() {
return wire.getCapability();
}
@Override
public Requirement getRequirement() {
return requirement;
}
@Override
public Resource getProvider() {
return wire.getProvider();
}
@Override
public Resource getRequirer() {
return resource;
}
});
}
}
}
}
use of org.apache.karaf.features.internal.resolver.SimpleFilter in project karaf by apache.
the class SubsystemResolver method getBundles.
/**
*
* @return map of bundles and the region they are deployed in
*/
public Map<Resource, String> getBundles() {
if (bundles == null) {
String filter = String.format("(&(%s=*)(|(%s=%s)(%s=%s)))", IDENTITY_NAMESPACE, CAPABILITY_TYPE_ATTRIBUTE, TYPE_BUNDLE, CAPABILITY_TYPE_ATTRIBUTE, TYPE_FRAGMENT);
SimpleFilter sf = SimpleFilter.parse(filter);
bundles = getResourceMapping(sf);
}
return bundles;
}
use of org.apache.karaf.features.internal.resolver.SimpleFilter in project karaf by apache.
the class SubsystemResolver method getResourceMapping.
/**
*
* @param resourceFilter
* @return map from resource to region name
*/
private Map<Resource, String> getResourceMapping(SimpleFilter resourceFilter) {
Map<String, String> flats = getFlatSubsystemsMap();
Map<Resource, List<Wire>> wiring = getWiring();
Map<Resource, String> resources = new HashMap<>();
SimpleFilter sf = createFilter(IDENTITY_NAMESPACE, "*", CAPABILITY_TYPE_ATTRIBUTE, TYPE_SUBSYSTEM);
if (wiring != null) {
for (Resource resource : wiring.keySet()) {
if (findMatchingCapability(resourceFilter, resource.getCapabilities(null)) != null) {
// Find the subsystem where this feature is installed
Wire wire = findMatchingWire(sf, wiring.get(resource));
if (wire != null) {
String region = (String) wire.getCapability().getAttributes().get(IDENTITY_NAMESPACE);
region = flats.get(region);
resources.put(resource, region);
}
}
}
}
return resources;
}
use of org.apache.karaf.features.internal.resolver.SimpleFilter in project karaf by apache.
the class StaxParser method parseRequirement.
private static RequirementImpl parseRequirement(XMLStreamReader reader, ResourceImpl resource) throws XMLStreamException {
String[] namespace = new String[1];
Map<String, String> directives = new HashMap<>();
Map<String, Object> attributes = new HashMap<>();
parseClause(reader, namespace, directives, attributes);
sanityCheckEndElement(reader, reader.getEventType(), REQUIREMENT);
String filterStr = directives.get(Constants.FILTER_DIRECTIVE);
SimpleFilter sf = (filterStr != null) ? SimpleFilter.parse(filterStr) : SimpleFilter.convert(attributes);
return new RequirementImpl(resource, namespace[0], directives, attributes, sf);
}
Aggregations