|
||||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||||||
See:
Description
| Interface Summary | |
|---|---|
| BindBeforeValidation | Indicates a domain object wishes to perform additional binding before the
Validator is called. |
| IntrospectionManager | Indicates a concrete class capable of introspecting a domain object for its immediate children. |
| ValidationManager | Able to validate any passed domain object instance, including its children. |
| ValidationRegistryManager | ValidationRegistryManager implementations are able to
authoritatively return a Validator instance that is suitable
for a given domain object. |
| Class Summary | |
|---|---|
| BindBeforeValidationUtils | Convenience class that invokes the BindBeforeValidation interface if
the passed domain object has requested it. |
| ValidationAdvisor | Advisor for the ValidationInterceptor. |
| ValidationInterceptor | Calls ValidationManager for method invocations. |
| ValidationManagerImpl | Default implementation of ValidationManager. |
| ValidationRegistryManagerImpl | A basic implementation of ValidationRegistryManager. |
| Exception Summary | |
|---|---|
| ValidatorNotFoundException | Thrown if no Validator could be found that supports a domain
object presented for validation. |
Validation services for complex domain objects.
Generally you will write Validators for each of your domain
objects, and add a ValidationManager to your application context. You
will need to wire a suitable IntrospectionManager against the
ValidationManager so that children of a domain object presented
for validation can be identified and in turn also validated.
The ValidationInterceptor and ValidationAdvisor are provided,
although their use is not recommended against DAOs given many Validators
require a DAO and this will cause a loop that results in the DAO not being
advised. Instead your DAO implementations should have their mutator methods
pass the object to the ValidationManager prior to persistence. This
is a non-AOP approach, but represetns a practical solution.
If you domain objects themselves wish to ensure they are in a valid state
prior to internal business methods being invoked, it is suggested they provide
a ValidationManager collaborator, and fire its validate method.
Such collaborator can be autowired during both instance retrieval and creation.
It should generally also be marked as transient, to avoid possible
serialisation issues if used inside a HttpSession or similar.
Sometimes domain objects need to internally update themselves before being
validated. Any such domain objects should implement BindBeforeValidation.
The ValidationManager will fire the related method just prior to
validation, and you can do it manually using BindBeforeValidationUtils.
Using the utility class is generally preferred over calling the method
directly, as it ignores classes that do not implement
BindBeforeValidation.
Finally, sometimes Validators might need to perform queries
against a persistence or services layer. For example, the Validator
may be checking no other user has this username, or comparing the object's old
state to detect modifications that violate business rules. If using an ORM tool
such as Hibernate, it is recommended you use the EvictionUtils
static methods to remove objects from the session.
|
||||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||||||