diff --git a/domain/src/main/java/org/acegisecurity/domain/validation/ValidationRegistryManagerImpl.java b/domain/src/main/java/org/acegisecurity/domain/validation/ValidationRegistryManagerImpl.java index 317f6e2e6d..0aca977d8a 100644 --- a/domain/src/main/java/org/acegisecurity/domain/validation/ValidationRegistryManagerImpl.java +++ b/domain/src/main/java/org/acegisecurity/domain/validation/ValidationRegistryManagerImpl.java @@ -16,8 +16,10 @@ package net.sf.acegisecurity.domain.validation; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.Map; +import java.util.Set; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; @@ -34,6 +36,29 @@ import org.springframework.validation.Validator; *
* Locates Validators registered in bean factory.
*
If more than one Validator can support a given object, the
+ * supporting Validators will be iterated and their bean factory
+ * defined bean names will be used to attempt to select the "best matching"
+ * Validator. The lowercase version of a given object's simplified
+ * class name will be searched within the bean names. If more than one
+ * Validator contains this search criteria, an exception will be
+ * thrown as the actual intended Validator is unidentifiable.
+ *
+ *
For example, say you had a PartyValidator which could validate
+ * com.foo.Party, and also its subclass, com.foo.Person. There is also a
+ * PersonValidator which can only validate Person. PartyValidator and
+ * PersonValidator are registered in the bean container as "partyValidator"
+ * and "personValidator". When ValidationRegistryManagerImpl
+ * is asked to return the Validator for Person, it will locate
+ * the two matching Validators in the bean container. As there
+ * are two matching, it will look at the lowercase representation of the
+ * bean names and see if either contain the lower simplified class name of
+ * the object being search for (com.foo.Person thus becomes simply "person").
+ * ValidationRegistryManagerImpl will then correctly return the
+ * PersonValidator for Person. If the PartyValidator had been registered with
+ * an ambiguous bean name of say "personAndPartyValidator", both bean names
+ * would have matched and an exception would have been thrown.
*
* @author Matthew E. Porter
* @author Ben Alex
@@ -69,19 +94,45 @@ public class ValidationRegistryManagerImpl implements ValidationRegistryManager,
// Attempt to find Validator via introspection
Map