uk.ac.soton.itinnovation.grid.service.ogsadai
Class OgsaDaiDataResourceManager

java.lang.Object
  extended by uk.ac.soton.itinnovation.grid.service.ogsadai.OgsaDaiDataResourceManager
All Implemented Interfaces:
DataResourceManager
Direct Known Subclasses:
PlaintextDataResourceManager, RDBMSDataResourceManager

public abstract class OgsaDaiDataResourceManager
extends Object
implements DataResourceManager

Implementation of DataResourceManager that provides functionality common to all OGSA-DAI based services. This functionality includes configuration file handling, creating an OgsaDaiInstance, and convenience methods to read and write files.


Field Summary
protected  File configurationDirectory
           
protected static org.apache.log4j.Logger log
           
protected  OgsaDaiInstance ogsaDaiInstance
           
protected  String schemaUrl
           
protected  File skeletonDirectory
           
 
Constructor Summary
OgsaDaiDataResourceManager()
          Finds configuration directories, calls reloadConfiguration(), calls createOgsaDaiInstance().
 
Method Summary
protected  void createOgsaDaiInstance()
          Create a DefaultOgsaDaiInstance.
protected  String getGriaConfigDirectory()
          Find the path to the GRIA configuration directory.
 OgsaDaiInstance getOgsaDaiInstance()
           
protected  String getSchemaURL(String webInfPath)
          Return a file:// URL pointing to a directory containing the OGSA-DAI XML schema directory.
protected  ServiceConfiguration getServiceConfiguration()
          Return a ServiceConfiguration object - if possible from a cache.
protected  String getWebInfDirectory()
          Return the absolute path to the web service's WEB-INF directory.
 boolean isConfigurationLoaded()
          Determine whether configuration files have been loaded and the service is ready to respond to requests.
protected  Properties loadPropertiesFile(String fileName)
          Convenience method to load and return a properties file given by a filename.
protected  String readFile(InputStream stream)
          Read and return the contents of an input stream.
protected  String readFileFromClassPath(String fileName)
          Read and return the contents of a file from the classpath.
protected  String readSkeletonFile(String fileName)
          Read and return the contents of a skeleton file.
 void setConfigurationLoaded(boolean isConfigurationLoaded)
          Set the isConfigurationLoaded field.
protected  void writeFile(File file, String data)
          Write the contents of a string to a file This is a convenience method.
protected  void writeFile(File directory, String fileName, String data)
          Write the contents of a string to a named file in a given directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uk.ac.soton.itinnovation.grid.service.dataresource.DataResourceManager
connectDataResource, connectDataResourceRole, createDataResource, createDataResourceRole, createDataResourceSubscription, createDefaultRoles, destroyDataResource, destroyDataResourceRole, destroyDataResourceSubscription, disconnectDataResource, disconnectDataResourceRole, reloadConfiguration, writeDataResourceConfiguration
 

Field Detail

skeletonDirectory

protected File skeletonDirectory

configurationDirectory

protected File configurationDirectory

schemaUrl

protected String schemaUrl

ogsaDaiInstance

protected OgsaDaiInstance ogsaDaiInstance

log

protected static org.apache.log4j.Logger log
Constructor Detail

OgsaDaiDataResourceManager

public OgsaDaiDataResourceManager()
Finds configuration directories, calls reloadConfiguration(), calls createOgsaDaiInstance().

Method Detail

createOgsaDaiInstance

protected void createOgsaDaiInstance()
Create a DefaultOgsaDaiInstance. Override this method if you need to create a different implementation of OgsaDaiInstance.


readSkeletonFile

protected String readSkeletonFile(String fileName)
                           throws IOException
Read and return the contents of a skeleton file. Skeleton files are located in skeletonDirectory. This is a convenience method.

Parameters:
fileName - The name of the skeleton file relative to skeletonDirectory
Returns:
The entire contents of the skeleton file
Throws:
IOException

readFileFromClassPath

protected String readFileFromClassPath(String fileName)
                                throws IOException
Read and return the contents of a file from the classpath. This is a convenience method.

Parameters:
fileName - The name of the file to read
Returns:
The entire contents of the file
Throws:
IOException

readFile

protected String readFile(InputStream stream)
                   throws IOException
Read and return the contents of an input stream. This is a convenience method.

Parameters:
stream - The stream from which to read
Returns:
The entire contents of the stream
Throws:
IOException

writeFile

protected void writeFile(File directory,
                         String fileName,
                         String data)
                  throws IOException
Write the contents of a string to a named file in a given directory. This is a convenience method.

Parameters:
directory -
fileName -
data -
Throws:
IOException

writeFile

protected void writeFile(File file,
                         String data)
                  throws IOException
Write the contents of a string to a file This is a convenience method.

Parameters:
file -
data -
Throws:
IOException

getWebInfDirectory

protected String getWebInfDirectory()
Return the absolute path to the web service's WEB-INF directory. This can be useful for loading any metadata bundled with the webapp.

Returns:
The absolute path to the WEB-INF directory.

getSchemaURL

protected String getSchemaURL(String webInfPath)
Return a file:// URL pointing to a directory containing the OGSA-DAI XML schema directory. This is useful when generating OGSA-DAI configuration files, as the xsi:schemaLocation attribute needs to be set to a valid URL. Example usage of this URL in an XML file:

SCHEMA-PATH/schema/ogsadai/xsd/sessions_config.xsd

Where SCHEMA-PATH is replaced with the return value of this method.

Parameters:
webInfPath - The path to the web service's WEB-INF directory. Usually obtained from getWebInfDirectory()

loadPropertiesFile

protected Properties loadPropertiesFile(String fileName)
                                 throws PropertyConfigurationException
Convenience method to load and return a properties file given by a filename.

Parameters:
fileName - The name of the properties file relative to the GRIA configuration directory.
Returns:
The properties file
Throws:
PropertyConfigurationException

getGriaConfigDirectory

protected String getGriaConfigDirectory()
                                 throws PropertyConfigurationException
Find the path to the GRIA configuration directory.

Throws:
PropertyConfigurationException

getServiceConfiguration

protected ServiceConfiguration getServiceConfiguration()
                                                throws PropertyConfigurationException
Return a ServiceConfiguration object - if possible from a cache.

Throws:
PropertyConfigurationException

isConfigurationLoaded

public boolean isConfigurationLoaded()
Description copied from interface: DataResourceManager
Determine whether configuration files have been loaded and the service is ready to respond to requests.

Specified by:
isConfigurationLoaded in interface DataResourceManager

setConfigurationLoaded

public void setConfigurationLoaded(boolean isConfigurationLoaded)
Set the isConfigurationLoaded field. Subclasses should call this in their reloadConfiguration method.


getOgsaDaiInstance

public OgsaDaiInstance getOgsaDaiInstance()


Copyright © 2001-2008 University of Southampton IT Innovation Centre. All Rights Reserved.