Search in sources :

Example 1 with RequirementBuilder

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;
}
Also used : Requirement(org.osgi.resource.Requirement) AggregateRepository(aQute.bnd.osgi.repository.AggregateRepository) Repository(org.osgi.service.repository.Repository) AugmentRepository(aQute.bnd.osgi.repository.AugmentRepository) Processor(aQute.bnd.osgi.Processor) Capability(org.osgi.resource.Capability) Collection(java.util.Collection) RequirementBuilder(aQute.bnd.osgi.resource.RequirementBuilder)

Example 2 with RequirementBuilder

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));
}
Also used : Requirement(org.osgi.resource.Requirement) Capability(org.osgi.resource.Capability) CapabilityBuilder(aQute.bnd.osgi.resource.CapabilityBuilder) RequirementBuilder(aQute.bnd.osgi.resource.RequirementBuilder)

Example 3 with RequirementBuilder

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));
}
Also used : Requirement(org.osgi.resource.Requirement) Capability(org.osgi.resource.Capability) CapabilityBuilder(aQute.bnd.osgi.resource.CapabilityBuilder) RequirementBuilder(aQute.bnd.osgi.resource.RequirementBuilder)

Example 4 with RequirementBuilder

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));
}
Also used : Requirement(org.osgi.resource.Requirement) Capability(org.osgi.resource.Capability) CapabilityBuilder(aQute.bnd.osgi.resource.CapabilityBuilder) RequirementBuilder(aQute.bnd.osgi.resource.RequirementBuilder)

Example 5 with RequirementBuilder

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));
    }
}
Also used : ResourceBuilder(aQute.bnd.osgi.resource.ResourceBuilder) Processor(aQute.bnd.osgi.Processor) Capability(org.osgi.resource.Capability) RequirementBuilder(aQute.bnd.osgi.resource.RequirementBuilder)

Aggregations

RequirementBuilder (aQute.bnd.osgi.resource.RequirementBuilder)10 Requirement (org.osgi.resource.Requirement)9 Capability (org.osgi.resource.Capability)8 CapabilityBuilder (aQute.bnd.osgi.resource.CapabilityBuilder)5 Collection (java.util.Collection)3 Resource (org.osgi.resource.Resource)3 Processor (aQute.bnd.osgi.Processor)2 XMLResourceParser (aQute.bnd.osgi.repository.XMLResourceParser)2 URL (java.net.URL)2 Repository (org.osgi.service.repository.Repository)2 HttpClient (aQute.bnd.http.HttpClient)1 AggregateRepository (aQute.bnd.osgi.repository.AggregateRepository)1 AugmentRepository (aQute.bnd.osgi.repository.AugmentRepository)1 ResourceBuilder (aQute.bnd.osgi.resource.ResourceBuilder)1 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)1 Version (aQute.bnd.version.Version)1 Slf4jReporter (aQute.libg.reporter.slf4j.Slf4jReporter)1 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Semaphore (java.util.concurrent.Semaphore)1