edu.jhu.tmaj.util.config.data
Class ConstantsHolder

java.lang.Object
  extended by edu.jhu.tmaj.util.config.data.ConstantsHolder

public final class ConstantsHolder
extends java.lang.Object

A Helper class for reading config files. Every jar file created contains a config file in the /config directory. It is possible that a config file outside of the jar may override the values of the original config file. This file is referred to as the override file. The methods override(filename) where filename is the name of the override file. Any values in the original config file will be overwritten.


Constructor Summary
ConstantsHolder(java.util.Properties properties, java.lang.String propertiesFileName, java.util.List<? extends ConfigKey> configKeyList)
          Constructs this object.
 
Method Summary
 boolean getBoolean(ConfigKey configKey)
          Gets the boolean value for a config key that has a boolean type.
static ConstantsHolder getInstanceFromExternalProperties(java.io.File propertiesFile, java.util.List<? extends ConfigKey> configKeyList)
           
static ConstantsHolder getInstanceFromInternalProperties(java.lang.String propertiesFileName, java.util.List<? extends ConfigKey> configKeyList)
           
 java.lang.Integer getInt(ConfigKey configKey)
          Gets the int value for a config key that is an int type.
 java.lang.String getString(ConfigKey configKey)
          Gets the string value for a config key that is an string type.
 java.net.URL getURL(ConfigKey configKey)
           
 void override(java.io.File overrideFile)
          Override the config file with another config file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConstantsHolder

public ConstantsHolder(java.util.Properties properties,
                       java.lang.String propertiesFileName,
                       java.util.List<? extends ConfigKey> configKeyList)
Constructs this object.

Parameters:
propertiesFileName - the internal properies file. Example: config/client.properties
configKeyList - all the possible configKeys that may be found in the properties file
Method Detail

getInstanceFromInternalProperties

public static ConstantsHolder getInstanceFromInternalProperties(java.lang.String propertiesFileName,
                                                                java.util.List<? extends ConfigKey> configKeyList)

getInstanceFromExternalProperties

public static ConstantsHolder getInstanceFromExternalProperties(java.io.File propertiesFile,
                                                                java.util.List<? extends ConfigKey> configKeyList)

getInt

public java.lang.Integer getInt(ConfigKey configKey)
Gets the int value for a config key that is an int type.


getString

public java.lang.String getString(ConfigKey configKey)
Gets the string value for a config key that is an string type.


getURL

public java.net.URL getURL(ConfigKey configKey)

getBoolean

public boolean getBoolean(ConfigKey configKey)
Gets the boolean value for a config key that has a boolean type. If the key is not in the config file, false is returned.


override

public void override(java.io.File overrideFile)
Override the config file with another config file. If the config file specified is not found, this function has no effect except to print a message indicating that no file was found. This method looks for the file on the client's local machine. This is useful if you are attempting to access a version of TMAJ running on a private IP address. Lets say the default value for WEB_SERVER_URL in the jar file is "http://10.0.0.1/images". Since 10.0.0.1 is a private IP address, you will not be able to access it from outside. So you have port forwarding setup, forwarding port 50080 on your local machine to 10.0.0.1:80. Then, you have an override file where you specify the WEB_SERVER_URL to "http://localhost:50080/images".