org.javalid.external.db.extension
Class JavalidExtensionDatabaseImpl

java.lang.Object
  extended by org.javalid.external.db.extension.JavalidExtensionDatabaseImpl
All Implemented Interfaces:
JavalidExtension

public class JavalidExtensionDatabaseImpl
extends java.lang.Object
implements JavalidExtension

The JaValid Database extension implementation. This class is responsible for the database extension.

Since:
1.1
Version:
1.0
Author:
M.Reuvers

Field Summary
static java.lang.String CONFIG_FILE_NAME
           
 
Constructor Summary
JavalidExtensionDatabaseImpl()
           
 
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.
 java.sql.Connection getConnection(java.lang.String dsRef)
          Internally this method works as follows: First checks the DatabaseState, to find out if it can find a shared connection using given dsRef.
 java.lang.String getQuery(java.lang.String refDs, java.lang.String refQuery)
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIG_FILE_NAME

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

JavalidExtensionDatabaseImpl

public JavalidExtensionDatabaseImpl()
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

getConnection

public java.sql.Connection getConnection(java.lang.String dsRef)
Internally this method works as follows: First checks the DatabaseState, to find out if it can find a shared connection using given dsRef. Gets that connection if there, checks if it is open and if that succeeds it returns this connection, if that fails it attempts to find a datasource for given dsRef, on success it fetches a connection from it and returns that (before returning stores the connection in DatabaseState for this dsRef).


getQuery

public java.lang.String getQuery(java.lang.String refDs,
                                 java.lang.String refQuery)