uk.org.ogsadai.sessions
Class SessionConfigurationLoader

java.lang.Object
  |
  +--uk.org.ogsadai.sessions.SessionConfigurationLoader
All Implemented Interfaces:
SessionComponentFactory

public class SessionConfigurationLoader
extends java.lang.Object
implements SessionComponentFactory

This class loads an XML session configuration file conforming to the session_config.xsd schema. It then instantiates the SessionManagerFactory described by the sessionManagerFactory element of the document. Finally, it constructs a SimpleSessionCoordinator using this factory. The getSessionCoordinator method provides access to this.

Author:
The OGSA-DAI Project Team

Field Summary
private static?java.lang.String COPYRIGHT_NOTICE
??????????Copyright statement
private static?DAILogger LOG
??????????Logger object for this class
private ?boolean mAreComponentsBuilt
??????????Have the session components been built?
private ?SessionCoordinator mCoordinator
??????????Session coordinator component.
private ?DataResourceAccessor mDataResourceAccessor
??????????Data resource accessor associated with the session components
private ?Properties mResourceProperties
??????????Resource properties associated with the the session components
private ?org.w3c.dom.Element mSessionConfig
??????????Session configuration element
private ?java.io.File mSessionConfigFile
??????????Session configuration file
private ?SessionManagerFactory mSessionManagerFactory
??????????Session manager factory
?
Constructor Summary
SessionConfigurationLoader(java.io.File?sessionConfigFile)
??????????Creates a SessionConfigurationLoader using the specified session configuration file.
?
Method Summary
private ?void buildComponents()
??????????Builds the session components if they have not already been built.
private ?org.w3c.dom.Element buildElement(java.io.File?sessionConfiguration)
??????????Builds a document from the specified XML file and returns the root element.
(package private) ?SessionManagerFactory createSessionManagerFactory(java.lang.String?className)
??????????Creates and initialises a SessionManagerFactory using reflection.
?SessionCoordinator getSessionCoordinator()
??????????Gets the session coordinator for the data service resource.
private ?java.lang.String parseFactoryClassName(org.w3c.dom.Element?config)
??????????Parses and returns the SessionManagerFactory class name from the sessionConfiguration element.
?void setDataResourceAccessor(DataResourceAccessor?dataResourceAccessor)
??????????Specifies the data resource accessor associated with the data service resource.
?void setResourceProperties(Properties?resourceProperties)
??????????Specifies the data resource properties associated with the data 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 final DAILogger LOG
Logger object for this class


mSessionConfigFile

private final java.io.File mSessionConfigFile
Session configuration file


mSessionConfig

private final org.w3c.dom.Element mSessionConfig
Session configuration element


mSessionManagerFactory

private final SessionManagerFactory mSessionManagerFactory
Session manager factory


mDataResourceAccessor

private DataResourceAccessor mDataResourceAccessor
Data resource accessor associated with the session components


mResourceProperties

private Properties mResourceProperties
Resource properties associated with the the session components


mAreComponentsBuilt

private boolean mAreComponentsBuilt
Have the session components been built?


mCoordinator

private SessionCoordinator mCoordinator
Session coordinator component.

Constructor Detail

SessionConfigurationLoader

public SessionConfigurationLoader(java.io.File?sessionConfigFile)
                           throws SessionManagerFactoryCreationException
Creates a SessionConfigurationLoader using the specified session configuration file.

Parameters:
sessionConfigFile - The session configuration file.
Throws:
SessionManagerFactoryCreationException - if the session manager factory could not be created.
java.lang.IllegalArgumentException - if the sessionConfig argument is null.
Method Detail

setDataResourceAccessor

public void setDataResourceAccessor(DataResourceAccessor?dataResourceAccessor)
Description copied from interface: SessionComponentFactory
Specifies the data resource accessor associated with the data service resource.

Specified by:
setDataResourceAccessor in interface SessionComponentFactory
Parameters:
dataResourceAccessor - The data resource accessor.

setResourceProperties

public void setResourceProperties(Properties?resourceProperties)
Description copied from interface: SessionComponentFactory
Specifies the data resource properties associated with the data resource. Session components may add, delete or alter the set of data resource properties.

Specified by:
setResourceProperties in interface SessionComponentFactory
Parameters:
resourceProperties -

getSessionCoordinator

public SessionCoordinator getSessionCoordinator()
                                         throws DAIException
Gets the session coordinator for the data service resource. This method must only be called after the setDataResourceAccessor and setResourceProperties methods have both been called.

Specified by:
getSessionCoordinator in interface SessionComponentFactory
Returns:
The session coordinator for the data service resource.
Throws:
java.lang.IllegalStateException - If this method is called before the setDataResourceAccessor and setResourceProperties methods have been called.
DAIException - If an error occurs constructing the serssion coordinator.

buildComponents

private void buildComponents()
                      throws SessionManagerCreationException
Builds the session components if they have not already been built.

Throws:
SessionManagerCreationException - If there is a error creating the session manager.

buildElement

private org.w3c.dom.Element buildElement(java.io.File?sessionConfiguration)
                                  throws SessionManagerFactoryCreationException
Builds a document from the specified XML file and returns the root element.

Parameters:
sessionConfiguration - Session manager factory configuration file.
Returns:
root element of specified XML file.
Throws:
SessionManagerFactoryCreationException - if there is a problem in the loading or parsing.

parseFactoryClassName

private java.lang.String parseFactoryClassName(org.w3c.dom.Element?config)
Parses and returns the SessionManagerFactory class name from the sessionConfiguration element.

An empty string is returned if the class name is not specified, but this should not happen because the XML Schema should ensure the attribute is present and specifies a Java class.

Parameters:
config - XML fragment holding the class name.
Returns:
the class name or the empty string.

createSessionManagerFactory

SessionManagerFactory createSessionManagerFactory(java.lang.String?className)
                                            throws SessionManagerFactoryCreationException
Creates and initialises a SessionManagerFactory using reflection.

This method has package-level accessibility to facilitate testing.

Parameters:
className - The name of the SessionManagerFactory implementation class.
Returns:
a new SessionManagerFactory
Throws:
SessionManagerFactoryCreationException - if there is a problem in the creation or initialisation.