org.acegisecurity.domain.validation
Class ValidationRegistryManagerImpl

java.lang.Object
  extended by org.acegisecurity.domain.validation.ValidationRegistryManagerImpl
All Implemented Interfaces:
ValidationRegistryManager, BeanFactoryAware

public class ValidationRegistryManagerImpl
extends Object
implements ValidationRegistryManager, BeanFactoryAware

A basic implementation of ValidationRegistryManager.

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.

Version:
$Id: ValidationRegistryManagerImpl.java,v 1.7 2005/11/17 00:55:50 benalex Exp $
Author:
Matthew E. Porter, Ben Alex

Constructor Summary
ValidationRegistryManagerImpl()
           
 
Method Summary
 Validator findValidator(Class domainClass)
          Obtains the Validator that applies for a given domain object class.
 void registerValidator(Class domainClass, String beanName)
           
 void setBeanFactory(BeanFactory beanFactory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidationRegistryManagerImpl

public ValidationRegistryManagerImpl()
Method Detail

setBeanFactory

public void setBeanFactory(BeanFactory beanFactory)
                    throws BeansException
Specified by:
setBeanFactory in interface BeanFactoryAware
Throws:
BeansException

findValidator

public Validator findValidator(Class domainClass)
Description copied from interface: ValidationRegistryManager
Obtains the Validator that applies for a given domain object class.

Specified by:
findValidator in interface ValidationRegistryManager
Parameters:
domainClass - that a Validator is required for
Returns:
the Validator, or null if no Validator is known for the indicated domainClass

registerValidator

public void registerValidator(Class domainClass,
                              String beanName)


Copyright © 2004-2005 Acegi Technology Pty Limited. All Rights Reserved.