Search in sources :

Example 66 with Resource

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);
}
Also used : Resource(org.osgi.resource.Resource)

Example 67 with Resource

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));
}
Also used : Capability(org.osgi.resource.Capability) Resource(org.osgi.resource.Resource)

Example 68 with Resource

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);
}
Also used : Capability(org.osgi.resource.Capability) Version(org.osgi.framework.Version) Resource(org.osgi.resource.Resource)

Example 69 with Resource

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());
}
Also used : Capability(org.osgi.resource.Capability) Resource(org.osgi.resource.Resource) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString)

Example 70 with Resource

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);
}
Also used : ResourceBuilder(aQute.bnd.osgi.resource.ResourceBuilder) Parameters(aQute.bnd.header.Parameters) Resource(org.osgi.resource.Resource)

Aggregations

Resource (org.osgi.resource.Resource)201 Capability (org.osgi.resource.Capability)62 Requirement (org.osgi.resource.Requirement)62 ArrayList (java.util.ArrayList)57 List (java.util.List)39 HashMap (java.util.HashMap)32 File (java.io.File)27 Collection (java.util.Collection)24 Wire (org.osgi.resource.Wire)24 ResourceBuilder (aQute.bnd.osgi.resource.ResourceBuilder)23 Map (java.util.Map)22 CapReqBuilder (aQute.bnd.osgi.resource.CapReqBuilder)18 URI (java.net.URI)18 HashSet (java.util.HashSet)18 BndEditModel (aQute.bnd.build.model.BndEditModel)15 MockRegistry (test.lib.MockRegistry)15 Version (org.osgi.framework.Version)14 BundleRevision (org.osgi.framework.wiring.BundleRevision)14 Repository (org.osgi.service.repository.Repository)14 IdentityCapability (aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability)13