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;
}
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);
}
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;
}
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();
}
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);
}
}
Aggregations