com.netflix.config.util
Class ConfigurationUtils

java.lang.Object
  extended by com.netflix.config.util.ConfigurationUtils

public class ConfigurationUtils
extends java.lang.Object

Utility class for configuration.


Constructor Summary
ConfigurationUtils()
           
 
Method Summary
static ConcurrentCompositeConfiguration convertToConcurrentCompositeConfiguration(org.apache.commons.configuration.CombinedConfiguration config)
          Convert CombinedConfiguration into ConcurrentCompositeConfiguration as the later has better performance and thread safety.
static void copyProperties(org.apache.commons.configuration.Configuration from, org.apache.commons.configuration.Configuration to)
           
static java.util.Map<java.lang.String,org.apache.commons.configuration.Configuration> getAllNamedConfiguration(org.apache.commons.configuration.Configuration conf)
          Gets all named sub-configuration from a configuration in a map.
static org.apache.commons.configuration.AbstractConfiguration getConfigFromPropertiesFile(java.net.URL startingUrl, java.util.Set<java.lang.String> loaded, java.lang.String... nextLoadKeys)
           
static java.util.Properties getProperties(org.apache.commons.configuration.Configuration config)
          Utility method to obtain Properties given an instance of AbstractConfiguration.
static java.util.Properties getPropertiesFromFile(java.net.URL startingUrl, java.util.Set<java.lang.String> loaded, java.lang.String... nextLoadKeys)
           
static void loadProperties(java.util.Properties props, org.apache.commons.configuration.Configuration config)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationUtils

public ConfigurationUtils()
Method Detail

convertToConcurrentCompositeConfiguration

public static ConcurrentCompositeConfiguration convertToConcurrentCompositeConfiguration(org.apache.commons.configuration.CombinedConfiguration config)
Convert CombinedConfiguration into ConcurrentCompositeConfiguration as the later has better performance and thread safety.

Parameters:
config - Configuration to be converted

getAllNamedConfiguration

public static java.util.Map<java.lang.String,org.apache.commons.configuration.Configuration> getAllNamedConfiguration(org.apache.commons.configuration.Configuration conf)
Gets all named sub-configuration from a configuration in a map. This method examines each sub-configuration which is an instance of ConcurrentCompositeConfiguration or CombinedConfiguration and extract the named configurations out of them.

Parameters:
conf - Configuration to get all the named sub-configurations
Returns:
map where key is the name of the sub-configuration and value is the sub-configuration

getProperties

public static java.util.Properties getProperties(org.apache.commons.configuration.Configuration config)
Utility method to obtain Properties given an instance of AbstractConfiguration. Returns an empty Properties object if the config has no properties or is null.

Parameters:
config - Configuration to get the properties
Returns:
properties extracted from the configuration

loadProperties

public static void loadProperties(java.util.Properties props,
                                  org.apache.commons.configuration.Configuration config)

getConfigFromPropertiesFile

public static org.apache.commons.configuration.AbstractConfiguration getConfigFromPropertiesFile(java.net.URL startingUrl,
                                                                                                 java.util.Set<java.lang.String> loaded,
                                                                                                 java.lang.String... nextLoadKeys)
                                                                                          throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException

copyProperties

public static void copyProperties(org.apache.commons.configuration.Configuration from,
                                  org.apache.commons.configuration.Configuration to)

getPropertiesFromFile

public static java.util.Properties getPropertiesFromFile(java.net.URL startingUrl,
                                                         java.util.Set<java.lang.String> loaded,
                                                         java.lang.String... nextLoadKeys)
                                                  throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException