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

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

Introduction

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

Prototype

public INIConfiguration(URL url) throws ConfigurationException 

Source Link

Document

Create and load the ini configuration from the given url.

Usage

From source file:com.intel.cosbench.config.common.INIConfigParser.java

public static Config parse(File file) {
    INIConfiguration config = null;//from w ww. ja  v  a 2  s .  com
    try {
        config = new INIConfiguration(file);
    } catch (Exception e) {
        String msg = "cannot loader config from " + file.getAbsolutePath();
        logger.error(msg, e);
        throw new ConfigException(msg, e);
    }
    return new COSBConfigApator(config);
}

From source file:org.glite.authz.pap.common.PAPConfiguration.java

/**
 * Loads the PAP startup configuration.//from www.  ja  v a  2 s.c o m
 */
private void loadStartupConfiguration() {

    //        logger.info( "Loading pap startup configuration..." );
    String papConfDir = configuration.getString("papConfigurationDir");

    File papConfFile = new File(papConfDir + "/" + DEFAULT_PAP_CONFIGURATION_FILE_NAME);

    if (!papConfFile.exists())
        throw new PAPConfigurationException(
                "PAP startup configuration file does not exists on path:" + papConfFile.getAbsolutePath());

    try {

        startupConfiguration = new INIConfiguration(papConfFile);
        configuration.addConfiguration(startupConfiguration);

    } catch (org.apache.commons.configuration.ConfigurationException e) {

        logger.error("Error parsing PAP distribution configuration: " + e.getMessage(), e);
        throw new PAPConfigurationException("Error parsing PAP distribution configuration: " + e.getMessage(),
                e);

    }

}

From source file:org.skb.util.types.composite.util.TSPropertyMap.java

public String loadFromFile(String fn) {
    try {//from w w w.j av  a  2 s . c o m
        AbstractConfiguration cfg;
        String prefix = "";
        if (fn.endsWith(".ini")) {
            cfg = new INIConfiguration(fn);
            prefix = "tribe.";
        } else if (fn.endsWith(".xml"))
            cfg = new XMLConfiguration(fn);
        else if (fn.endsWith(".properties"))
            cfg = new PropertiesConfiguration(fn);
        else
            return "unknown configuration file format, use '.ini' or '.xml' or '.properties'";

        File file = new File(fn);
        if (!file.canRead())
            return "can't read configuration file <" + fn + ">";

        Iterator<?> it;
        if (prefix != "")
            it = cfg.getKeys(prefix);
        else
            it = cfg.getKeys();
        while (it.hasNext()) {
            String p = it.next().toString();
            if (this.containsKey(p)) {
                String type = this.get(p, TSPropertyMap.pmValType).toString();
                if (type.equals(TSRepository.TString.TS_ATOMIC_JAVA_STRING))
                    this.put(p, TSPropertyMap.pmValValueFile, cfg.getString(p));
                else if (type.equals(TSRepository.TString.TS_ATOMIC_JAVA_BOOLEAN))
                    this.put(p, TSPropertyMap.pmValValueFile, cfg.getBoolean(p, false));
                else if (type.equals(TSRepository.TString.TS_ATOMIC_JAVA_INTEGER))
                    this.put(p, TSPropertyMap.pmValValueFile, cfg.getInteger(p, 0));
                else if (type.equals(TSRepository.TString.TS_ATOMIC_JAVA_DOUBLE))
                    this.put(p, TSPropertyMap.pmValValueFile, cfg.getDouble(p));
                else if (type.equals(TSRepository.TString.TS_ATOMIC_JAVA_LONG))
                    this.put(p, TSPropertyMap.pmValValueFile, cfg.getLong(p, 0));
                //                 else
                //                    System.err.println("TSPropMap, loadfromfile, unknown type <"+type+"> for <"+p+">");
            }

        }
    } catch (Exception e) {
        //           ReportManager repMgr=ReportManager.getInstance();
        //           repMgr.reportErrorNoFile(e.toString());
    }
    return null;
}