Example usage for org.apache.commons.configuration XMLConfiguration XMLConfiguration

List of usage examples for org.apache.commons.configuration XMLConfiguration XMLConfiguration

Introduction

In this page you can find the example usage for org.apache.commons.configuration XMLConfiguration XMLConfiguration.

Prototype

public XMLConfiguration(URL url) throws ConfigurationException 

Source Link

Document

Creates a new instance of XMLConfiguration.

Usage

From source file:edu.harvard.hul.ois.fits.tools.utils.XsltTransformMap.java

public static Hashtable getMap(String config) throws FitsConfigurationException {
    Hashtable mappings = new Hashtable();
    XMLConfiguration conf = null;//from  ww  w  .  jav a2  s  . com
    try {
        conf = new XMLConfiguration(config);
    } catch (ConfigurationException e) {
        throw new FitsConfigurationException("Error reading " + config + "fits.xml", e);
    }

    List fields = conf.configurationsAt("map");
    for (Iterator it = fields.iterator(); it.hasNext();) {
        HierarchicalConfiguration sub = (HierarchicalConfiguration) it.next();
        // sub contains now all data about a single field
        String format = sub.getString("[@format]");
        String transform = sub.getString("[@transform]");
        mappings.put(format, transform);
    }
    return mappings;
}

From source file:com.weibo.datasys.common.conf.ConfigFactory.java

public static void init(String configFilePath) {
    // ??/*from   w ww  . jav  a2s . co  m*/
    if (configFilePath == null) {
        configFilePath = CONFIG_FILE_DEFAULT_PATH;
    }
    try {
        System.out.println(new Date() + " - [ConfigInit] - ConfigPath= " + configFilePath);
        config = new XMLConfiguration(configFilePath);
        config.setReloadingStrategy(new FileChangedReloadingStrategy());
        configDirPath = new File(configFilePath).getParentFile();
    } catch (ConfigurationException e) {
        System.out.println(new Date() + " - [FatalError] - Init ConfigFactory Error. System Exit.");
        System.exit(1);
    }
}

From source file:club.jmint.crossing.client.config.Config.java

public static XMLConfiguration loadXMLConfigFile(String file) {
    XMLConfiguration config = null;//  www  .  j a v  a2 s . co  m
    try {
        //String fileName = Constants.DIR_CONF+File.separator+file;
        config = new XMLConfiguration(file);
    } catch (ConfigurationException e) {
        CrossLog.printStackTrace(e);
    }

    return config;
}

From source file:com.github.ipaas.ideploy.plugin.util.XmlUtil.java

/**
 * ?// w ww . j  a  v a  2 s  .c o  m
 * 
 * @param XML?
 * @param elementNames
 *            ??  . 
 * @param dufaultValue
 *            ?
 * @return
 */
public static String getString(String fileName, String elementNames, String defaultValue) {
    XMLConfiguration config;
    try {
        config = new XMLConfiguration(fileName);
    } catch (ConfigurationException e) {
        ConsoleHandler.error("??[" + fileName + "]:" + e.getMessage());
        return null;
    }
    // ??????
    String str = config.getString(elementNames, defaultValue);
    return str;
}

From source file:com.dgwave.osrs.OsrsConfig.java

/**
 * Looks up active file, loads active file and validates it
 *///from   w ww  .j  av  a2  s. c o  m
private static void loadConfig() {
    try {
        XMLConfiguration actConfig = new XMLConfiguration(OSRSDIR + OSRSCONFIG + ACTIVECONFIG);

        String actFile = actConfig.getString("activeConfig");
        actConfig = null; // just a reminder

        config = new XMLConfiguration(OSRSDIR + OSRSCONFIG + actFile);

        validateConfiguration();

        logger.info("OSRS configuration loaded successfully");
    } catch (Exception ce) {
        logger.error("Initial Configuration could not be loaded - OSRS will not run");
        throw new OsrsException("Configuration Problem", ce);
    }
}

From source file:com.quick.config.ApacheCommonsConfigurationSpringConfig.java

@Bean
public XMLConfiguration xmlConfig() throws ConfigurationException {
    return new XMLConfiguration(CONFIG_LOCATION_CLASSPATH);
}

From source file:club.jmint.crossing.config.ConfigWizard.java

public static Configuration loadXMLConfigFile(String file) {
    Configuration config = null;/*from  w  w  w .  j ava2s.  c o  m*/
    try {
        config = new XMLConfiguration(file);
    } catch (ConfigurationException e) {
        CrossLog.printStackTrace(e);
    }

    return config;
}

From source file:Configuration.AlarmConfig.java

public AlarmConfig() {
    try {//  w ww . ja  v  a2s  .c o  m
        File hmbCF = ConfigHelper.getConfigFile("AlarmConfig.xml");
        config = new XMLConfiguration(hmbCF);
    } catch (Exception e) {
        System.out.println("Entra2");
        Logger.getLogger("HMB").error("Could not find config file hmb.xml. Using default hardcoded values!!.");
    }
}

From source file:de.ingrid.portal.config.FacetsConfig.java

public static XMLConfiguration getInstance() {

    if (instance == null) {
        try {/*from www .  j ava 2 s .  c  o m*/
            instance = new XMLConfiguration("facets-config.xml");
        } catch (ConfigurationException cex) {
            log.error("Error reading facets config file!");
        }
    }
    return instance;
}

From source file:com.github.ipaas.ideploy.plugin.util.XmlUtil.java

public static String getString(String fileName, String elementNames) {
    XMLConfiguration config;//from  www . j  a va  2  s  . c  o  m
    try {
        config = new XMLConfiguration(fileName);
    } catch (ConfigurationException e) {
        ConsoleHandler.error("??[" + fileName + "]:" + e.getMessage());
        return null;
    }
    // ??????
    String str = config.getString(elementNames);
    return str;
}