use of org.osgi.resource.Wire 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);
}
}
use of org.osgi.resource.Wire in project karaf by apache.
the class SubsystemTest method dumpWiring.
private void dumpWiring(SubsystemResolver resolver) {
System.out.println("Wiring");
Map<Resource, List<Wire>> wiring = resolver.getWiring();
List<Resource> resources = new ArrayList<>(wiring.keySet());
resources.sort(Comparator.comparing(this::getName));
for (Resource resource : resources) {
System.out.println(" " + getName(resource));
for (Wire wire : wiring.get(resource)) {
System.out.println(" " + wire);
}
}
}
use of org.osgi.resource.Wire in project karaf by apache.
the class SubsystemResolver method resolve.
@Override
public Map<Resource, List<Wire>> resolve(String featureResolutionRange, FeaturesService.ServiceRequirementsBehavior serviceRequirements, final Repository globalRepository, String outputFile) throws Exception {
if (root == null) {
return Collections.emptyMap();
}
// Download bundles
root.downloadBundles(manager, featureResolutionRange, serviceRequirements, new RepositoryManager(), callback);
// Populate digraph and resolve
digraph = new StandardRegionDigraph(null, null);
populateDigraph(digraph, root);
Downloader downloader = manager.createDownloader();
SubsystemResolveContext context = new SubsystemResolveContext(root, digraph, globalRepository, downloader, serviceRequirements);
if (outputFile != null) {
Map<String, Object> json = new HashMap<>();
if (globalRepository != null) {
json.put("globalRepository", toJson(globalRepository));
}
json.put("repository", toJson(context.getRepository()));
try {
// this is where the magic happens...
wiring = resolver.resolve(context);
json.put("success", "true");
json.put("wiring", toJson(wiring));
} catch (Exception e) {
json.put("success", "false");
json.put("exception", e.toString());
throw e;
} finally {
try (Writer writer = Files.newBufferedWriter(Paths.get(outputFile), StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {
JsonWriter.write(writer, json, true);
}
}
} else {
// this is where the magic happens...
wiring = resolver.resolve(context);
}
downloader.await();
// Remove wiring to the fake environment resource
if (environmentResource != null) {
for (List<Wire> wires : wiring.values()) {
wires.removeIf(wire -> wire.getProvider() == environmentResource);
}
}
// Fragments are always wired to their host only, so create fake wiring to
// the subsystem the host is wired to
associateFragments();
return wiring;
}
Aggregations