Improve logging.

This commit is contained in:
Ben Alex 2005-05-17 01:05:13 +00:00
parent 14e384051b
commit ee3a14ab1b
1 changed files with 6 additions and 1 deletions

View File

@ -117,18 +117,23 @@ public class ValidationRegistryManagerImpl implements ValidationRegistryManager,
return beans.get(validator);
} else {
// Try to locate an entry with simple class name in it
StringBuffer sb = new StringBuffer();
Iterator<String> iterCandidates = candidateValidatorNames.iterator();
String lastFound = null;
int numberFound = 0;
while (iterCandidates.hasNext()) {
String candidate = iterCandidates.next();
sb.append(candidate);
if (iterCandidates.hasNext()) {
sb.append(",");
}
if (candidate.toLowerCase().contains(domainClass.getSimpleName().toLowerCase())) {
numberFound++;
lastFound = candidate;
}
}
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);
return beans.get(lastFound);