org.mod4j.runtime.validation
Class BusinessRuleValidationTemplate

java.lang.Object
  extended by org.mod4j.runtime.validation.BusinessRuleValidationTemplate

public class BusinessRuleValidationTemplate
extends java.lang.Object

Template class that simplifies business rule validation. The central method is execute(org.mod4j.runtime.validation.BusinessRuleValidationCallback), supporting validations implementing the BusinessRuleValidationCallback interface. It provides for the creation of an Errors object for storing all errors found while validating fields of a particular object in the BusinessRuleValidationCallback.doValidate(Object, Errors) method. After all validations are executed and the results collected in the Errors object and if one or more errors are found, a BusinessRuleException is thrown that wraps the the BindException object that implements the Errors object is thrown as an exception.

Author:
Eric Jan Malotaux

Constructor Summary
BusinessRuleValidationTemplate(java.lang.Object object)
          Creates a new BusinessRuleValidationTemplate instance.
 
Method Summary
 void execute(BusinessRuleValidationCallback action)
          Execute the BusinessRuleValidationCallback.doValidate(Object, Errors) method of the given action on the current object.
 void invokeValidator(org.springframework.validation.Validator validator)
          Invoke the given validator on the current object.
 void invokeValidators(java.util.List<org.springframework.validation.Validator> validators)
          Invoke the given validators on the current object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BusinessRuleValidationTemplate

public BusinessRuleValidationTemplate(java.lang.Object object)
Creates a new BusinessRuleValidationTemplate instance. Field validations are performed on named fields of the given object.

Parameters:
object -
Method Detail

invokeValidator

public void invokeValidator(org.springframework.validation.Validator validator)
Invoke the given validator on the current object.

Parameters:
validator -
Throws:
BusinessRuleException - when the validator finds an error.

invokeValidators

public void invokeValidators(java.util.List<org.springframework.validation.Validator> validators)
Invoke the given validators on the current object.

Parameters:
validators - - the validators to invoke.
Throws:
BusinessRuleException - - thrown when one of the validators finds an error.

execute

public void execute(BusinessRuleValidationCallback action)
Execute the BusinessRuleValidationCallback.doValidate(Object, Errors) method of the given action on the current object.

Parameters:
action - - the BusinessRuleValidationCallback to invoke its BusinessRuleValidationCallback.doValidate(Object, Errors) method on.
Throws:
BusinessRuleException - - thrown when the BusinessRuleValidationCallback.doValidate(Object, Errors) method added one ore more errors to its errors object.


Copyright © 2009. All Rights Reserved.