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

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

Introduction

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

Prototype

public PropertiesConfiguration(URL url) throws ConfigurationException 

Source Link

Document

Creates and loads the extended properties from the specified URL.

Usage

From source file:com.baifendian.swordfish.execserver.job.impexp.Args.ImpExpProps.java

public ImpExpProps(ImpExpParam impExpParam, Logger logger) {
    this.impExpParam = impExpParam;
    this.datasourceDao = DaoFactory.getDaoInstance(DatasourceDao.class);

    try {// w ww .j  av  a  2 s.  c  o  m
        hadoopConf = new PropertiesConfiguration("common/hadoop/hadoop.properties");
        workConf = new PropertiesConfiguration("worker.properties");
        hiveConf = new PropertiesConfiguration("common/hive/hive.properties");
    } catch (ConfigurationException e) {
        logger.error("Init impExpProps error", e);
        throw new IllegalArgumentException("Init impExpProps error!");
    }
}

From source file:es.bsc.servicess.ide.editors.deployers.OptimisProperties.java

public OptimisProperties(File file) throws ConfigurationException {
    config = new PropertiesConfiguration(file);
}

From source file:com.cloudera.nav.plugin.client.PluginConfigurationFactory.java

/**
 * Create a PluginConfiguration from the properties contained in the
 * given filePath/* w w  w  .  j  a v a 2  s  . c o m*/
 *
 * @param filePath
 * @return
 */
public PluginConfigurations readConfigurations(String filePath) {
    try {
        PropertiesConfiguration props = new PropertiesConfiguration(filePath);
        PluginConfigurations config = new PluginConfigurations();
        config.setApplicationUrl(props.getString(APP_URL));
        config.setFileFormat(FileFormat.valueOf(props.getString(FILE_FORMAT, FileFormat.JSON.name())));
        config.setMetadataParentUri(URI.create(props.getString(METADATA_URI)));
        config.setNamespace(props.getString(NAMESPACE));
        config.setNavigatorUrl(props.getString(NAV_URL));
        config.setUsername(props.getString(USERNAME));
        config.setPassword(props.getString(PASSWORD));
        return config;
    } catch (ConfigurationException e) {
        throw Throwables.propagate(e);
    }
}

From source file:com.bennavetta.appsite.util.Config.java

@PostConstruct
public void setup() throws ConfigurationException {
    ConcurrentMapConfiguration systemConfig = new ConcurrentMapConfiguration(new SystemConfiguration());
    ConcurrentMapConfiguration defaultConfig = new ConcurrentMapConfiguration(
            new PropertiesConfiguration("default-config.properties"));
    // datastore config would be concurrent because the datastore itself is 

    ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration();
    finalConfig.addConfiguration(datastoreConfig, "DatastoreConfig");
    finalConfig.addConfiguration(defaultConfig, "DefaultConfig");
    finalConfig.addConfiguration(systemConfig, "SystemConfig");

    ConfigurationManager.install(finalConfig);
}

From source file:com.googlecode.xtecuannet.framework.catalina.manager.tomcat.constants.Constants.java

public static PropertiesConfiguration getConfig(String basePath, Class clazze) {
    PropertiesConfiguration pc = null;//from w  ww  . ja  va 2 s .  co  m

    String className = clazze.getSimpleName();

    File basePathObj = new File(basePath);
    File fileCfg = new File(basePathObj, className + PROPERTIES);

    try {

        if (!basePathObj.exists()) {
            if (basePathObj.mkdirs()) {
                logger.info(basePath + " created!!!");
            }
        } else {

            logger.info(basePath + " already exists skipping!!!");

            if (!fileCfg.exists()) {

                FileUtils.touch(fileCfg);
                logger.info(fileCfg.getName() + " created!!!");
            } else {

                logger.info(fileCfg.getName() + " already exists skipping!!!");
            }
        }

        pc = new PropertiesConfiguration(fileCfg);
        pc.setReloadingStrategy(new FileChangedReloadingStrategy());
        //            pc.setAutoSave(true);
        pc.setDelimiterParsingDisabled(false);

        logger.info(fileCfg.getName() + " loaded!!!");

    } catch (IOException e) {
        logger.error("Error creating config file or directory for class: " + className, e);
    } catch (ConfigurationException ex) {
        logger.error("Error getting/initializacion config for class: " + className, ex);
    }

    return pc;
}

From source file:funnycats.TestUtils.java

@Test
public void testGettingFunnyCatsFromDirectoryReturnsAListOfCats() throws ConfigurationException {
    Configuration configuration = new PropertiesConfiguration("funnycats.properties");
    String path = configuration.getString("cats.pictures");
    URL url = getClass().getClassLoader().getResource(path);
    File directory = new File(url.getFile());
    List<FunnyCat> funnyCats = Utils.getFunnyCats(directory);
    Assert.assertTrue(funnyCats.size() > 0);
}

From source file:com.codspire.mojo.artifactlookup.ProcessResponseTest.java

@Before
public void initMock() throws Exception {
    when(log.isDebugEnabled()).thenReturn(Boolean.TRUE);

    plugInConfig = new PropertiesConfiguration("artifact-lookup-maven-plugin.properties");
}

From source file:com.flipkart.polyguice.config.ApacheCommonsConfigProvider.java

public ApacheCommonsConfigProvider location(String loc) {
    try {//from   w  w w.jav a  2 s  .com
        if (loc.toLowerCase(Locale.getDefault()).endsWith(".properties")) {
            PropertiesConfiguration config = new PropertiesConfiguration(new File(loc));
            rootConfig.addConfiguration(config);
            LOGGER.debug("properties configuration from {}", loc);
        } else if (loc.toLowerCase(Locale.getDefault()).endsWith(".xml")) {
            XMLConfiguration config = new XMLConfiguration(new File(loc));
            rootConfig.addConfiguration(config);
            LOGGER.debug("xml configuration from {}", loc);
        } else if (loc.toLowerCase(Locale.getDefault()).endsWith(".json")) {
            JsonConfiguration config = new JsonConfiguration(new File(loc));
            rootConfig.addConfiguration(config);
            LOGGER.debug("json configuration from {}", loc);
        } else if (loc.toLowerCase(Locale.getDefault()).endsWith(".yml")) {
            YamlConfiguration config = new YamlConfiguration(loc);
            rootConfig.addConfiguration(config);
            LOGGER.debug("yaml configuration from {}", loc);
        } else if (loc.toLowerCase(Locale.getDefault()).endsWith(".yaml")) {
            YamlConfiguration config = new YamlConfiguration(loc);
            rootConfig.addConfiguration(config);
            LOGGER.debug("yaml configuration from {}", loc);
        }
    } catch (Exception exep) {
        LOGGER.error("unable to load configuration from " + loc.toString(), exep);
    }
    return this;
}

From source file:com.arcbees.plugin.template.util.FetchProperties.java

/**
 * TODO retry on failures//  www. j ava2 s. c om
 * TODO report error
 * @throws MalformedURLException 
 * @throws ConfigurationException 
 */
public PropertiesConfiguration fetch() throws MalformedURLException, ConfigurationException {
    URL url;
    try {
        url = new URL(path);
    } catch (MalformedURLException e) {
        // TODO
        e.printStackTrace();
        throw e;
    }

    try {
        configuration = new PropertiesConfiguration(url);
    } catch (ConfigurationException e) {
        e.printStackTrace();
        throw e;
    }

    System.out.println(configuration.toString());

    return configuration;
}

From source file:integratedtoolkit.util.RuntimeConfigManager.java

public RuntimeConfigManager(File file) throws ConfigurationException {
    config = new PropertiesConfiguration(file);
}