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.1
Author:
M.Reuvers

Field Summary
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.
 
Constructor Summary
JvConfiguration(java.lang.String xmlConfigFile, AnnotationValidator validator)
          Construct this configuration by xmlConfigFile 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
 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.
 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)
           
 boolean isCheckAnnotationsOnMethods()
          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 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.
 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.

See Also:
Constant Field Values

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
Method Detail

init

protected void init(java.lang.String xmlConfigFile)
             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.

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

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

isCheckAnnotationsOnMethods

public boolean isCheckAnnotationsOnMethods()
Returns true if annotations must be checked on methods, if false fields must be used.

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