Search in sources :

Example 1 with PackageCapability

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

the class Main method populateScenario3.

private static List<Resource> populateScenario3(Map<Resource, Wiring> wirings, Map<Requirement, List<Capability>> candMap) {
    wirings.clear();
    candMap.clear();
    List<Capability> resourcesCands = new ArrayList<Capability>();
    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 2 with PackageCapability

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

the class Main method populateScenario1.

private static List<Resource> populateScenario1(Map<Resource, Wiring> wirings, Map<Requirement, List<Capability>> candMap) {
    wirings.clear();
    candMap.clear();
    ResourceImpl exporter = new ResourceImpl("A");
    exporter.addCapability(new PackageCapability(exporter, "foo"));
    ResourceImpl importer = new ResourceImpl("B");
    importer.addRequirement(new PackageRequirement(importer, "foo"));
    candMap.put(importer.getRequirements(null).get(0), exporter.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE));
    List<Resource> resources = new ArrayList<Resource>();
    resources.add(importer);
    return resources;
}
Also used : ResourceImpl(org.apache.felix.resolver.test.util.ResourceImpl) PackageCapability(org.apache.felix.resolver.test.util.PackageCapability) PackageRequirement(org.apache.felix.resolver.test.util.PackageRequirement) Resource(org.osgi.resource.Resource) ArrayList(java.util.ArrayList)

Example 3 with PackageCapability

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

the class Main method populateScenario6.

private static List<Resource> populateScenario6(Map<Resource, Wiring> wirings, Map<Requirement, List<Capability>> candMap) {
    wirings.clear();
    candMap.clear();
    ResourceImpl a1 = new ResourceImpl("A");
    a1.addRequirement(new PackageRequirement(a1, "p1"));
    a1.addRequirement(new PackageRequirement(a1, "p2"));
    Requirement a1Req = new GenericRequirement(a1, "generic");
    a1Req.getDirectives().put(Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE, Namespace.CARDINALITY_MULTIPLE);
    a1.addRequirement(a1Req);
    ResourceImpl a2 = new ResourceImpl("A");
    a2.addRequirement(new BundleRequirement(a2, "B"));
    a2.addRequirement(new BundleRequirement(a2, "C"));
    Requirement a2Req = new GenericRequirement(a2, "generic");
    a2Req.getDirectives().put(Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE, Namespace.CARDINALITY_MULTIPLE);
    a2.addRequirement(a2Req);
    ResourceImpl b1 = new ResourceImpl("B");
    b1.addCapability(new BundleCapability(b1, "B"));
    Capability b1_p2 = new PackageCapability(b1, "p2");
    b1_p2.getDirectives().put(Namespace.CAPABILITY_USES_DIRECTIVE, "p1");
    b1.addCapability(b1_p2);
    b1.addRequirement(new PackageRequirement(b1, "p1"));
    ResourceImpl b2 = new ResourceImpl("B");
    b2.addCapability(new BundleCapability(b2, "B"));
    Capability b2_p2 = new PackageCapability(b2, "p2");
    b2_p2.getDirectives().put(Namespace.CAPABILITY_USES_DIRECTIVE, "p1");
    b2.addCapability(b2_p2);
    b2.addRequirement(new PackageRequirement(b2, "p1"));
    ResourceImpl c1 = new ResourceImpl("C");
    c1.addCapability(new BundleCapability(c1, "C"));
    Capability c1_p1 = new PackageCapability(c1, "p1");
    ResourceImpl c2 = new ResourceImpl("C");
    c2.addCapability(new BundleCapability(c2, "C"));
    Capability c2_p1 = new PackageCapability(c2, "p1");
    ResourceImpl d1 = new ResourceImpl("D");
    GenericCapability d1_generic = new GenericCapability(d1, "generic");
    d1_generic.addDirective(Namespace.CAPABILITY_USES_DIRECTIVE, "p1,p2");
    d1.addCapability(d1_generic);
    d1.addRequirement(new PackageRequirement(d1, "p1"));
    d1.addRequirement(new PackageRequirement(d1, "p2"));
    ResourceImpl d2 = new ResourceImpl("D");
    GenericCapability d2_generic = new GenericCapability(d2, "generic");
    d2_generic.addDirective(Namespace.CAPABILITY_USES_DIRECTIVE, "p1,p2");
    d2.addCapability(d2_generic);
    d2.addRequirement(new PackageRequirement(d2, "p1"));
    d2.addRequirement(new PackageRequirement(d2, "p2"));
    candMap.put(a1.getRequirements(null).get(0), Arrays.asList(c2_p1));
    candMap.put(a1.getRequirements(null).get(1), Arrays.asList(b2_p2));
    candMap.put(a1.getRequirements(null).get(2), Arrays.asList((Capability) d1_generic, (Capability) d2_generic));
    candMap.put(a2.getRequirements(null).get(0), c2.getCapabilities(BundleNamespace.BUNDLE_NAMESPACE));
    candMap.put(a2.getRequirements(null).get(1), b2.getCapabilities(BundleNamespace.BUNDLE_NAMESPACE));
    candMap.put(a2.getRequirements(null).get(2), Arrays.asList((Capability) d1_generic, (Capability) d2_generic));
    candMap.put(b1.getRequirements(null).get(0), Arrays.asList(c1_p1, c2_p1));
    candMap.put(b2.getRequirements(null).get(0), Arrays.asList(c1_p1, c2_p1));
    candMap.put(d1.getRequirements(null).get(0), Arrays.asList(c1_p1, c2_p1));
    candMap.put(d1.getRequirements(null).get(1), Arrays.asList(b1_p2, b2_p2));
    candMap.put(d2.getRequirements(null).get(0), Arrays.asList(c1_p1, c2_p1));
    candMap.put(d2.getRequirements(null).get(1), Arrays.asList(b1_p2, b2_p2));
    List<Resource> resources = new ArrayList<Resource>();
    resources.add(a1);
    resources.add(a2);
    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) GenericRequirement(org.apache.felix.resolver.test.util.GenericRequirement) 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) Resource(org.osgi.resource.Resource) ArrayList(java.util.ArrayList) GenericCapability(org.apache.felix.resolver.test.util.GenericCapability) BundleCapability(org.apache.felix.resolver.test.util.BundleCapability) BundleRequirement(org.apache.felix.resolver.test.util.BundleRequirement)

Example 4 with PackageCapability

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

the class Main method populateScenario2.

private static List<Resource> populateScenario2(Map<Resource, Wiring> wirings, Map<Requirement, List<Capability>> candMap) {
    wirings.clear();
    candMap.clear();
    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 5 with PackageCapability

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

the class ResolverTest method populateScenario6.

private static List<Resource> populateScenario6(Map<Resource, Wiring> wirings, Map<Requirement, List<Capability>> candMap) {
    ResourceImpl a1 = new ResourceImpl("A");
    a1.addRequirement(new PackageRequirement(a1, "p1"));
    a1.addRequirement(new PackageRequirement(a1, "p2"));
    Requirement a1Req = new GenericRequirement(a1, "generic");
    a1Req.getDirectives().put(Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE, Namespace.CARDINALITY_MULTIPLE);
    a1.addRequirement(a1Req);
    ResourceImpl a2 = new ResourceImpl("A");
    a2.addRequirement(new BundleRequirement(a2, "B"));
    a2.addRequirement(new BundleRequirement(a2, "C"));
    Requirement a2Req = new GenericRequirement(a2, "generic");
    a2Req.getDirectives().put(Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE, Namespace.CARDINALITY_MULTIPLE);
    a2.addRequirement(a2Req);
    ResourceImpl b1 = new ResourceImpl("B");
    b1.addCapability(new BundleCapability(b1, "B"));
    Capability b1_p2 = new PackageCapability(b1, "p2");
    b1_p2.getDirectives().put(Namespace.CAPABILITY_USES_DIRECTIVE, "p1");
    b1.addCapability(b1_p2);
    b1.addRequirement(new PackageRequirement(b1, "p1"));
    ResourceImpl b2 = new ResourceImpl("B");
    b2.addCapability(new BundleCapability(b2, "B"));
    Capability b2_p2 = new PackageCapability(b2, "p2");
    b2_p2.getDirectives().put(Namespace.CAPABILITY_USES_DIRECTIVE, "p1");
    b2.addCapability(b2_p2);
    b2.addRequirement(new PackageRequirement(b2, "p1"));
    ResourceImpl c1 = new ResourceImpl("C");
    c1.addCapability(new BundleCapability(c1, "C"));
    Capability c1_p1 = new PackageCapability(c1, "p1");
    c1.addCapability(c1_p1);
    ResourceImpl c2 = new ResourceImpl("C");
    c2.addCapability(new BundleCapability(c2, "C"));
    Capability c2_p1 = new PackageCapability(c2, "p1");
    c2.addCapability(c2_p1);
    ResourceImpl d1 = new ResourceImpl("D");
    GenericCapability d1_generic = new GenericCapability(d1, "generic");
    d1_generic.addDirective(Namespace.CAPABILITY_USES_DIRECTIVE, "p1,p2");
    d1.addCapability(d1_generic);
    d1.addRequirement(new PackageRequirement(d1, "p1"));
    d1.addRequirement(new PackageRequirement(d1, "p2"));
    ResourceImpl d2 = new ResourceImpl("D");
    GenericCapability d2_generic = new GenericCapability(d2, "generic");
    d2_generic.addDirective(Namespace.CAPABILITY_USES_DIRECTIVE, "p1,p2");
    d2.addCapability(d2_generic);
    d2.addRequirement(new PackageRequirement(d2, "p1"));
    d2.addRequirement(new PackageRequirement(d2, "p2"));
    candMap.put(a1.getRequirements(null).get(0), Arrays.asList(c2_p1));
    candMap.put(a1.getRequirements(null).get(1), Arrays.asList(b2_p2));
    candMap.put(a1.getRequirements(null).get(2), Arrays.asList((Capability) d1_generic, (Capability) d2_generic));
    candMap.put(a2.getRequirements(null).get(0), c2.getCapabilities(BundleNamespace.BUNDLE_NAMESPACE));
    candMap.put(a2.getRequirements(null).get(1), b2.getCapabilities(BundleNamespace.BUNDLE_NAMESPACE));
    candMap.put(a2.getRequirements(null).get(2), Arrays.asList((Capability) d1_generic, (Capability) d2_generic));
    candMap.put(b1.getRequirements(null).get(0), Arrays.asList(c1_p1, c2_p1));
    candMap.put(b2.getRequirements(null).get(0), Arrays.asList(c1_p1, c2_p1));
    candMap.put(d1.getRequirements(null).get(0), Arrays.asList(c1_p1, c2_p1));
    candMap.put(d1.getRequirements(null).get(1), Arrays.asList(b1_p2, b2_p2));
    candMap.put(d2.getRequirements(null).get(0), Arrays.asList(c1_p1, c2_p1));
    candMap.put(d2.getRequirements(null).get(1), Arrays.asList(b1_p2, b2_p2));
    List<Resource> resources = new ArrayList<Resource>();
    resources.add(a1);
    resources.add(a2);
    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) GenericRequirement(org.apache.felix.resolver.test.util.GenericRequirement) 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) Resource(org.osgi.resource.Resource) ArrayList(java.util.ArrayList) GenericCapability(org.apache.felix.resolver.test.util.GenericCapability) 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