Search in sources :

Example 6 with PackageCapability

use of org.apache.felix.resolver.test.util.PackageCapability in project felix by apache.

the class ResolverTest method populateScenario3.

private static List<Resource> populateScenario3(Map<Resource, Wiring> wirings, Map<Requirement, List<Capability>> candMap) {
    List<Capability> dResourcesCands = new ArrayList<Capability>();
    List<Capability> eBundleDCands = new ArrayList<Capability>();
    List<Capability> eResourcesCands = new ArrayList<Capability>();
    // B
    ResourceImpl b = new ResourceImpl("B");
    PackageCapability pc = new PackageCapability(b, "resources");
    b.addCapability(pc);
    eResourcesCands.add(pc);
    // C
    ResourceImpl c = new ResourceImpl("C");
    pc = new PackageCapability(c, "resources");
    c.addCapability(pc);
    eResourcesCands.add(pc);
    dResourcesCands.add(pc);
    // D
    ResourceImpl d = new ResourceImpl("D");
    pc = new PackageCapability(d, "export");
    pc.addDirective(Namespace.CAPABILITY_USES_DIRECTIVE, "resources");
    d.addCapability(pc);
    BundleCapability bc = new BundleCapability(d, "D");
    bc.addDirective(Namespace.CAPABILITY_USES_DIRECTIVE, "resources");
    d.addCapability(bc);
    eBundleDCands.add(bc);
    Requirement r = new PackageRequirement(d, "resources");
    d.addRequirement(r);
    candMap.put(r, dResourcesCands);
    // E
    ResourceImpl e = new ResourceImpl("E");
    r = new BundleRequirement(e, "D");
    e.addRequirement(r);
    candMap.put(r, eBundleDCands);
    r = new PackageRequirement(e, "resources");
    e.addRequirement(r);
    candMap.put(r, eResourcesCands);
    // Mandatory resources
    List<Resource> resources = new ArrayList<Resource>();
    resources.add(e);
    return resources;
}
Also used : Requirement(org.osgi.resource.Requirement) BundleRequirement(org.apache.felix.resolver.test.util.BundleRequirement) GenericRequirement(org.apache.felix.resolver.test.util.GenericRequirement) PackageRequirement(org.apache.felix.resolver.test.util.PackageRequirement) ResourceImpl(org.apache.felix.resolver.test.util.ResourceImpl) PackageCapability(org.apache.felix.resolver.test.util.PackageCapability) GenericCapability(org.apache.felix.resolver.test.util.GenericCapability) PackageCapability(org.apache.felix.resolver.test.util.PackageCapability) Capability(org.osgi.resource.Capability) BundleCapability(org.apache.felix.resolver.test.util.BundleCapability) PackageRequirement(org.apache.felix.resolver.test.util.PackageRequirement) ArrayList(java.util.ArrayList) Resource(org.osgi.resource.Resource) BundleCapability(org.apache.felix.resolver.test.util.BundleCapability) BundleRequirement(org.apache.felix.resolver.test.util.BundleRequirement)

Example 7 with PackageCapability

use of org.apache.felix.resolver.test.util.PackageCapability in project felix by apache.

the class Main method populateScenario5.

private static List<Resource> populateScenario5(Map<Resource, Wiring> wirings, Map<Requirement, List<Capability>> candMap) {
    wirings.clear();
    candMap.clear();
    ResourceImpl x = new ResourceImpl("X");
    x.addRequirement(new BundleRequirement(x, "A"));
    ResourceImpl a = new ResourceImpl("A");
    a.addCapability(new BundleCapability(a, "A"));
    a.addRequirement(new BundleRequirement(a, "B"));
    a.addRequirement(new BundleRequirement(a, "C"));
    ResourceImpl b = new ResourceImpl("B");
    b.addCapability(new BundleCapability(b, "B"));
    b.addCapability(new PackageCapability(b, "p1"));
    ResourceImpl c = new ResourceImpl("C");
    c.addRequirement(new BundleRequirement(c, "D"));
    c.addCapability(new BundleCapability(c, "C"));
    PackageCapability p2 = new PackageCapability(c, "p2");
    p2.addDirective(Namespace.CAPABILITY_USES_DIRECTIVE, "p1");
    c.addCapability(p2);
    ResourceImpl d = new ResourceImpl("D");
    d.addCapability(new BundleCapability(d, "D"));
    d.addCapability(new PackageCapability(d, "p1"));
    candMap.put(x.getRequirements(null).get(0), a.getCapabilities(BundleNamespace.BUNDLE_NAMESPACE));
    candMap.put(a.getRequirements(null).get(0), b.getCapabilities(BundleNamespace.BUNDLE_NAMESPACE));
    candMap.put(a.getRequirements(null).get(1), c.getCapabilities(BundleNamespace.BUNDLE_NAMESPACE));
    candMap.put(c.getRequirements(null).get(0), d.getCapabilities(BundleNamespace.BUNDLE_NAMESPACE));
    List<Resource> resources = new ArrayList<Resource>();
    resources.add(x);
    return resources;
}
Also used : ResourceImpl(org.apache.felix.resolver.test.util.ResourceImpl) PackageCapability(org.apache.felix.resolver.test.util.PackageCapability) Resource(org.osgi.resource.Resource) ArrayList(java.util.ArrayList) BundleCapability(org.apache.felix.resolver.test.util.BundleCapability) BundleRequirement(org.apache.felix.resolver.test.util.BundleRequirement)

Example 8 with PackageCapability

use of org.apache.felix.resolver.test.util.PackageCapability in project felix by apache.

the class Main method populateScenario4.

private static List<Resource> populateScenario4(Map<Resource, Wiring> wirings, Map<Requirement, List<Capability>> candMap) {
    wirings.clear();
    candMap.clear();
    ResourceImpl a = new ResourceImpl("A");
    a.addRequirement(new BundleRequirement(a, "B"));
    a.addRequirement(new BundleRequirement(a, "C"));
    ResourceImpl b = new ResourceImpl("B");
    b.addCapability(new BundleCapability(b, "B"));
    b.addCapability(new PackageCapability(b, "p1"));
    ResourceImpl c = new ResourceImpl("C");
    c.addRequirement(new BundleRequirement(c, "D"));
    c.addCapability(new BundleCapability(c, "C"));
    PackageCapability p2 = new PackageCapability(c, "p2");
    p2.addDirective(Namespace.CAPABILITY_USES_DIRECTIVE, "p1");
    c.addCapability(p2);
    ResourceImpl d = new ResourceImpl("D");
    d.addCapability(new BundleCapability(d, "D"));
    d.addCapability(new PackageCapability(d, "p1"));
    candMap.put(a.getRequirements(null).get(0), b.getCapabilities(BundleNamespace.BUNDLE_NAMESPACE));
    candMap.put(a.getRequirements(null).get(1), c.getCapabilities(BundleNamespace.BUNDLE_NAMESPACE));
    candMap.put(c.getRequirements(null).get(0), d.getCapabilities(BundleNamespace.BUNDLE_NAMESPACE));
    List<Resource> resources = new ArrayList<Resource>();
    resources.add(a);
    return resources;
}
Also used : ResourceImpl(org.apache.felix.resolver.test.util.ResourceImpl) PackageCapability(org.apache.felix.resolver.test.util.PackageCapability) Resource(org.osgi.resource.Resource) ArrayList(java.util.ArrayList) BundleCapability(org.apache.felix.resolver.test.util.BundleCapability) BundleRequirement(org.apache.felix.resolver.test.util.BundleRequirement)

Example 9 with PackageCapability

use of org.apache.felix.resolver.test.util.PackageCapability in project felix by apache.

the class ResolverTest method populateScenario2.

private static List<Resource> populateScenario2(Map<Resource, Wiring> wirings, Map<Requirement, List<Capability>> candMap) {
    List<Capability> fooCands = new ArrayList<Capability>();
    List<Capability> barCands = new ArrayList<Capability>();
    // A
    ResourceImpl a = new ResourceImpl("A");
    PackageCapability p = new PackageCapability(a, "foo");
    a.addCapability(p);
    fooCands.add(p);
    // B
    ResourceImpl b = new ResourceImpl("B");
    p = new PackageCapability(b, "foo");
    b.addCapability(p);
    fooCands.add(p);
    p = new PackageCapability(b, "bar");
    p.addDirective(PackageNamespace.CAPABILITY_USES_DIRECTIVE, "foo");
    b.addCapability(p);
    barCands.add(p);
    // C
    ResourceImpl c = new ResourceImpl("C");
    Requirement r = new PackageRequirement(c, "foo");
    c.addRequirement(r);
    candMap.put(r, fooCands);
    r = new PackageRequirement(c, "bar");
    c.addRequirement(r);
    candMap.put(r, barCands);
    // Mandatory resources
    List<Resource> resources = new ArrayList<Resource>();
    resources.add(c);
    return resources;
}
Also used : Requirement(org.osgi.resource.Requirement) BundleRequirement(org.apache.felix.resolver.test.util.BundleRequirement) GenericRequirement(org.apache.felix.resolver.test.util.GenericRequirement) PackageRequirement(org.apache.felix.resolver.test.util.PackageRequirement) ResourceImpl(org.apache.felix.resolver.test.util.ResourceImpl) PackageCapability(org.apache.felix.resolver.test.util.PackageCapability) GenericCapability(org.apache.felix.resolver.test.util.GenericCapability) PackageCapability(org.apache.felix.resolver.test.util.PackageCapability) Capability(org.osgi.resource.Capability) BundleCapability(org.apache.felix.resolver.test.util.BundleCapability) PackageRequirement(org.apache.felix.resolver.test.util.PackageRequirement) ArrayList(java.util.ArrayList) Resource(org.osgi.resource.Resource)

Example 10 with PackageCapability

use of org.apache.felix.resolver.test.util.PackageCapability in project felix by apache.

the class ResolverTest method populateScenario5.

private static List<Resource> populateScenario5(Map<Resource, Wiring> wirings, Map<Requirement, List<Capability>> candMap) {
    ResourceImpl x = new ResourceImpl("X");
    x.addRequirement(new BundleRequirement(x, "A"));
    ResourceImpl a = new ResourceImpl("A");
    a.addCapability(new BundleCapability(a, "A"));
    a.addRequirement(new BundleRequirement(a, "B"));
    a.addRequirement(new BundleRequirement(a, "C"));
    ResourceImpl b = new ResourceImpl("B");
    b.addCapability(new BundleCapability(b, "B"));
    b.addCapability(new PackageCapability(b, "p1"));
    ResourceImpl c = new ResourceImpl("C");
    c.addRequirement(new BundleRequirement(c, "D"));
    c.addCapability(new BundleCapability(c, "C"));
    PackageCapability p2 = new PackageCapability(c, "p2");
    p2.addDirective(Namespace.CAPABILITY_USES_DIRECTIVE, "p1");
    c.addCapability(p2);
    ResourceImpl d = new ResourceImpl("D");
    d.addCapability(new BundleCapability(d, "D"));
    d.addCapability(new PackageCapability(d, "p1"));
    candMap.put(x.getRequirements(null).get(0), a.getCapabilities(BundleNamespace.BUNDLE_NAMESPACE));
    candMap.put(a.getRequirements(null).get(0), b.getCapabilities(BundleNamespace.BUNDLE_NAMESPACE));
    candMap.put(a.getRequirements(null).get(1), c.getCapabilities(BundleNamespace.BUNDLE_NAMESPACE));
    candMap.put(c.getRequirements(null).get(0), d.getCapabilities(BundleNamespace.BUNDLE_NAMESPACE));
    List<Resource> resources = new ArrayList<Resource>();
    resources.add(x);
    return resources;
}
Also used : ResourceImpl(org.apache.felix.resolver.test.util.ResourceImpl) PackageCapability(org.apache.felix.resolver.test.util.PackageCapability) Resource(org.osgi.resource.Resource) ArrayList(java.util.ArrayList) BundleCapability(org.apache.felix.resolver.test.util.BundleCapability) BundleRequirement(org.apache.felix.resolver.test.util.BundleRequirement)

Aggregations

ArrayList (java.util.ArrayList)12 PackageCapability (org.apache.felix.resolver.test.util.PackageCapability)12 ResourceImpl (org.apache.felix.resolver.test.util.ResourceImpl)12 Resource (org.osgi.resource.Resource)12 BundleCapability (org.apache.felix.resolver.test.util.BundleCapability)10 BundleRequirement (org.apache.felix.resolver.test.util.BundleRequirement)10 PackageRequirement (org.apache.felix.resolver.test.util.PackageRequirement)8 GenericCapability (org.apache.felix.resolver.test.util.GenericCapability)6 GenericRequirement (org.apache.felix.resolver.test.util.GenericRequirement)6 Capability (org.osgi.resource.Capability)6 Requirement (org.osgi.resource.Requirement)6