gov.bnl.gums.configuration
Class FileConfigurationStore

java.lang.Object
  extended by gov.bnl.gums.configuration.FileConfigurationStore
All Implemented Interfaces:
ConfigurationStore

public class FileConfigurationStore
extends java.lang.Object
implements ConfigurationStore

Implements the logic to retrieve the configuration from the gums.config file taken from the classpath. The file will be reloaded as soon as if it changes, on demand (no polling).

Author:
Gabriele Carcassi, Jay Packard

Constructor Summary
FileConfigurationStore()
          Creates a new FileConfigurationStore object.
FileConfigurationStore(java.lang.String configDir, java.lang.String resourceDir, java.lang.String version, boolean create)
          Creates a new FileConfigurationStore object.
 
Method Summary
static void copyFile(java.lang.String source, java.lang.String target)
          Copy source to target
 void deleteBackupConfiguration(java.lang.String dateStr)
           
 java.util.Collection getBackupConfigDates()
          Get a list of config files that have been backed up
 boolean isActive()
          Defines whether a configuration can be retrieved from the store.
 boolean isReadOnly()
          Defines whether the configuration can be changed or not.
static void moveFile(java.lang.String source, java.lang.String target)
          Move source to target
 Configuration restoreConfiguration(java.lang.String dateStr)
          Restores configuration in memory.
 Configuration retrieveConfiguration()
          Loads the configuration in memory.
 void setConfiguration(Configuration conf, boolean backupCopy)
          Set and store the configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileConfigurationStore

public FileConfigurationStore()
Creates a new FileConfigurationStore object. Used to instantiate class when run as a unit test.


FileConfigurationStore

public FileConfigurationStore(java.lang.String configDir,
                              java.lang.String resourceDir,
                              java.lang.String version,
                              boolean create)
Creates a new FileConfigurationStore object. Allows for specifying the absolute name of the configuration file. Used to instantiate class when GUMS is run within servlet.

Parameters:
filename -
create - if true, a new barbones configuration file will be created at given filename if no file currently exists there
Method Detail

copyFile

public static void copyFile(java.lang.String source,
                            java.lang.String target)
Copy source to target

Parameters:
source -
target -

moveFile

public static void moveFile(java.lang.String source,
                            java.lang.String target)
Move source to target

Parameters:
source -
target -

deleteBackupConfiguration

public void deleteBackupConfiguration(java.lang.String dateStr)
Specified by:
deleteBackupConfiguration in interface ConfigurationStore

getBackupConfigDates

public java.util.Collection getBackupConfigDates()
Description copied from interface: ConfigurationStore
Get a list of config files that have been backed up

Specified by:
getBackupConfigDates in interface ConfigurationStore
Returns:
collection of date strings.

isActive

public boolean isActive()
Description copied from interface: ConfigurationStore
Defines whether a configuration can be retrieved from the store. This should only check whether configuration information is accessible, not if it is inconsistent. For example, it should check whether the configuration file is present, not if contains valid information.

Specified by:
isActive in interface ConfigurationStore
Returns:
true if the store is configured correctly.

isReadOnly

public boolean isReadOnly()
Description copied from interface: ConfigurationStore
Defines whether the configuration can be changed or not.

Specified by:
isReadOnly in interface ConfigurationStore
Returns:
true if storeConfiguration is allowed.

retrieveConfiguration

public Configuration retrieveConfiguration()
Description copied from interface: ConfigurationStore
Loads the configuration in memory. If the configuration cannot be loaded due to an inconsistency in the store, it should throw an exception.

Specified by:
retrieveConfiguration in interface ConfigurationStore
Returns:
A configuration object.

restoreConfiguration

public Configuration restoreConfiguration(java.lang.String dateStr)
Description copied from interface: ConfigurationStore
Restores configuration in memory. If the configuration cannot be loaded due to an inconsistency in the store, it should throw an exception.

Specified by:
restoreConfiguration in interface ConfigurationStore
Returns:
A configuration object.

setConfiguration

public void setConfiguration(Configuration conf,
                             boolean backupCopy)
                      throws java.lang.Exception
Description copied from interface: ConfigurationStore
Set and store the configuration.

Specified by:
setConfiguration in interface ConfigurationStore
Throws:
java.lang.Exception


Copyright © 2004-2008. All Rights Reserved.