uk.org.ogsadai.service.resource.factory
Class DataServiceResourceFactoryUtil

java.lang.Object
  |
  +--uk.org.ogsadai.service.resource.factory.DataServiceResourceFactoryUtil

public class DataServiceResourceFactoryUtil
extends java.lang.Object

Class containing utilities for dynamic creation of data service resources. It provides much of the functionality needed by classes implementing the uk.org.ogsadai.service.resource.factory.DataServiceResourceFactory interface.

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String CLASS_CONFIG_FILENAME
          Name of the class config file
private static java.lang.String CLASS_CONFIG_TEMPLATE_FILENAME
          Name of the template class config file
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
private static java.lang.String DATA_RESOURCE_ACCESSOR_CLASS_NAME_TOKEN
          Token within the template class config file that will be replaced with the class name.
private static DAILogger LOG
          Logger object for logging in this class
private  java.io.File mConfigDirectory
          Directory storing all OGSA-DAI configuration files
private  java.lang.Object mPersistResourceSynchronization
          Persist resource synchronization object
private  java.io.File mSchemaDirectory
          Directory storing OGSA-DAI XML Schema and WSDL
static java.lang.String OGSADAI_SCHEMA_ROOT_TOKEN
          Token used in configuration files to represent the root OGSADAI schema directory.
 
Constructor Summary
DataServiceResourceFactoryUtil(java.io.File configDirectory, java.io.File schemaDirectory)
          Constructor.
 
Method Summary
 java.io.File createResourceConfigDirectory(java.lang.String resourceName)
          Returns the configuration files directory for the named resource.
 java.lang.String getNewResourceName()
          Returns a new resource name that is guaranteed to be unique within this service.
 java.lang.String getNewResourceName(java.lang.String prefix)
          Returns a new resource name that is guaranteed to be unique within this service.
 void persistResource(java.lang.String resourceName, java.io.File resourcesFile)
          Perists a specified resource by writing an entry for it in the a data service resources file.
 void removePersistentResource(java.lang.String resourceName, java.io.File resourcesFile)
          Remove a resource from the data service resources file.
 boolean removeResourceConfigDirectory(java.lang.String resourceName)
          Remove configuration files directory of the given resource.
 void replaceTokensInAllConfigFiles(java.lang.String resourceName)
          Scans through all the files in the specified data service resources's configuration directory and replaces all occurrences of special tokens with corresponding values.
 void writeClassConfigFile(java.lang.String resourceName, java.lang.String className)
          Writes the data service resource accessor class configuration file for the named data service 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


CLASS_CONFIG_FILENAME

private static java.lang.String CLASS_CONFIG_FILENAME
Name of the class config file


CLASS_CONFIG_TEMPLATE_FILENAME

private static java.lang.String CLASS_CONFIG_TEMPLATE_FILENAME
Name of the template class config file


DATA_RESOURCE_ACCESSOR_CLASS_NAME_TOKEN

private static java.lang.String DATA_RESOURCE_ACCESSOR_CLASS_NAME_TOKEN
Token within the template class config file that will be replaced with the class name.


mConfigDirectory

private java.io.File mConfigDirectory
Directory storing all OGSA-DAI configuration files


mPersistResourceSynchronization

private java.lang.Object mPersistResourceSynchronization
Persist resource synchronization object


mSchemaDirectory

private java.io.File mSchemaDirectory
Directory storing OGSA-DAI XML Schema and WSDL


OGSADAI_SCHEMA_ROOT_TOKEN

public static java.lang.String OGSADAI_SCHEMA_ROOT_TOKEN
Token used in configuration files to represent the root OGSADAI schema directory. All occurences of this token will be replaced by the absolute schema path.

Constructor Detail

DataServiceResourceFactoryUtil

public DataServiceResourceFactoryUtil(java.io.File configDirectory,
                                      java.io.File schemaDirectory)
                               throws DAIConfigDirectoryException
Constructor.

Stores references to the given parameters.

Parameters:
configDirectory - Absolute path to OGSA-DAI configuration files directory.
schemaDirectory - Absolute path to OGSA-DAI XML Schema and WSDL directory.
Throws:
DAIConfigDirectoryException - if configDirectory does not exist or is not a directory.
Method Detail

getNewResourceName

public java.lang.String getNewResourceName()
Returns a new resource name that is guaranteed to be unique within this service.

The implementation of this method is synchronized.

Returns:
a new data service resource name.

getNewResourceName

public java.lang.String getNewResourceName(java.lang.String prefix)
Returns a new resource name that is guaranteed to be unique within this service. The resource name will being with the given prefix.

The implementation of this method is synchronized.

Parameters:
prefix - prefix of new resource name
Returns:
a new data service resource name.

createResourceConfigDirectory

public java.io.File createResourceConfigDirectory(java.lang.String resourceName)
                                           throws CreateResourceConfigDirectoryException
Returns the configuration files directory for the named resource. If the directory does not exist then it will be created.

Parameters:
resourceName - Name of the resource to create the directory for.
Returns:
the configuration files directory for the data service resource.
Throws:
CreateResourceConfigDirectoryException - if there is a problem in checking or creating the directory.

writeClassConfigFile

public void writeClassConfigFile(java.lang.String resourceName,
                                 java.lang.String className)
                          throws CreateResourceConfigFileException
Writes the data service resource accessor class configuration file for the named data service resource.

This method uses a templace file in dataResourceClassConfigTemplate.xml.

Parameters:
resourceName - Data service resource name.
className - Data service resource accessor class name.
Throws:
CreateResourceConfigFileException - if there is a problem in creating the file.

replaceTokensInAllConfigFiles

public void replaceTokensInAllConfigFiles(java.lang.String resourceName)
                                   throws CustomiseResourceConfigFileException
Scans through all the files in the specified data service resources's configuration directory and replaces all occurrences of special tokens with corresponding values.

The special tokens replaced are:

Parameters:
resourceName - Data service resource name.
Throws:
CustomiseResourceConfigFileException - if a problem arises during the customisation. is a problem in checking or creating the directory.

persistResource

public void persistResource(java.lang.String resourceName,
                            java.io.File resourcesFile)
                     throws PersistResourceNameFileException
Perists a specified resource by writing an entry for it in the a data service resources file. This is a file used by services to specify the services they expose on start-up.

The implementation of this method is synchronized.

Parameters:
resourceName - Data service resource name.
resourcesFile - Data service resources file into which to write resource name.
Throws:
PersistResourceNameFileException - if a problem occurs.

removePersistentResource

public void removePersistentResource(java.lang.String resourceName,
                                     java.io.File resourcesFile)
                              throws RemoveResourceNameFileException
Remove a resource from the data service resources file.

The implementation of this method is synchronized.

Parameters:
resourceName - data service resource name
resourcesFile - data service resources file
Throws:
RemoveResourceNameFileException - if a problem occurs

removeResourceConfigDirectory

public boolean removeResourceConfigDirectory(java.lang.String resourceName)
Remove configuration files directory of the given resource.

Parameters:
resourceName - name of the data service resource
Returns:
indicates whether the directory could be removed successfully