uk.org.ogsadai.dataresource
Class SQLMultipleDataResourceAccessor

java.lang.Object
  |
  +--uk.org.ogsadai.dataresource.SQLMultipleDataResourceAccessor
All Implemented Interfaces:
DataResourceAccessor, PersistInFiles

public class SQLMultipleDataResourceAccessor
extends java.lang.Object
implements DataResourceAccessor, PersistInFiles

A data resource accessor that provides access to a number of data resources. These should be relational databases.

The configuration file is named dataResourceConfig.xml and is assumed to reside in the configuration files directory for the data service resource that owns this data resource accessor.

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
private static java.lang.String DATA_SERVICE_CONFIG_ELEMENT
          The element describing each one of the data service resources connected to the multiple data service resource.
private static DAILogger LOG
          Logger object for logging in this class.
private static java.lang.String MAIN_CONFIG_FILE_NAME
          The name of XML configuration file
private  java.lang.String mDataResourceName
          the name of the multiple data service resource
private  DataServiceInfo[] mMultipleDS
          information about data service resources connected to the multiple data service resource.
private  Property[] mProperties
          the properties of this data service resource
private  StatusOfDataServices mStatusCallback
          the status of the data service resources connected to the multiple data service resource.
 
Constructor Summary
SQLMultipleDataResourceAccessor()
           
 
Method Summary
private  Property[] constructProperties()
          Constructs the data resource properties.
private  org.w3c.dom.Document getConfigAsDOM(java.lang.String name, java.io.File configDirectory)
          Reads the main configuration file and returns the XML as a DOM.
 DataServiceInfo[] getMultipleDS()
          Get Info for multiple Data Services.
 Property[] getProperties()
          Returns the resource properties that will be available to service users via the resource properties mechanism.
 void onBeginRequest()
          Notifies the data resource that a new request is about to be processed.
 void onBeginSession()
          Notifies the data resource that a new session has been started.
 void onContainerShutdown()
          Notifies the data resource that the container is about to shutdown.
 void onEndRequest()
          Notifies the data resource that a request has ended.
 void onEndSession()
          Notifies the data resource that a session has ended.
 void restoreFromConfig(java.io.File directory)
          Configures the data resource accessor by reading any relevant configuration files in the given directory.
 void setResourceName(java.lang.String resourceName)
          Sets the name of the resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
Copyright statement

See Also:
Constant Field Values

LOG

private static DAILogger LOG
Logger object for logging in this class.


MAIN_CONFIG_FILE_NAME

private static final java.lang.String MAIN_CONFIG_FILE_NAME
The name of XML configuration file

See Also:
Constant Field Values

DATA_SERVICE_CONFIG_ELEMENT

private static final java.lang.String DATA_SERVICE_CONFIG_ELEMENT
The element describing each one of the data service resources connected to the multiple data service resource.

See Also:
Constant Field Values

mDataResourceName

private java.lang.String mDataResourceName
the name of the multiple data service resource


mProperties

private Property[] mProperties
the properties of this data service resource


mMultipleDS

private DataServiceInfo[] mMultipleDS
information about data service resources connected to the multiple data service resource.


mStatusCallback

private StatusOfDataServices mStatusCallback
the status of the data service resources connected to the multiple data service resource.

Constructor Detail

SQLMultipleDataResourceAccessor

public SQLMultipleDataResourceAccessor()
Method Detail

setResourceName

public void setResourceName(java.lang.String resourceName)
Description copied from interface: DataResourceAccessor
Sets the name of the resource. This method will be called one before any other methods in this interface are called. Data resource accessors are not required to do anything with this name although it is sometimes useful to include it in any error messages.

Specified by:
setResourceName in interface DataResourceAccessor
Parameters:
resourceName - Name of the data service resource which will use this data resource accessor to mediate access to a data resource.

restoreFromConfig

public void restoreFromConfig(java.io.File directory)
                       throws DataResourceAccessorConfigException,
                              DataResourceAccessorMetaDataException,
                              DataResourceAccessorSetupException,
                              java.lang.IllegalArgumentException
Description copied from interface: PersistInFiles
Configures the data resource accessor by reading any relevant configuration files in the given directory.

If a data service resource is being constructed by reading from a configuration file this method will be called once immediately after the setName method is called. The data resource accessor should read its configuration from the files in the given directory of the data service resource which uses it.

Data resource accessors are free to add, amend or delete files in the given directory at any time throughout their lifetime. The exception to this rule is the dataResourceClassConfig.xml file which must be left unaltered since this specifies the data resource accessor class name.

Specified by:
restoreFromConfig in interface PersistInFiles
Parameters:
directory - Directory containing the data service resource configuration files. This includes the data resource accessor configuration files.
Throws:
java.lang.IllegalArgumentException - if the directory argument is null or is not a directory.
DataResourceAccessorSetupException - if an error occurs when setting up the data resource accessor after having read the configuration files.
DataResourceAccessorConfigException - if an error occurs reading the configuration files.
DataResourceAccessorMetaDataException - if an error occurs when constructing data resource accessor meta data properties.

getProperties

public Property[] getProperties()
Returns the resource properties that will be available to service users via the resource properties mechanism.

Specified by:
getProperties in interface DataResourceAccessor
Returns:
Resource properties.

onBeginSession

public void onBeginSession()
Notifies the data resource that a new session has been started.

The implementation of this method must be thread safe as multiple threads may begin new session concurrently.


onEndSession

public void onEndSession()
Notifies the data resource that a session has ended.

The implementation of this method must be thread safe as multiple threads may end sessions concurrently.


onBeginRequest

public void onBeginRequest()
Notifies the data resource that a new request is about to be processed.

The implementation of this method must be thread safe as multiple threads may process requests concurrently.


onEndRequest

public void onEndRequest()
Notifies the data resource that a request has ended.

The implementation of this method must be thread safe as multiple threads may be process requests concurrently.


onContainerShutdown

public void onContainerShutdown()
Notifies the data resource that the container is about to shutdown.

There is no guarantee that calls to other methods will not be received during or after this call.


getMultipleDS

public DataServiceInfo[] getMultipleDS()
Get Info for multiple Data Services.


getConfigAsDOM

private org.w3c.dom.Document getConfigAsDOM(java.lang.String name,
                                            java.io.File configDirectory)
                                     throws DataResourceAccessorConfigException
Reads the main configuration file and returns the XML as a DOM.

Parameters:
configDirectory - Data resource configuration directory.
Returns:
The data resource configuration as a DOM.
Throws:
DataResourceConfigException - Thrown if there was an error in the configuration details.
DAIFileNotFoundException - Thrown if the configuration file is not found.
DAIFileReadIOException - Thrown if there is an error reading the configuration file.
DAIFileContentError - Thrown if there is an error in the contents of the configuration file, i.e. the XML is invalid according to the schema.
InternalException
DataResourceAccessorConfigException

constructProperties

private Property[] constructProperties()
Constructs the data resource properties.

Returns:
An array of the constucted properties.