use of org.osgi.resource.Resource in project bnd by bndtools.
the class ResolveProcess method augment.
private static ResolutionException augment(Collection<Requirement> unresolved, ResolveContext context, ResolutionException re) {
if (unresolved.isEmpty()) {
return re;
}
long deadline = System.currentTimeMillis() + 1000L;
Set<Requirement> list = new HashSet<>(unresolved);
Set<Resource> resources = new HashSet<>();
try {
for (Requirement r : unresolved) {
Requirement find = missing(context, r, resources, deadline);
if (find != null) {
list.add(find);
}
}
} catch (TimeoutException toe) {
}
return new ResolutionException(re.getMessage(), re.getCause(), list);
}
use of org.osgi.resource.Resource in project bnd by bndtools.
the class ResolveProcess method tidyUpOptional.
private static Map<Resource, List<Wire>> tidyUpOptional(Map<Resource, List<Wire>> required, Map<Resource, List<Wire>> discoveredOptional, LogService log) {
Map<Resource, List<Wire>> toReturn = new HashMap<Resource, List<Wire>>();
Set<Capability> requiredIdentities = new HashSet<Capability>();
for (Resource r : required.keySet()) {
Capability normalisedIdentity = toPureIdentity(r, log);
if (normalisedIdentity != null) {
requiredIdentities.add(normalisedIdentity);
}
}
Set<Capability> acceptedIdentities = new HashSet<>();
for (Entry<Resource, List<Wire>> entry : discoveredOptional.entrySet()) {
// If we're required we are not also optional
Resource optionalResource = entry.getKey();
if (required.containsKey(optionalResource)) {
continue;
}
// If another resource with the same identity is required
// then we defer to it, otherwise we will get the an optional
// resource showing up from a different repository
Capability optionalIdentity = toPureIdentity(optionalResource, log);
if (requiredIdentities.contains(optionalIdentity)) {
continue;
}
// Only wires to required resources should kept
List<Wire> validWires = new ArrayList<Wire>();
optional: for (Wire optionalWire : entry.getValue()) {
Resource requirer = optionalWire.getRequirer();
Capability requirerIdentity = toPureIdentity(requirer, log);
if (required.containsKey(requirer)) {
Requirement req = optionalWire.getRequirement();
// Somebody does require this - do they have a match
// already?
List<Wire> requiredWires = required.get(requirer);
for (Wire requiredWire : requiredWires) {
if (req.equals(requiredWire.getRequirement())) {
continue optional;
}
}
validWires.add(optionalWire);
}
}
// This can happen if the same resource is in multiple repos
if (!validWires.isEmpty()) {
if (acceptedIdentities.add(optionalIdentity)) {
toReturn.put(optionalResource, validWires);
} else {
log.log(LogService.LOG_INFO, "Discarding the optional resource " + optionalResource + " because another optional resource with the identity " + optionalIdentity + " has already been selected. This usually happens when the same bundle is present in multiple repositories.");
}
}
}
return toReturn;
}
use of org.osgi.resource.Resource in project bnd by bndtools.
the class DebugReporter method doAllMembers.
private void doAllMembers() {
header("RESOURCES");
Requirement r = CapReqBuilder.createBundleRequirement("*", null).buildSyntheticRequirement();
List<Capability> providers = context.findProviders(r);
Set<Resource> resources = ResourceUtils.getResources(providers);
for (Resource resource : resources) {
resource(resource);
}
resource(context.getSystemResource());
nl();
}
use of org.osgi.resource.Resource in project bnd by bndtools.
the class DebugReporter method doBlackList.
private void doBlackList() {
header("BLACKLISTED RESOURCES");
for (Resource r : context.getBlackList()) {
resource(r);
}
nl();
}
use of org.osgi.resource.Resource in project bnd by bndtools.
the class AbstractResolveContext method getResources.
public List<Resource> getResources(List<Repository> repos, Requirement req) {
Set<Resource> resources = new HashSet<Resource>();
for (Repository repo : repos) {
Collection<Capability> providers = findProviders(repo, req);
resources.addAll(ResourceUtils.getResources(providers));
}
return new ArrayList<>(resources);
}
Aggregations