List of usage examples for org.apache.commons.configuration ConfigurationFactory setConfigurationFileName
public void setConfigurationFileName(String configurationFileName)
From source file:gda.configuration.properties.JakartaPropertiesConfig.java
/** * Load in a single property data source, or a "config.xml" descriptor file (specifying multiple data sources). * Properties are added to the global composite property data set. * <p>/* w ww . ja v a 2 s . co m*/ * <p> * N.B. Due to underlying Jakarta (commons configuration) implementation, any previously loaded properties (with * duplicate keys) will override subsequently loaded properties. ie clients should load in override (eg user) data * before loading default (eg core) data. * <p> * <p> * N.B. Also system properties are currently loaded before any calls to loadPropertyData, so they take precedence * over everything. * * @param listName * the path name of the property data source. If the name ends in "config.xml" then the file is treated * as a Jakarta commons configuration descriptor file. If the file ends in ".xml" it is loaded as a * Jakarta XML property configuration file. Otherwise it is loaded as a legacy flat-file key-value pair * plain text property file. N.B. Although Jakarta supports other data sources, eg JDBC, these are not * yet supported via this method. * @throws ConfigurationException * @see gda.configuration.properties.PropertiesConfig#loadPropertyData(java.lang.String) */ @Override public void loadPropertyData(String listName) throws ConfigurationException { Configuration userConfig = null; if (listName.contains(".xml")) { if (listName.endsWith("config.xml")) { // create a JCC configuration factory from a JCC config // descriptor // file and make a JCC configuration interface/object from it ConfigurationFactory factory = new ConfigurationFactory(); // README - fix to get relative paths in config.xml working. // See comment for this method for explanation. configFactoryBasePathBugWorkaround(factory, listName); // now try to load in config.xml - relative paths should now // work factory.setConfigurationFileName(listName); userConfig = factory.getConfiguration(); } else { // load a JCC XML-format property file userConfig = new XMLConfiguration(listName); } } else { if (listName.contains(".properties")) { // load a classic java properties flat-textfile, // containing just name-value pairs - with extended JCC syntax userConfig = new PropertiesConfiguration(listName); } } if (userConfig != null) { config.addConfiguration(userConfig); configMap.put(listName, userConfig); } }
From source file:org.apache.qpid.server.configuration.XmlConfigurationUtilities.java
public static Configuration parseConfig(File file) throws ConfigurationException { ConfigurationFactory factory = new ConfigurationFactory(); factory.setConfigurationFileName(file.getAbsolutePath()); Configuration conf = factory.getConfiguration(); Iterator<?> keys = conf.getKeys(); if (!keys.hasNext()) { keys = null;/*w w w . j a v a2s. c o m*/ conf = flatConfig(file); } return conf; }
From source file:org.wso2.andes.configuration.qpid.ServerConfiguration.java
private static org.apache.commons.configuration.Configuration parseConfig(File file) throws ConfigurationException { ConfigurationFactory factory = new ConfigurationFactory(); factory.setConfigurationFileName(file.getAbsolutePath()); org.apache.commons.configuration.Configuration conf = factory.getConfiguration(); Iterator<?> keys = conf.getKeys(); if (!keys.hasNext()) { conf = flatConfig(file);//from w w w .j a va 2s .c o m } substituteEnvironmentVariables(conf); return conf; }
From source file:org.wso2.andes.server.configuration.ServerConfiguration.java
private static Configuration parseConfig(File file) throws ConfigurationException { ConfigurationFactory factory = new ConfigurationFactory(); factory.setConfigurationFileName(file.getAbsolutePath()); Configuration conf = factory.getConfiguration(); Iterator<?> keys = conf.getKeys(); if (!keys.hasNext()) { keys = null;//from w ww . j a v a 2 s .c o m conf = flatConfig(file); } substituteEnvironmentVariables(conf); return conf; }