gov.bnl.gums.configuration
Class FileConfigurationStore

java.lang.Object
  extended by gov.bnl.gums.configuration.ConfigurationStore
      extended by gov.bnl.gums.configuration.FileConfigurationStore

public class FileConfigurationStore
extends 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

Field Summary
 
Fields inherited from class gov.bnl.gums.configuration.ConfigurationStore
format
 
Constructor Summary
FileConfigurationStore()
          Creates a new FileConfigurationStore object.
FileConfigurationStore(String configDir)
          Creates a new FileConfigurationStore object.
 
Method Summary
static void copyFile(String source, String target)
          Copy source to target
 void deleteBackupConfiguration(String name)
          Delete backup configuration
 Collection getBackupNames()
          Get a list of config date strings that have been backed up
 Date getLastModification()
          Get last modified
 boolean isActive()
          Defines whether a configuration can be retrieved from the store.
static void moveFile(String source, String target)
          Move source to target
 Configuration restoreConfiguration(String name)
          Restores configuration in memory.
 Configuration retrieveConfiguration()
          Loads the configuration in memory if or from storage based on reload.
 void setConfiguration(Configuration conf, boolean backupCopy, String name, Date date)
          Set and store the configuration.
 
Methods inherited from class gov.bnl.gums.configuration.ConfigurationStore
getFormat
 
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(String configDir)
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(String source,
                            String target)
Copy source to target

Parameters:
source -
target -

moveFile

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

Parameters:
source -
target -

deleteBackupConfiguration

public void deleteBackupConfiguration(String name)
Description copied from class: ConfigurationStore
Delete backup configuration

Specified by:
deleteBackupConfiguration in class ConfigurationStore

getBackupNames

public Collection getBackupNames()
Description copied from class: ConfigurationStore
Get a list of config date strings that have been backed up

Specified by:
getBackupNames in class ConfigurationStore
Returns:
collection of date strings.

getLastModification

public Date getLastModification()
Description copied from class: ConfigurationStore
Get last modified

Specified by:
getLastModification in class ConfigurationStore
Returns:
Date

isActive

public boolean isActive()
Description copied from class: 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 class ConfigurationStore
Returns:
true if the store is configured correctly.

restoreConfiguration

public Configuration restoreConfiguration(String name)
Description copied from class: 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 class ConfigurationStore
Returns:
A configuration object.

retrieveConfiguration

public Configuration retrieveConfiguration()
Description copied from class: ConfigurationStore
Loads the configuration in memory if or from storage based on reload. This is useful if needsReload was called previously and you don't want to look it up again for performance's sake. If the configuration cannot be loaded due to an inconsistency in the store, it should throw an exception.

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

setConfiguration

public void setConfiguration(Configuration conf,
                             boolean backupCopy,
                             String name,
                             Date date)
                      throws Exception
Description copied from class: ConfigurationStore
Set and store the configuration. A configuration may specify to store the configuration using another configuration store, so this function also returns itself or a updated configuration store

Specified by:
setConfiguration in class ConfigurationStore
Throws:
Exception


Copyright © 2004-2009. All Rights Reserved.