Class DefaultActionValidatorManager
- All Implemented Interfaces:
- ActionValidatorManager
- Direct Known Subclasses:
- AnnotationActionValidatorManager
This is the entry point into XWork's rule-based validation framework.
 Validation rules are specified in XML configuration files named className-contextName-validation.xml where
 className is the name of the class the configuration is for and -contextName is optional
 (contextName is an arbitrary key that is used to look up additional validation rules for a
 specific context).
 
- Author:
- Jason Carreira, Mark Woon, James House, Rainer Hermanns
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected FileManagerprotected booleanprotected TextProviderFactoryprotected static final StringThe file suffix for any validation file.protected final Map<String,List<ValidatorConfig>> protected ValidatorFactoryprotected final Map<String,List<ValidatorConfig>> protected ValidatorFileParser
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected List<ValidatorConfig>buildAliasValidatorConfigs(Class<?> aClass, String context, boolean checkFile) protected List<ValidatorConfig>buildClassValidatorConfigs(Class<?> aClass, boolean checkFile) protected List<ValidatorConfig>buildValidatorConfigs(Class<?> clazz, String context, boolean checkFile, Set<String> checked) This method 'collects' all the validator configurations for a given action invocation.protected StringbuildValidatorKey(Class<?> clazz, String context) Builds a key for validators - used when caching validators.protected ValidatorgetValidatorFromValidatorConfig(ValidatorConfig config, ValueStack stack) getValidators(Class<?> clazz, String context) Returns a list of validators for the given class and context.getValidators(Class<?> clazz, String context, String method) Returns a list of validators for the given class, context, and method.protected List<ValidatorConfig>voidsetFileManagerFactory(FileManagerFactory fileManagerFactory) voidsetReloadingConfigs(String reloadingConfigs) voidsetTextProviderFactory(TextProviderFactory textProviderFactory) voidvoidvoidValidates the given object using action and its context.voidValidates the given object using an action, its context, and the name of the method being invoked on the action.voidvalidate(Object object, String context, ValidatorContext validatorContext) Validates an action give its context and a validation context.voidvalidate(Object object, String context, ValidatorContext validatorContext, String method) Validates an action give its context and a validation context.
- 
Field Details- 
VALIDATION_CONFIG_SUFFIXThe file suffix for any validation file.- See Also:
 
- 
validatorCache
- 
validatorFileCache
- 
validatorFactory
- 
validatorFileParser
- 
fileManager
- 
reloadingConfigsprotected boolean reloadingConfigs
- 
textProviderFactory
 
- 
- 
Constructor Details- 
DefaultActionValidatorManagerpublic DefaultActionValidatorManager()
 
- 
- 
Method Details- 
setValidatorFactory
- 
setValidatorFileParser
- 
setFileManagerFactory
- 
setReloadingConfigs
- 
setTextProviderFactory
- 
validateDescription copied from interface:ActionValidatorManagerValidates the given object using action and its context.- Specified by:
- validatein interface- ActionValidatorManager
- Parameters:
- object- the action to validate.
- context- the action's context.
- Throws:
- ValidationException- if an error happens when validating the action.
 
- 
validateDescription copied from interface:ActionValidatorManagerValidates the given object using an action, its context, and the name of the method being invoked on the action.- Specified by:
- validatein interface- ActionValidatorManager
- Parameters:
- object- the action to validate.
- context- the action's context.
- method- the name of the method being invoked on the action - can be null.
- Throws:
- ValidationException- if an error happens when validating the action.
 
- 
validatepublic void validate(Object object, String context, ValidatorContext validatorContext) throws ValidationException Description copied from interface:ActionValidatorManagerValidates an action give its context and a validation context.- Specified by:
- validatein interface- ActionValidatorManager
- Parameters:
- object- the action to validate.
- context- the action's context.
- validatorContext- the validation context to use
- Throws:
- ValidationException- if an error happens when validating the action.
 
- 
buildValidatorKeyBuilds a key for validators - used when caching validators.- Parameters:
- clazz- the action.
- context- context
- Returns:
- a validator key which is the class name plus context.
 
- 
getValidatorFromValidatorConfig
- 
getValidatorsDescription copied from interface:ActionValidatorManagerReturns a list of validators for the given class, context, and method. This is the primary lookup method for validators.- Specified by:
- getValidatorsin interface- ActionValidatorManager
- Parameters:
- clazz- the class to lookup.
- context- the context of the action class - can be null.
- method- the name of the method being invoked on the action - can be null.
- Returns:
- a list of all validators for the given class and context.
 
- 
getValidatorsDescription copied from interface:ActionValidatorManagerReturns a list of validators for the given class and context. This is the primary lookup method for validators.- Specified by:
- getValidatorsin interface- ActionValidatorManager
- Parameters:
- clazz- the class to lookup.
- context- the context of the action class - can be null.
- Returns:
- a list of all validators for the given class and context.
 
- 
validatepublic void validate(Object object, String context, ValidatorContext validatorContext, String method) throws ValidationException Description copied from interface:ActionValidatorManagerValidates an action give its context and a validation context.- Specified by:
- validatein interface- ActionValidatorManager
- Parameters:
- object- the action to validate.
- context- the action's context.
- validatorContext- the validation context to use
- method- the name of the method being invoked on the action - can be null.
- Throws:
- ValidationException- if an error happens when validating the action.
 
- 
buildValidatorConfigsprotected List<ValidatorConfig> buildValidatorConfigs(Class<?> clazz, String context, boolean checkFile, Set<String> checked) This method 'collects' all the validator configurations for a given action invocation. It will traverse up the class hierarchy looking for validators for every super class and directly implemented interface of the current action, as well as adding validators for any alias of this invocation. Nifty! Given the following class structure: interface Thing; interface Animal extends Thing; interface Quadraped extends Animal; class AnimalImpl implements Animal; class QuadrapedImpl extends AnimalImpl implements Quadraped; class Dog extends QuadrapedImpl; This method will look for the following config files for Dog: Animal Animal-context AnimalImpl AnimalImpl-context Quadraped Quadraped-context QuadrapedImpl QuadrapedImpl-context Dog Dog-context Note that the validation rules for Thing is never looked for because no class in the hierarchy directly implements Thing. - Parameters:
- clazz- the Class to look up validators for.
- context- the context to use when looking up validators.
- checkFile- true if the validation config file should be checked to see if it has been updated.
- checked- the set of previously checked class-contexts, null if none have been checked
- Returns:
- a list of validator configs for the given class and context.
 
- 
buildAliasValidatorConfigsprotected List<ValidatorConfig> buildAliasValidatorConfigs(Class<?> aClass, String context, boolean checkFile) 
- 
buildClassValidatorConfigs
- 
loadFile
 
-