use of org.apache.aries.application.resolver.obr.ext.ModelledBundleResource in project aries by apache.
the class OBRAriesResolver method doResolve.
private Collection<ModelledResource> doResolve(Resolver obrResolver, String appName) throws ResolverException {
log.debug(LOG_ENTRY, "doResolve");
Collection<ModelledResource> toReturn = new ArrayList<ModelledResource>();
if (obrResolver.resolve()) {
List<Resource> requiredResources = retrieveRequiredResources(obrResolver);
if (requiredResources == null) {
log.debug("resolver.getRequiredResources() returned null");
} else {
for (Resource r : requiredResources) {
Map<String, String> attribs = new HashMap<String, String>();
attribs.put(Constants.VERSION_ATTRIBUTE, "[" + r.getVersion() + ',' + r.getVersion() + "]");
ModelledResource modelledResourceForThisMatch = null;
// list of packages available in the target runtime environment. If the resource has no symbolic name, we can ignore it
if (r.getSymbolicName() != null) {
try {
modelledResourceForThisMatch = new ModelledBundleResource(r, modellingManager, modellingHelper);
} catch (InvalidAttributeException iax) {
ResolverException re = new ResolverException("Internal error occurred: " + iax);
log.debug(LOG_EXIT, "doResolve", re);
throw re;
}
toReturn.add(modelledResourceForThisMatch);
}
}
}
log.debug(LOG_EXIT, toReturn);
return toReturn;
} else {
Reason[] reasons = obrResolver.getUnsatisfiedRequirements();
// let's refine the list by removing the indirect unsatisfied bundles that are caused by unsatisfied packages or other bundles
Map<String, Set<String>> refinedReqs = refineUnsatisfiedRequirements(obrResolver, reasons);
StringBuffer reqList = new StringBuffer();
Map<String, String> unsatisfiedRequirements = extractConsumableMessageInfo(refinedReqs);
for (String reason : unsatisfiedRequirements.keySet()) {
reqList.append('\n');
reqList.append(reason);
}
ResolverException re = new ResolverException(MessageUtil.getMessage("RESOLVER_UNABLE_TO_RESOLVE", new Object[] { appName, reqList }));
re.setUnsatisfiedRequirementsAndReasons(unsatisfiedRequirements);
log.debug(LOG_EXIT, "doResolve", re);
throw re;
}
}
Aggregations