// we cannot just assume a meaningful default
}
// match up the version
if (ver != null) {
Version version = new Version(ver);
// version specified, look for a match (and allow version
// generic ones to live by)
for (Iterator itr = vmatches.iterator(); itr.hasNext();) {
XmlRequestReader r = (XmlRequestReader) itr.next();
if (r.getVersion() == null || version.equals(r.getVersion())) {
continue;
}
itr.remove();
}
if (vmatches.isEmpty()) {
// no matching version found, drop out and next step
// will sort to return highest version
vmatches = new ArrayList(matches);
}
}
//multiple readers found, sort by version and by service match
if (vmatches.size() > 1) {
//use highest version
Comparator comparator = new Comparator() {
public int compare(Object o1, Object o2) {
XmlRequestReader r1 = (XmlRequestReader) o1;
XmlRequestReader r2 = (XmlRequestReader) o2;
Version v1 = r1.getVersion();
Version v2 = r2.getVersion();
if ((v1 == null) && (v2 == null)) {
return 0;
}