return new MDResolvedResource(null, capabilityMd.getRevision(), rmr);
}
public ResolvedResource findResource(ResolvedResource[] rress, ResourceMDParser rmdparser,
ModuleRevisionId mrid, Date date) {
ResolvedResource found = super.findResource(rress, rmdparser, mrid, date);
String osgiType = mrid.getOrganisation();
// for non bundle requirement : log the selected bundle
if (!BundleInfo.BUNDLE_TYPE.equals(osgiType)) {
// several candidates with different symbolic name : make an warning about the ambiguity
if (rress.length != 1) {
// several candidates with different symbolic name ?
Map/* <String, List<MDResolvedResource>> */matching = new HashMap();
for (int i = 0; i < rress.length; i++) {
String name = ((MDResolvedResource) rress[i]).getResolvedModuleRevision()
.getDescriptor().getExtraAttribute(CAPABILITY_EXTRA_ATTR);
List/* <MDResolvedResource> */list = (List) matching.get(name);
if (list == null) {
list = new ArrayList/* <MDResolvedResource> */();
matching.put(name, list);
}
list.add(rress[i]);
}
if (matching.keySet().size() != 1) {
if (requirementStrategy == RequirementStrategy.first) {
Message.warn("Ambiguity for the '" + osgiType + "' requirement "
+ mrid.getName() + ";version=" + mrid.getRevision());
Iterator itMatching = matching.entrySet().iterator();
while (itMatching.hasNext()) {
Entry/* <String, List<MDResolvedResource>> */entry = (Entry) itMatching
.next();
Message.warn("\t" + entry.getKey());
Iterator itB = ((List) entry.getValue()).iterator();
while (itB.hasNext()) {
MDResolvedResource c = (MDResolvedResource) itB.next();
Message.warn("\t\t" + c.getRevision()
+ (found == c ? " (selected)" : ""));
}
}
} else if (requirementStrategy == RequirementStrategy.noambiguity) {
Message.error("Ambiguity for the '" + osgiType + "' requirement "
+ mrid.getName() + ";version=" + mrid.getRevision());
Iterator itMatching = matching.entrySet().iterator();
while (itMatching.hasNext()) {
Entry/* <String, List<MDResolvedResource>> */entry = (Entry) itMatching
.next();
Message.error("\t" + entry.getKey());
Iterator itB = ((List) entry.getValue()).iterator();
while (itB.hasNext()) {
MDResolvedResource c = (MDResolvedResource) itB.next();
Message.error("\t\t" + c.getRevision()
+ (found == c ? " (best match)" : ""));
}
}
return null;
}
}
}
Message.info("'" + osgiType + "' requirement " + mrid.getName() + ";version="
+ mrid.getRevision() + " satisfied by "
+ ((MDResolvedResource) found).getResolvedModuleRevision().getId().getName()
+ ";" + found.getRevision());
}
return found;
}