org.javalid.external.spring.extension
Class JavalidExtensionSpringImpl

java.lang.Object
  extended by org.javalid.external.spring.extension.JavalidExtensionSpringImpl
All Implemented Interfaces:
JavalidExtension, JavalidExtensionLookup

public class JavalidExtensionSpringImpl
extends java.lang.Object
implements JavalidExtensionLookup

The JaValid Spring extension implementation. This class is responsible for the Spring extension.

Since:
1.1
Version:
1.0
Author:
M.Reuvers

Field Summary
static java.lang.String LOOKUP_CLASS_NAME
           
static java.lang.String LOOKUP_CLASS_VALUE
           
static java.lang.String VALIDATOR_CLASS_NAME
           
static java.lang.String VALIDATOR_CLASS_VALUE
           
 
Constructor Summary
JavalidExtensionSpringImpl()
           
 
Method Summary
 void afterValidation(JvConfigurationWrapper wrapper)
          Once validation is done, this method is called and allows an extension to perform cleanup (if necessary).
 void beforeValidation(JvConfigurationWrapper wrapper)
          Before a the validation starts this methid is called, it can do some initialization or other things that might be needed.
 void configurationLoadingComplete(JvConfigurationWrapper wrapper)
          This method is called by the configuration loader as soon as it is done loading everything needed.
 void destroy()
          Called once the the AnnotationValidator's destroy() method has been called.
 SpringLookupExt getLookup()
          Returns the lookup
 SpringValidatorExt getValidator()
          Returns the validator
 void init(java.util.Map<java.lang.String,java.lang.String> parameters, JvConfigurationWrapper wrapper)
          This method is called only once, as soon as the extension is created (after its constructor has been called) and provides you with the parameters you might have passed to this extension.
 java.lang.Object lookupBean(java.lang.String name)
          Based on given name attempts to lookup a bean.
 java.util.List<ValidationMessage> validate(java.lang.Object currentInstance, java.lang.String prefixPath, java.lang.String beanNameExpression, JvMethod jvMethod)
          This method is called by the JV framework if an object to validate has defined a lookup and thus must be validated through a bean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALIDATOR_CLASS_NAME

public static final java.lang.String VALIDATOR_CLASS_NAME
See Also:
Constant Field Values

VALIDATOR_CLASS_VALUE

public static final java.lang.String VALIDATOR_CLASS_VALUE
See Also:
Constant Field Values

LOOKUP_CLASS_NAME

public static final java.lang.String LOOKUP_CLASS_NAME
See Also:
Constant Field Values

LOOKUP_CLASS_VALUE

public static final java.lang.String LOOKUP_CLASS_VALUE
See Also:
Constant Field Values
Constructor Detail

JavalidExtensionSpringImpl

public JavalidExtensionSpringImpl()
Method Detail

init

public void init(java.util.Map<java.lang.String,java.lang.String> parameters,
                 JvConfigurationWrapper wrapper)
Description copied from interface: JavalidExtension
This method is called only once, as soon as the extension is created (after its constructor has been called) and provides you with the parameters you might have passed to this extension. The wrapper passed along may be used for some Javalid specific data you might need. Keep in mind however that extensions are initialized in the order you specify them in your configuration so not all data might be available so if you need another extension to be fully loaded (e.g. require spring beans from its context) you'd better use the method configurationLoadingComplete() method instead.

Specified by:
init in interface JavalidExtension
Parameters:
parameters - Map with parameters passed to this extension (keys are the name).
wrapper - The config wrapper

configurationLoadingComplete

public void configurationLoadingComplete(JvConfigurationWrapper wrapper)
Description copied from interface: JavalidExtension
This method is called by the configuration loader as soon as it is done loading everything needed. If you require specific data from other extensions etc. this method is the one you'd want. Keep in mind that this method is called in the order of the extensions specified in the configuration file.

If you need parameters from the config file, save them in the init() method, which is called on creation of this extension.

Specified by:
configurationLoadingComplete in interface JavalidExtension
Parameters:
wrapper - The config wrapper

beforeValidation

public void beforeValidation(JvConfigurationWrapper wrapper)
Description copied from interface: JavalidExtension
Before a the validation starts this methid is called, it can do some initialization or other things that might be needed.

Specified by:
beforeValidation in interface JavalidExtension
Parameters:
wrapper - The config wrapper

afterValidation

public void afterValidation(JvConfigurationWrapper wrapper)
Description copied from interface: JavalidExtension
Once validation is done, this method is called and allows an extension to perform cleanup (if necessary).

Specified by:
afterValidation in interface JavalidExtension
Parameters:
wrapper - The config wrapper

destroy

public void destroy()
Description copied from interface: JavalidExtension
Called once the the AnnotationValidator's destroy() method has been called. This allows this extension to cleanup. Do not fully rely on it though.

Specified by:
destroy in interface JavalidExtension

lookupBean

public java.lang.Object lookupBean(java.lang.String name)
Description copied from interface: JavalidExtensionLookup
Based on given name attempts to lookup a bean. Implementors must raise a JavalidLookupFailedException if the bean was NOT found. If the bean was found, but null, simply return null.

Specified by:
lookupBean in interface JavalidExtensionLookup
Parameters:
name - The name to lookup
Returns:
The Object found (even if its null), if not found raise JavalidLookupException

validate

public java.util.List<ValidationMessage> validate(java.lang.Object currentInstance,
                                                  java.lang.String prefixPath,
                                                  java.lang.String beanNameExpression,
                                                  JvMethod jvMethod)
Description copied from interface: JavalidExtensionLookup
This method is called by the JV framework if an object to validate has defined a lookup and thus must be validated through a bean. It is the developer's responsibility to provide JvMethod with parameters that are needed. Think of: Object value and String prefixPath. These can be specified in a JvParam (see docs)

Specified by:
validate in interface JavalidExtensionLookup
Parameters:
currentInstance - The current instance for validation
prefixPath - The prefix path for this instance
beanNameExpression - The name of the spring bean to use
jvMethod - The method containing the actual call to be performed on the bean with ALL needed parameters.
Returns:
List containing ValidationMesssage instances if errors were encountered, if no errors an empty list must be returned.

getValidator

public SpringValidatorExt getValidator()
Returns the validator

Returns:
The validator

getLookup

public SpringLookupExt getLookup()
Returns the lookup

Returns:
The lookup