Search in sources :

Example 96 with Capability

use of org.osgi.resource.Capability in project bnd by bndtools.

the class OSInformation method createCapability.

static Capability createCapability(NativeCapability clause) throws Exception {
    CapabilityBuilder c = new CapabilityBuilder("osgi.native");
    c.addAttribute("osgi.native.osname", clause.osname);
    c.addAttribute("osgi.native.osversion", clause.osversion);
    c.addAttribute("osgi.native.processor", clause.processor);
    c.addAttribute("osgi.native.language", clause.language);
    Capability cap = c.synthetic();
    return cap;
}
Also used : Capability(org.osgi.resource.Capability) CapabilityBuilder(aQute.bnd.osgi.resource.CapabilityBuilder)

Example 97 with Capability

use of org.osgi.resource.Capability in project bnd by bndtools.

the class OSInformation method getNativeCapabilityClause.

/**
	 * Helper for the Processor._native_capability macro
	 * 
	 * @param args the arguments of the macro
	 * @return a provide capability clause for the native environment
	 */
public static String getNativeCapabilityClause(Processor p, String[] args) throws Exception {
    NativeCapability clause = new NativeCapability();
    parseNativeCapabilityArgs(p, args, clause);
    validateNativeCapability(clause);
    Capability cap = createCapability(clause);
    return ResourceUtils.toProvideCapability(cap);
}
Also used : Capability(org.osgi.resource.Capability)

Example 98 with Capability

use of org.osgi.resource.Capability in project bnd by bndtools.

the class AgentServer method toDTO.

/*
	 * Turn a bundle in a Bundle Revision dto. On a r6 framework we could do
	 * this with adapt but on earlier frameworks we're on our own
	 */
private BundleRevisionDTO toDTO(BundleRevision resource) {
    BundleRevisionDTO brd = new BundleRevisionDTO();
    brd.bundle = resource.getBundle().getBundleId();
    brd.id = sequence.getAndIncrement();
    brd.symbolicName = resource.getSymbolicName();
    brd.type = resource.getTypes();
    brd.version = resource.getVersion().toString();
    brd.requirements = new ArrayList<RequirementDTO>();
    for (Requirement r : resource.getRequirements(null)) {
        brd.requirements.add(toDTO(brd.id, r));
    }
    brd.capabilities = new ArrayList<CapabilityDTO>();
    for (Capability c : resource.getCapabilities(null)) {
        brd.capabilities.add(toDTO(brd.id, c));
    }
    return brd;
}
Also used : Requirement(org.osgi.resource.Requirement) RequirementDTO(org.osgi.resource.dto.RequirementDTO) Capability(org.osgi.resource.Capability) BundleRevisionDTO(org.osgi.framework.wiring.dto.BundleRevisionDTO) CapabilityDTO(org.osgi.resource.dto.CapabilityDTO)

Example 99 with Capability

use of org.osgi.resource.Capability in project bnd by bndtools.

the class TestWrapper method augmentTest.

private void augmentTest(InfoRepository repo) throws Exception, IOException {
    assertNotNull(repo.get("biz.aQute.jpm.daemon", new Version("1.1.0"), null));
    InfoRepositoryWrapper iw = new InfoRepositoryWrapper(tmp, Collections.singleton(repo));
    Properties augments = new UTF8Properties();
    augments.load(new StringReader("biz.aQute.jpm.daemon: cap=test;test=1\n"));
    iw.addAugment(augments);
    //
    // Get the test and identity capability
    //
    Requirement testreq = new CapReqBuilder("test").filter("(test=1)").buildSyntheticRequirement();
    Requirement identity = new CapReqBuilder("osgi.identity").filter("(osgi.identity=biz.aQute.jpm.daemon)").buildSyntheticRequirement();
    Map<Requirement, Collection<Capability>> result = iw.findProviders(Arrays.asList(testreq, identity));
    assertNotNull(result);
    assertEquals(2, result.size());
    //
    // Test if they come from the same resource
    //
    Capability testcap = result.get(testreq).iterator().next();
    Capability identitycap = result.get(identity).iterator().next();
    assertNotNull(testcap);
    assertNotNull(identitycap);
    assertEquals(testcap.getResource(), identitycap.getResource());
    iw.close();
}
Also used : CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) Requirement(org.osgi.resource.Requirement) Capability(org.osgi.resource.Capability) Version(aQute.bnd.version.Version) StringReader(java.io.StringReader) Collection(java.util.Collection) UTF8Properties(aQute.lib.utf8properties.UTF8Properties) Properties(java.util.Properties) UTF8Properties(aQute.lib.utf8properties.UTF8Properties)

Example 100 with Capability

use of org.osgi.resource.Capability in project bnd by bndtools.

the class PomRepositoryTest method assertAllBndCap.

void assertAllBndCap(Map<Archive, Resource> value) {
    for (Resource resource : value.values()) {
        List<Capability> capabilities = resource.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE);
        assertNotNull(capabilities);
        assertEquals(1, capabilities.size());
        capabilities = resource.getCapabilities("bnd.info");
        Capability c = capabilities.get(0);
        String a = (String) c.getAttributes().get("name");
        Archive archive = Archive.valueOf(a);
        assertNotNull(archive);
    }
}
Also used : Archive(aQute.maven.api.Archive) Capability(org.osgi.resource.Capability) Resource(org.osgi.resource.Resource)

Aggregations

Capability (org.osgi.resource.Capability)189 Requirement (org.osgi.resource.Requirement)103 Resource (org.osgi.resource.Resource)60 ArrayList (java.util.ArrayList)38 IdentityCapability (aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability)37 HashMap (java.util.HashMap)37 CapReqBuilder (aQute.bnd.osgi.resource.CapReqBuilder)35 Collection (java.util.Collection)32 MockRegistry (test.lib.MockRegistry)26 BndEditModel (aQute.bnd.build.model.BndEditModel)25 Version (org.osgi.framework.Version)19 List (java.util.List)18 Repository (org.osgi.service.repository.Repository)17 Test (org.junit.Test)16 File (java.io.File)14 HostedCapability (org.osgi.service.resolver.HostedCapability)12 HashSet (java.util.HashSet)11 LinkedList (java.util.LinkedList)11 Map (java.util.Map)11 RequirementBuilder (aQute.bnd.osgi.resource.RequirementBuilder)8