org.javalid.core.config
Class JvConfiguration

java.lang.Object
  extended by org.javalid.core.config.JvConfiguration

public class JvConfiguration
extends java.lang.Object

This class is responsible for loading the xml configuration file(s) and create a valid configuration from it. The loading process is initialized directly from the constructor, hence only 1 instance of this class is needed normally.

The class loads the core configuration xml file only, any config files related to extensionsMap are loaded by the extensionsMap themselves, this class only kicks them off in that case.

Since:
1.0
Version:
1.2
Author:
M.Reuvers

Field Summary
static java.lang.Integer ANNOT_TYPE_CLASS
          An annotation supports class validation.
static java.lang.Integer ANNOT_TYPE_CLASS_AND_FIELD_AND_METHOD
          An annotation supports both class and field and method validation.
static java.lang.Integer ANNOT_TYPE_FIELD_AND_METHOD
          An annotation supports field / method validation.
static java.lang.String EXTENSION_DATABASE_NAME
          Name of the database extension.
static java.lang.String EXTENSION_JSF_NAME
          Name of the jsf extension.
static java.lang.String EXTENSION_SPRING_NAME
          Name of the spring extension.
static java.lang.String JV_CONFIG_DEFAULT_FILE
          Default configuration file that ships in the core jar file and used by AnnotationValidatorImpl by default if not told otherwise (without message resolving as was in javalid 1.1 and older)
static java.lang.String JV_CONFIG_FILE_FIELD
          Same configuration file as the default, except the annotations-on-element is field (the default is method).
static java.lang.String JV_CONFIG_FILE_FIELD_WITH_MSG_RESOLVING
          Same as the JV_CONFIG_FILE_FIELD field, except here message resolving of ValidationMessages is enabled.
static java.lang.String JV_CONFIG_FILE_METHOD_FILE_WITH_MSG_RESOLVING
          Same as the default config file, except here message resolving of ValidationMessages is enabled.
 
Constructor Summary
  JvConfiguration(java.lang.String xmlConfigFile, AnnotationValidator validator)
          Construct this configuration by xmlConfigFile and reference to the validator this config is for.
protected JvConfiguration(java.lang.String xmlConfigFile, java.net.URL urlConfigFile, AnnotationValidator validator)
           
  JvConfiguration(java.net.URL urlConfigFile, AnnotationValidator validator)
          Construct this configuration by urlConfigFile and reference to the validator this config is for.
 
Method Summary
 void callExtensionsAfterValidation(JvConfigurationWrapper wrapper)
          Calls the afterValidation(..) method on each extension
 void callExtensionsBeforeValidation(JvConfigurationWrapper wrapper)
          Calls the beforeValidation(..) method on each extension
 void callExtensionsConfigurationLoadingComplete(JvConfigurationWrapper wrapper)
          Calls the configurationLoadingComplete(..) method on each extension
 JvConfigurationWrapper getConfigWrapper()
          Gets a new configuration wrapper for this configuration.
 javax.el.ELContext getELContext()
          Returns the context that is used by the framework.
 javax.el.ExpressionFactory getExpressionFactory()
          Returns a new ExpressionFactory to use
 JavalidExtension getExtension(java.lang.String nameExtension)
          Returns the extension for given name if found, null otherwise.
 GenericAnnotationCache getGenericAnnotationCache()
          Returns the generic annotation cache
 JavalidValidator getImplementationClassForAnnotation(java.lang.String className)
          Checks the map containing the annotation implementations supported by the framework.
 java.lang.String[] getProxyRecognizers()
          Returns all names to recognize a classname as a proxied object (only valid if isCheckForProxy() returns true, else this returns null).
protected  void init(java.lang.String xmlConfigFile, java.net.URL urlConfigFile)
           
 boolean isCheckAnnotationsOnMethodsGlobalLevel()
          Returns true if annotations must be checked on methods, if false fields must be used.
 boolean isCheckForProxy()
          Return true if classes should check the parent class for an annotation (method annotations e.g) if not found on the current method/class.
 boolean isClassLevelAnnotation(java.lang.String className)
          Returns true if the annotation is meant for class-level (to be annotated on a class).
 boolean isExtensionLoaded(java.lang.String nameExtension)
          Returns true if an extension under given name is loaded, false otherwise.
 boolean isImplementationClassAvailableForAnnotation(java.lang.String className)
          Returns true if for given fully qualified classname of an annotation, a validator is available
 boolean isPluralAnnotationSupported(java.lang.String className)
          Returns true if given plural annotation is supported.
 boolean isResolveMessages()
          Returns true if annotation validators should resolve validation messages.
 java.lang.Object lookupBean(java.lang.String beanLookupName)
          Locates given beanName and returns bean instance if found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JV_CONFIG_DEFAULT_FILE

public static final java.lang.String JV_CONFIG_DEFAULT_FILE
Default configuration file that ships in the core jar file and used by AnnotationValidatorImpl by default if not told otherwise (without message resolving as was in javalid 1.1 and older)

See Also:
Constant Field Values

JV_CONFIG_FILE_FIELD

public static final java.lang.String JV_CONFIG_FILE_FIELD
Same configuration file as the default, except the annotations-on-element is field (the default is method). (without message resolving as was in javalid 1.1 and older)

See Also:
Constant Field Values

JV_CONFIG_FILE_METHOD_FILE_WITH_MSG_RESOLVING

public static final java.lang.String JV_CONFIG_FILE_METHOD_FILE_WITH_MSG_RESOLVING
Same as the default config file, except here message resolving of ValidationMessages is enabled.

See Also:
Constant Field Values

JV_CONFIG_FILE_FIELD_WITH_MSG_RESOLVING

public static final java.lang.String JV_CONFIG_FILE_FIELD_WITH_MSG_RESOLVING
Same as the JV_CONFIG_FILE_FIELD field, except here message resolving of ValidationMessages is enabled.

See Also:
Constant Field Values

ANNOT_TYPE_FIELD_AND_METHOD

public static final java.lang.Integer ANNOT_TYPE_FIELD_AND_METHOD
An annotation supports field / method validation.


ANNOT_TYPE_CLASS

public static final java.lang.Integer ANNOT_TYPE_CLASS
An annotation supports class validation.


ANNOT_TYPE_CLASS_AND_FIELD_AND_METHOD

public static final java.lang.Integer ANNOT_TYPE_CLASS_AND_FIELD_AND_METHOD
An annotation supports both class and field and method validation.


EXTENSION_SPRING_NAME

public static final java.lang.String EXTENSION_SPRING_NAME
Name of the spring extension.

See Also:
Constant Field Values

EXTENSION_JSF_NAME

public static final java.lang.String EXTENSION_JSF_NAME
Name of the jsf extension.

See Also:
Constant Field Values

EXTENSION_DATABASE_NAME

public static final java.lang.String EXTENSION_DATABASE_NAME
Name of the database extension.

See Also:
Constant Field Values
Constructor Detail

JvConfiguration

public JvConfiguration(java.lang.String xmlConfigFile,
                       AnnotationValidator validator)
                throws JavalidException
Construct this configuration by xmlConfigFile and reference to the validator this config is for.

Parameters:
xmlConfigFile - The configuration file
validator - The validator
Throws:
JavalidException - Raised if loading fails

JvConfiguration

public JvConfiguration(java.net.URL urlConfigFile,
                       AnnotationValidator validator)
                throws JavalidException
Construct this configuration by urlConfigFile and reference to the validator this config is for.

Parameters:
urlConfigFile - The configuration url pointing to the configuration file
validator - The validator
Throws:
JavalidException - Raised if loading fails

JvConfiguration

protected JvConfiguration(java.lang.String xmlConfigFile,
                          java.net.URL urlConfigFile,
                          AnnotationValidator validator)
                   throws JavalidException
Throws:
JavalidException
Method Detail

init

protected void init(java.lang.String xmlConfigFile,
                    java.net.URL urlConfigFile)
             throws JavalidException
Throws:
JavalidException

getImplementationClassForAnnotation

public JavalidValidator getImplementationClassForAnnotation(java.lang.String className)
                                                     throws JavalidException
Checks the map containing the annotation implementations supported by the framework. If found returns the implementation class, ready to use. If not found raises an exception.

Parameters:
className - Fully qualified annotation class name to check
Returns:
JvValidator ready for use
Throws:
JavalidException - Raised if no implementation class was found

isImplementationClassAvailableForAnnotation

public boolean isImplementationClassAvailableForAnnotation(java.lang.String className)
Returns true if for given fully qualified classname of an annotation, a validator is available

Parameters:
className - The fully qualified classname of an annotation
Returns:
True if found, false otherwise.

isClassLevelAnnotation

public boolean isClassLevelAnnotation(java.lang.String className)
Returns true if the annotation is meant for class-level (to be annotated on a class). Raises javalidexception if no such annotation is known.

Parameters:
className - The fully qualified classname of an annotation
Returns:
True if found, false otherwise.
Since:
1.2

isPluralAnnotationSupported

public boolean isPluralAnnotationSupported(java.lang.String className)
Returns true if given plural annotation is supported.

Parameters:
className - The annotation classname to check
Returns:
True if supported, false otherwise.
Since:
1.1

lookupBean

public java.lang.Object lookupBean(java.lang.String beanLookupName)
Locates given beanName and returns bean instance if found. If not found, raises a JvLookupFailedException for invalid lookupType raises JvException.

Parameters:
beanLookupName - The beanName to lookup
Returns:
Bean instance if found, JvLookupException if not found.
Since:
1.1

isExtensionLoaded

public boolean isExtensionLoaded(java.lang.String nameExtension)
Returns true if an extension under given name is loaded, false otherwise.

Parameters:
nameExtension - The name of the extension
Returns:
Returns true if an extension under given name is loaded, false otherwise.
Since:
1.1

getExtension

public JavalidExtension getExtension(java.lang.String nameExtension)
Returns the extension for given name if found, null otherwise.

Parameters:
nameExtension - The name of the extension.
Returns:
The extension if found or null
Since:
1.1

callExtensionsBeforeValidation

public void callExtensionsBeforeValidation(JvConfigurationWrapper wrapper)
Calls the beforeValidation(..) method on each extension

Parameters:
wrapper - The config wrapper
Since:
1.1

callExtensionsAfterValidation

public void callExtensionsAfterValidation(JvConfigurationWrapper wrapper)
Calls the afterValidation(..) method on each extension

Parameters:
wrapper - The config wrapper
Since:
1.1

callExtensionsConfigurationLoadingComplete

public void callExtensionsConfigurationLoadingComplete(JvConfigurationWrapper wrapper)
Calls the configurationLoadingComplete(..) method on each extension

Parameters:
wrapper - The config wrapper
Since:
1.1

getConfigWrapper

public JvConfigurationWrapper getConfigWrapper()
Gets a new configuration wrapper for this configuration. Use this to pass around to non-core framework code (such as validation implementations). TODO: Consider creating it here once and return that one instead?

Returns:
Configuration wrapper

isCheckForProxy

public boolean isCheckForProxy()
Return true if classes should check the parent class for an annotation (method annotations e.g) if not found on the current method/class.

Returns:
True if classes should check parent class for an annotation as well if not found on current class

isCheckAnnotationsOnMethodsGlobalLevel

public boolean isCheckAnnotationsOnMethodsGlobalLevel()
Returns true if annotations must be checked on methods, if false fields must be used. This is a global setting defined in the configuration. Classes may override it and thus this may not be true in such case.

Returns:
True if annotations must be checked on methods, if false fields must be used.

getProxyRecognizers

public java.lang.String[] getProxyRecognizers()
Returns all names to recognize a classname as a proxied object (only valid if isCheckForProxy() returns true, else this returns null).

Returns:
Array with names to recognize proxies from (or null if checkForProxy = false).

getELContext

public javax.el.ELContext getELContext()
Returns the context that is used by the framework. The context is created anew each time you call this method (as it cannot be shared among multiple threads!). The resolver returned depends on several settings: 1) By default the framework's own context is returned (if jsflookup is disabled) 2) If jsflookup is enabled, returns a jsf enabled context, topped by the frameworks resolver (JaValid's resolver has precedence in the chain). Also works for JSF 1.1, which is topped by a custom resolver and then internally falling back to its ValueBinding's and that...

Returns:
Current context used by the framework
Since:
1.1

getExpressionFactory

public javax.el.ExpressionFactory getExpressionFactory()
Returns a new ExpressionFactory to use

Returns:
ExpressionFactory to use.
Since:
1.1

getGenericAnnotationCache

public GenericAnnotationCache getGenericAnnotationCache()
Returns the generic annotation cache

Returns:
Generic annotation cache

isResolveMessages

public boolean isResolveMessages()
Returns true if annotation validators should resolve validation messages. False otherwise.

Returns:
True if annotation validators should resolve validaton messages. False otherwise.
Since:
1.2