use of org.osgi.resource.Resource in project bnd by bndtools.
the class GenericResolveContext method addFramework.
public void addFramework(String framework, String version) throws Exception {
Resource r = getHighestResource(framework, version);
setFramework(system, r);
}
use of org.osgi.resource.Resource in project bnd by bndtools.
the class ResolveProcess method findResolvedProvider.
private static Resource findResolvedProvider(Wire wire, Set<Resource> resources, AbstractResolveContext rc) {
// Make sure not to add new resources into the result. The resolver
// already created the closure of all the needed resources. We need to
// find the key in the result that already provides the capability
// defined by this wire.
Capability capability = wire.getCapability();
Resource resource = capability.getResource();
if (rc.isSystemResource(resource) || (ResourceUtils.isFragment(resource) && resources.contains(resource))) {
return resource;
}
for (Resource resolved : resources) {
for (Capability resolvedCap : resolved.getCapabilities(capability.getNamespace())) {
if (ResourceUtils.matches(wire.getRequirement(), resolvedCap)) {
return resolved;
}
}
}
// It shouldn't be possible to arrive here!
throw new IllegalStateException(Strings.format("The capability for wire %s was not associated with a resource in the resolution", wire));
}
use of org.osgi.resource.Resource in project bndtools by bndtools.
the class BundleSorter method compare.
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
Resource r1 = (Resource) e1;
Resource r2 = (Resource) e2;
Capability id1 = ResourceUtils.getIdentityCapability(r1);
Capability id2 = ResourceUtils.getIdentityCapability(r2);
String name1 = ResourceUtils.getIdentity(id1);
if (name1 == null) {
name1 = "";
}
String name2 = ResourceUtils.getIdentity(id2);
if (name2 == null) {
name2 = "";
}
int ret = name1.compareTo(name2);
if (ret != 0) {
return ret;
}
Version ver1 = ResourceUtils.getVersion(id1);
if (ver1 == null) {
ver1 = Version.emptyVersion;
}
Version ver2 = ResourceUtils.getVersion(id2);
if (ver2 == null) {
ver2 = Version.emptyVersion;
}
// This comparison is the reverse of what you would expect
return ver2.compareTo(ver1);
}
use of org.osgi.resource.Resource in project bndtools by bndtools.
the class ResolutionChoiceSelectionDialog method updateSavePreferenceText.
private void updateSavePreferenceText() {
Resource resource = candidates.get(0).getResource();
Capability identity = ResourceUtils.getIdentityCapability(resource);
String name = ResourceUtils.getIdentity(identity);
StyledString label = new StyledString("Save top candidate (");
label.append(name, BoldStyler.INSTANCE_DEFAULT);
label.append(") as a ");
label.append("preferred resource.", ItalicStyler.INSTANCE_DEFAULT);
txtSavePreference.setText(label.getString());
txtSavePreference.setStyleRanges(label.getStyleRanges());
}
use of org.osgi.resource.Resource in project bnd by bndtools.
the class ResourceTest method testImportExportService.
public void testImportExportService() throws Exception {
ResourceBuilder rb = new ResourceBuilder();
rb.addImportServices(new Parameters(is));
rb.addExportServices(new Parameters(es));
Resource build = rb.build();
assertConfigAdminServices(build);
}
Aggregations