com.indexdata.masterkey.config
Class MasterkeyConfiguration

java.lang.Object
  extended by com.indexdata.masterkey.config.MasterkeyConfiguration

public class MasterkeyConfiguration
extends Object

Represents the configuration context for modules within this J2EE component. An instance of this class basically has a one-to-one relationship with the properties file for the component/vhost From this context it is possible to obtain configurations for sub-modules within the component. The configuration of a sub-module would be those properties in the components properties file that are prefixed with a given module name. It is possible to force the file name (but not the path to it) to be something data-dependent. 'Component': Basically a .war file 'Module': Sub-functions within the component, i.e. a Servlet, a REST service, a plug-in, etc. Throws ServletException If the configuration file (property file) is not found

Author:
Niels Erik

Field Summary
static String MASTERKEY_CONFIG_LIFE_TIME_PARAM
           
 
Method Summary
 boolean areConfigParamsCached()
           
 com.indexdata.masterkey.config.ConfigFileLocation getConfigFileLocation()
           
 String getConfigParameter(String prefix, String name)
          Retrieves a given config parameter by name and module/prefix.
 Enumeration<String> getConfigParameterNames(String prefix)
          Retrieves all config parameter names for the module
 Map<String,String> getConfigParamsAsMap(String prefix)
          Retrieves all config parameters for a module/prefix as a HashMap.
 Properties getConfigParamsAsProperties(String prefix)
          Returns the config parameters as Properties for a module/prefix
 String getContextKey()
          Provides a unique key for this configuration context (unique per j2ee component and vhost)
 String getHostName()
          Host name intended for use in logging.
static MasterkeyConfiguration getInstance(javax.servlet.ServletContext servletContext, String appId, String hostName)
          Creates a singleton MasterkeyConfiguration for each combination of component name and host name.
static MasterkeyConfiguration getInstance(javax.servlet.ServletContext servletContext, String appId, String hostName, String configFileName)
          Creates a singleton MasterkeyConfiguration for each combination of component name, host name, and property file name.
 ModuleConfiguration getModuleConfiguration(String moduleName)
          Creates a ModuleConfiguration holding the subset of properties that applies to the given module
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MASTERKEY_CONFIG_LIFE_TIME_PARAM

public static final String MASTERKEY_CONFIG_LIFE_TIME_PARAM
See Also:
Constant Field Values
Method Detail

getInstance

public static MasterkeyConfiguration getInstance(javax.servlet.ServletContext servletContext,
                                                 String appId,
                                                 String hostName)
                                          throws IOException
Creates a singleton MasterkeyConfiguration for each combination of component name and host name.

Parameters:
servletContext - Needed to pick up init parameters regarding the location of config files
hostName - Used for resolving the path to config files.
Throws:
IOException

getInstance

public static MasterkeyConfiguration getInstance(javax.servlet.ServletContext servletContext,
                                                 String appId,
                                                 String hostName,
                                                 String configFileName)
                                          throws IOException
Creates a singleton MasterkeyConfiguration for each combination of component name, host name, and property file name.
Provides support for a special case scenario where some feature is deployed separately from the .war file of the component. It allows for a deploy script (ie Debian) to add a new property file for the new feature rather than updating a sub-section within the already existing configuration file for the .war file.
Was specifically implemented for the Torus, which can have additional data stores deployed after the .war file.

Parameters:
servletContext - Needed to pick up init parameters regarding the location of config files
hostName - Used for resolving the path to config files.
configFileName - Defined by components code.
Throws:
IOException

getContextKey

public String getContextKey()
Provides a unique key for this configuration context (unique per j2ee component and vhost)

Returns:
Unique key for the context within which given sub-modules are executed.

getModuleConfiguration

public ModuleConfiguration getModuleConfiguration(String moduleName)
                                           throws IOException
Creates a ModuleConfiguration holding the subset of properties that applies to the given module

Parameters:
moduleName - Must match the prefix of the properties to pick up
Returns:
Throws:
IOException

areConfigParamsCached

public boolean areConfigParamsCached()

getConfigParameterNames

public Enumeration<String> getConfigParameterNames(String prefix)
                                            throws IOException
Retrieves all config parameter names for the module

Returns:
Throws:
javax.servlet.ServletException
IOException

getConfigParameter

public String getConfigParameter(String prefix,
                                 String name)
                          throws IOException
Retrieves a given config parameter by name and module/prefix.

Parameters:
name -
Returns:
Throws:
javax.servlet.ServletException
IOException

getConfigParamsAsMap

public Map<String,String> getConfigParamsAsMap(String prefix)
                                        throws IOException
Retrieves all config parameters for a module/prefix as a HashMap.

Returns:
Throws:
javax.servlet.ServletException
IOException

getConfigFileLocation

public com.indexdata.masterkey.config.ConfigFileLocation getConfigFileLocation()

getHostName

public String getHostName()
Host name intended for use in logging.

Returns:
Name of the (virtual) host the request is made to

getConfigParamsAsProperties

public Properties getConfigParamsAsProperties(String prefix)
                                       throws IOException
Returns the config parameters as Properties for a module/prefix

Returns:
Throws:
IOException


Copyright © 2012. All Rights Reserved.