com.netflix.config
Class ConfigurationManager

java.lang.Object
  extended by com.netflix.config.ConfigurationManager

public class ConfigurationManager
extends java.lang.Object

The configuration manager is a central place where it manages the system wide Configuration and deployment context.

During initialization, this class will check system property "archaius.default.configuration.class" and "archaius.default.configuration.factory". If the former is set, it will use the class name to instantiate it using its default no-arg constructor. If the later is set, it will call its static method getInstance(). In both cases, the returned Configuration object will be set as the system wide configuration.


Field Summary
static java.lang.String PROP_NEXT_LOAD
           
 
Constructor Summary
ConfigurationManager()
           
 
Method Summary
static org.apache.commons.configuration.AbstractConfiguration getConfigFromPropertiesFile(java.net.URL startingUrl)
           
static org.apache.commons.configuration.AbstractConfiguration getConfigInstance()
          Get the current system wide configuration.
static DeploymentContext getDeploymentContext()
           
static java.util.Set<java.lang.String> getLoadedPropertiesURLs()
           
static java.util.Properties getPropertiesFromFile(java.net.URL startingUrl)
           
static void install(org.apache.commons.configuration.AbstractConfiguration config)
          Install the system wide configuration with the ConfigurationManager.
static boolean isConfigurationInstalled()
           
static void loadCascadedPropertiesFromResources(java.lang.String configName)
          Load resource configName.properties first.
static void loadProperties(java.util.Properties properties)
          Load the specified properties into system wide configuration
static void loadPropertiesFromConfiguration(org.apache.commons.configuration.AbstractConfiguration config)
          Load properties from the specified configuration into system wide configuration
static void loadPropertiesFromResources(java.lang.String path)
          Load properties from resource file into the system wide configuration
static void setDeploymentContext(DeploymentContext context)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_NEXT_LOAD

public static final java.lang.String PROP_NEXT_LOAD
See Also:
Constant Field Values
Constructor Detail

ConfigurationManager

public ConfigurationManager()
Method Detail

getLoadedPropertiesURLs

public static java.util.Set<java.lang.String> getLoadedPropertiesURLs()

install

public static void install(org.apache.commons.configuration.AbstractConfiguration config)
                    throws java.lang.IllegalStateException
Install the system wide configuration with the ConfigurationManager. This will also install the configuration with the DynamicPropertyFactory by calling DynamicPropertyFactory.initWithConfigurationSource(AbstractConfiguration). This call can be made only once, otherwise IllegalStateException will be thrown.

Throws:
java.lang.IllegalStateException

isConfigurationInstalled

public static boolean isConfigurationInstalled()

getConfigInstance

public static org.apache.commons.configuration.AbstractConfiguration getConfigInstance()
Get the current system wide configuration. If there has not been set, it will return a default ConcurrentCompositeConfiguration which contains a SystemConfiguration from Apache Commons Configuration and a DynamicURLConfiguration.


loadPropertiesFromResources

public static void loadPropertiesFromResources(java.lang.String path)
                                        throws java.io.IOException
Load properties from resource file into the system wide configuration

Parameters:
path - path of the resource
Throws:
java.io.IOException

loadCascadedPropertiesFromResources

public static void loadCascadedPropertiesFromResources(java.lang.String configName)
                                                throws java.io.IOException
Load resource configName.properties first. Then load configName-deploymentEnvironment.properties into the system wide configuration. For example, if configName is "application", and deployment environment is "test", this API will first load "application.properties", then load "application-test.properties" to override any property that also exist in "application.properties".

Parameters:
configName - prefix of the properties file name.
Throws:
java.io.IOException
See Also:
DeploymentContext.getDeploymentEnvironment()

loadPropertiesFromConfiguration

public static void loadPropertiesFromConfiguration(org.apache.commons.configuration.AbstractConfiguration config)
Load properties from the specified configuration into system wide configuration


loadProperties

public static void loadProperties(java.util.Properties properties)
Load the specified properties into system wide configuration


setDeploymentContext

public static void setDeploymentContext(DeploymentContext context)

getDeploymentContext

public static DeploymentContext getDeploymentContext()

getConfigFromPropertiesFile

public static org.apache.commons.configuration.AbstractConfiguration getConfigFromPropertiesFile(java.net.URL startingUrl)
                                                                                          throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

getPropertiesFromFile

public static java.util.Properties getPropertiesFromFile(java.net.URL startingUrl)
                                                  throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException