use of org.osgi.resource.Wiring in project felix by apache.
the class ResolverTest method testScenario12.
/**
* Test dynamic resolution with an unresolvable host
*/
@Test(expected = ResolutionException.class)
public void testScenario12() throws Exception {
ResolverImpl resolver = new ResolverImpl(new Logger(Logger.LOG_DEBUG), 1);
Map<Resource, Wiring> wirings = new HashMap<Resource, Wiring>();
Map<Requirement, List<Capability>> candMap = new HashMap<Requirement, List<Capability>>();
ResourceImpl a1 = new ResourceImpl("A");
Capability a1_hostCap = addCap(a1, HostNamespace.HOST_NAMESPACE, "A");
ResourceImpl b1 = new ResourceImpl("B");
Requirement b_pkgReq1 = addReq(b1, PackageNamespace.PACKAGE_NAMESPACE, "org.foo.a");
ResourceImpl c1 = new ResourceImpl("C");
Capability c_hostCap = addCap(c1, HostNamespace.HOST_NAMESPACE, "A");
Capability c_pkgCap = addCap(c1, PackageNamespace.PACKAGE_NAMESPACE, "org.foo.a");
Requirement c_pkgReq1 = addReq(c1, PackageNamespace.PACKAGE_NAMESPACE, "org.foo.b");
candMap.put(b_pkgReq1, Collections.singletonList(c_pkgCap));
candMap.put(c_pkgReq1, Collections.<Capability>emptyList());
Map<Resource, List<Wire>> wires = new HashMap<Resource, List<Wire>>();
wires.put(a1, new ArrayList<Wire>());
wires.put(b1, new ArrayList<Wire>());
Map<Resource, List<Wire>> invertedWires = new HashMap<Resource, List<Wire>>();
invertedWires.put(a1, new ArrayList<Wire>());
invertedWires.put(b1, new ArrayList<Wire>());
wirings.put(a1, new SimpleWiring(a1, Collections.<Capability>emptyList(), wires, invertedWires));
wirings.put(b1, new SimpleWiring(b1, Collections.<Capability>emptyList(), wires, invertedWires));
ResolveContextImpl rci = new ResolveContextImpl(wirings, candMap, Collections.<Resource>emptyList(), Collections.<Resource>emptyList());
List<Capability> caps = new ArrayList<Capability>();
caps.add(c_pkgCap);
Map<Resource, List<Wire>> wireMap = resolver.resolve(rci, b1, b_pkgReq1, caps);
assertEquals(0, wireMap.size());
}
use of org.osgi.resource.Wiring in project aries by apache.
the class ResolveContext method processAsSubstitutableExport.
private void processAsSubstitutableExport(boolean isFragment, Requirement requirement, List<Capability> capabilities) {
String namespace = requirement.getNamespace();
if (!PackageNamespace.PACKAGE_NAMESPACE.equals(namespace)) {
return;
}
Resource resource = requirement.getResource();
Wiring wiring = wirings.get(resource);
if (isFragment) {
List<Wire> fragmentWires = wiring.getRequiredResourceWires(HostNamespace.HOST_NAMESPACE);
for (Wire fragmentWire : fragmentWires) {
Resource host = fragmentWire.getProvider();
processResourceCapabilities(wirings.get(host).getResourceCapabilities(namespace), requirement, capabilities);
}
} else {
List<Capability> resourceCapabilities = wiring.getResourceCapabilities(namespace);
processResourceCapabilities(resourceCapabilities, requirement, capabilities);
}
}
use of org.osgi.resource.Wiring in project aries by apache.
the class ResolveContext method processAsFragment.
private void processAsFragment(Requirement requirement, List<Capability> capabilities) {
String namespace = requirement.getNamespace();
Resource fragment = requirement.getResource();
Wiring fragmentWiring = wirings.get(fragment);
List<Wire> fragmentWires = fragmentWiring.getRequiredResourceWires(HostNamespace.HOST_NAMESPACE);
for (Wire fragmentWire : fragmentWires) {
Resource host = fragmentWire.getProvider();
Wiring hostWiring = wirings.get(host);
List<Wire> hostWires = hostWiring.getRequiredResourceWires(namespace);
processWires(hostWires, requirement, capabilities);
}
}
Aggregations