Improve logging.

This commit is contained in:
Ben Alex 2005-05-17 01:05:13 +00:00
parent 14e384051b
commit ee3a14ab1b

View File

@ -117,18 +117,23 @@ public class ValidationRegistryManagerImpl implements ValidationRegistryManager,
return beans.get(validator); return beans.get(validator);
} else { } else {
// Try to locate an entry with simple class name in it // Try to locate an entry with simple class name in it
StringBuffer sb = new StringBuffer();
Iterator<String> iterCandidates = candidateValidatorNames.iterator(); Iterator<String> iterCandidates = candidateValidatorNames.iterator();
String lastFound = null; String lastFound = null;
int numberFound = 0; int numberFound = 0;
while (iterCandidates.hasNext()) { while (iterCandidates.hasNext()) {
String candidate = iterCandidates.next(); String candidate = iterCandidates.next();
sb.append(candidate);
if (iterCandidates.hasNext()) {
sb.append(",");
}
if (candidate.toLowerCase().contains(domainClass.getSimpleName().toLowerCase())) { if (candidate.toLowerCase().contains(domainClass.getSimpleName().toLowerCase())) {
numberFound++; numberFound++;
lastFound = candidate; lastFound = candidate;
} }
} }
if (numberFound != 1) { if (numberFound != 1) {
throw new IllegalArgumentException("More than one Validator found that supports '" + domainClass + "' and cannot determine most specific Validator to use; give a hint by making bean name include the simple name of the target class"); throw new IllegalArgumentException("More than one Validator found (" + sb.toString() + ") that supports '" + domainClass + "', but cannot determine the most specific Validator to use; give a hint by making bean name include the simple name of the target class ('" + domainClass.getSimpleName().toString() + "')");
} }
this.validatorMap.put(domainClass, lastFound); this.validatorMap.put(domainClass, lastFound);
return beans.get(lastFound); return beans.get(lastFound);