use of aQute.bnd.osgi.resource.RequirementBuilder in project bnd by bndtools.
the class BndrunResolveContext method findRepositoryAugments.
private Processor findRepositoryAugments(Collection<Repository> orderedRepositories) {
Processor main = new Processor();
RequirementBuilder rb = new RequirementBuilder(BND_AUGMENT);
rb.filter("(path=*)");
Requirement req = rb.buildSyntheticRequirement();
for (Repository r : orderedRepositories) {
Map<Requirement, Collection<Capability>> found = r.findProviders(Collections.singleton(req));
Collection<Capability> capabilities = found.get(req);
if (capabilities != null) {
for (Capability capability : capabilities) {
findAdditionalAugmentsFromResource(main, capability);
}
}
}
return main;
}
use of aQute.bnd.osgi.resource.RequirementBuilder in project bnd by bndtools.
the class CapReqFilterTest method testReqNoFilterCapWithAttr.
public void testReqNoFilterCapWithAttr() throws Exception {
Capability cap = new CapabilityBuilder("foobar").addAttribute("blah", "baz").addAttribute("version", "42").buildSyntheticCapability();
Requirement req = new RequirementBuilder("foobar").buildSyntheticRequirement();
assertTrue(ResourceUtils.matches(req, cap));
}
use of aQute.bnd.osgi.resource.RequirementBuilder in project bnd by bndtools.
the class CapReqFilterTest method testReqNoFilterDifferentNamespace.
public void testReqNoFilterDifferentNamespace() throws Exception {
Capability cap = new CapabilityBuilder("run.amock").buildSyntheticCapability();
Requirement req = new RequirementBuilder("bamboozled").buildSyntheticRequirement();
assertFalse(ResourceUtils.matches(req, cap));
}
use of aQute.bnd.osgi.resource.RequirementBuilder in project bnd by bndtools.
the class CapReqFilterTest method testReqWithFilter.
public void testReqWithFilter() {
Capability cap = new CapabilityBuilder("foobar").buildSyntheticCapability();
Requirement req = new RequirementBuilder("foobar").addDirective("filter", "(something=true)").buildSyntheticRequirement();
assertFalse(ResourceUtils.matches(req, cap));
}
use of aQute.bnd.osgi.resource.RequirementBuilder in project bnd by bndtools.
the class ProcessorTest method assertNative.
private void assertNative(String in, String filter, String... fixup) throws Exception {
List<String> split = in == null ? new ArrayList<String>() : Strings.split("\\s*;\\s*", in);
split.add(0, "native_capability");
try (Processor p = new Processor()) {
String s = p._native_capability(split.toArray(new String[0]));
assertNotNull(s);
System.out.println(s);
ResourceBuilder rb = new ResourceBuilder();
List<Capability> capabilities = rb.addProvideCapabilities(s);
RequirementBuilder qb = new RequirementBuilder("osgi.native");
qb.addDirective("filter", filter);
List<Capability> found = ResourceUtils.findProviders(qb.synthetic(), capabilities);
assertTrue(!found.isEmpty());
assertTrue(p.check(fixup));
}
}
Aggregations