use of io.fabric8.agent.resolver.SimpleFilter in project fabric8 by jboss-fuse.
the class RequirementSort method collectDependencies.
@SuppressWarnings("unchecked")
private static <T extends Resource> Set<T> collectDependencies(T resource, CapabilitySet capSet) {
Set<T> result = new LinkedHashSet<>();
for (Requirement requirement : resource.getRequirements(null)) {
String filter = requirement.getDirectives().get(Constants.FILTER_DIRECTIVE);
SimpleFilter sf = (filter != null) ? SimpleFilter.parse(filter) : new SimpleFilter(null, null, SimpleFilter.MATCH_ALL);
for (Capability cap : capSet.match(sf, true)) {
result.add((T) cap.getResource());
}
}
return result;
}
use of io.fabric8.agent.resolver.SimpleFilter in project fabric8 by jboss-fuse.
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 (isFragment(resource)) {
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 io.fabric8.agent.resolver.SimpleFilter in project fabric8 by jboss-fuse.
the class SubsystemResolver method getResourceMapping.
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 io.fabric8.agent.resolver.SimpleFilter in project fabric8 by jboss-fuse.
the class SubsystemResolver method getBundles.
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 io.fabric8.agent.resolver.SimpleFilter in project fabric8 by jboss-fuse.
the class BaseRepository method findProviders.
@Override
public Map<Requirement, Collection<Capability>> findProviders(Collection<? extends Requirement> requirements) {
Map<Requirement, Collection<Capability>> result = new HashMap<Requirement, Collection<Capability>>();
for (Requirement requirement : requirements) {
CapabilitySet set = capSets.get(requirement.getNamespace());
if (set != null) {
SimpleFilter sf;
if (requirement instanceof RequirementImpl) {
sf = ((RequirementImpl) requirement).getFilter();
} else {
String filter = requirement.getDirectives().get(Constants.FILTER_DIRECTIVE);
sf = (filter != null) ? SimpleFilter.parse(filter) : new SimpleFilter(null, null, SimpleFilter.MATCH_ALL);
}
result.put(requirement, set.match(sf, true));
} else {
result.put(requirement, Collections.<Capability>emptyList());
}
}
return result;
}
Aggregations