List of usage examples for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration
public PropertiesConfiguration(URL url) throws ConfigurationException
From source file:fr.jetoile.hadoopunit.component.SolrBootstrapTest.java
@BeforeClass public static void setup() throws Exception { try {/*from w ww . j a v a 2 s . c o m*/ configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE); } catch (ConfigurationException e) { throw new BootstrapException("bad config", e); } HadoopBootstrap.INSTANCE.startAll(); }
From source file:fr.jetoile.hadoopunit.component.CassandraBootstrapTest.java
@BeforeClass public static void setup() throws BootstrapException { HadoopBootstrap.INSTANCE.startAll(); try {// w ww . j av a 2 s .c o m configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE); } catch (ConfigurationException e) { throw new BootstrapException("bad config", e); } }
From source file:net.orpiske.dcd.collector.vocabulary.impl.DictionaryConfigurationWrapper.java
/** * Initializes the configuration object//from w w w. j a v a 2 s .c om * * @param configDir * The configuration directory containing the configuration file * @param fileName * The name of the configuration file * @throws java.io.FileNotFoundException * @throws org.apache.commons.configuration.ConfigurationException */ public static void initConfiguration(final String configDir, final String fileName) throws FileNotFoundException, ConfigurationException { if (configDir == null) { throw new FileNotFoundException("The configuration dir was not found"); } config = new PropertiesConfiguration(configDir + File.separator + fileName); }
From source file:net.orpiske.ssps.common.configuration.ConfigurationWrapper.java
/** * Initializes the configuration object//w w w . j av a 2s . c o m * * @param configDir * The configuration directory containing the configuration file * @param fileName * The name of the configuration file * @throws FileNotFoundException * @throws ConfigurationException */ public static void initConfiguration(final String configDir, final String fileName) throws FileNotFoundException, ConfigurationException { if (configDir == null) { throw new FileNotFoundException("The configuration dir was not found"); } config = new PropertiesConfiguration(configDir + File.separator + fileName); // Appends an user config file, if exits ($HOME/.sdm/sdm.properties) String userFilePath = Utils.getSdmDirectoryPath() + File.separator + fileName; File userFile = new File(userFilePath); if (userFile.exists()) { PropertiesConfiguration userConfiguration = new PropertiesConfiguration(userFile); config.append(userConfiguration); } }
From source file:it.geosolutions.geoservertester.Start.java
/** * Loads the configuration /*from www.java2 s .c om*/ * @return the configuration */ private static Configuration loadConfig() { Configuration conf = null; try { conf = new PropertiesConfiguration( GeoServerTester.class.getClassLoader().getResource("configuration.properties")); } catch (ConfigurationException e) { LOG.log(Level.SEVERE, "failed to load configurations"); throw new RuntimeException(e); } return conf; }
From source file:io.coala.config.ConfigUtil.java
/** * @return//from w ww. j a v a 2 s. c o m */ public static Configuration getMainConfig() { if (MAIN_CONFIG == null) try { MAIN_CONFIG = new PropertiesConfiguration(PROPERTIES_FILE); } catch (final ConfigurationException e) { e.printStackTrace(); MAIN_CONFIG = new PropertiesConfiguration(); } return MAIN_CONFIG; }
From source file:com.carmatech.maven.model.MergerTestUtils.java
public static void assertThatPropertiesAreSameAsSources(final File targetFile) throws Exception { final PropertiesConfiguration properties = new PropertiesConfiguration(targetFile); assertThat(properties.getString("FamilyName"), is("Skywalker")); assertThat(properties.getString("first_name"), is("Luke")); assertThat(properties.getString("Sabrolaser"), is("bLuE")); assertThat(properties.getProperty("planets"), isObject(asList("endor", "tatooine", "naboo", "coruscant", "alderaan", "kamino", "yavin"))); assertThat(properties.getProperty("children"), is(nullValue())); }
From source file:eu.optimis.mi.aggregator.util.ConfigManager.java
public static PropertiesConfiguration getPropertiesConfiguration(String configFile) throws ConfigurationException, IOException { String filePath = null;//from w ww . jav a2 s . co m PropertiesConfiguration config = null; filePath = getConfigFilePath(configFile); config = new PropertiesConfiguration(filePath); return config; }
From source file:com.jorge.propiedades.MotorConfiguracion.java
public MotorConfiguracion() { try {//from w ww . j a va 2 s . c o m General general = new General(); if (general.BaseDatos.equals("oracle")) { PropertiesConfiguration configOracle = new PropertiesConfiguration("./quijotelu/Oracle.properties"); if (configOracle.getProperty("oracle.host") == null) { configOracle.setProperty("oracle.host", "127.0.0.1"); configOracle.save(); } if (configOracle.getProperty("oracle.puerto") == null) { configOracle.setProperty("oracle.puerto", "1521"); configOracle.save(); } if (configOracle.getProperty("oracle.servicio") == null) { configOracle.setProperty("oracle.servicio", "xe"); configOracle.save(); } if (configOracle.getProperty("oracle.usuario") == null) { configOracle.setProperty("oracle.usuario", "anita"); configOracle.save(); } if (configOracle.getProperty("oracle.clave") == null) { configOracle.setProperty("oracle.clave", "a"); configOracle.save(); } Host = (String) configOracle.getProperty("oracle.host"); Puerto = (String) configOracle.getProperty("oracle.puerto"); Servicio = (String) configOracle.getProperty("oracle.servicio"); Usuario = (String) configOracle.getProperty("oracle.usuario"); Clave = (String) configOracle.getProperty("oracle.clave"); } else if (general.BaseDatos.equals("sqlserver")) { PropertiesConfiguration configSqlServer = new PropertiesConfiguration( "./quijotelu/SqlServer.properties"); if (configSqlServer.getProperty("sqlserver.host") == null) { configSqlServer.setProperty("sqlserver.host", "127.0.0.1"); configSqlServer.save(); } if (configSqlServer.getProperty("sqlserver.puerto") == null) { configSqlServer.setProperty("oracle.puerto", "1521"); configSqlServer.save(); } if (configSqlServer.getProperty("sqlserver.servicio") == null) { configSqlServer.setProperty("sqlserver.servicio", "xe"); configSqlServer.save(); } if (configSqlServer.getProperty("sqlserver.usuario") == null) { configSqlServer.setProperty("sqlserver.usuario", "anita"); configSqlServer.save(); } if (configSqlServer.getProperty("sqlserver.clave") == null) { configSqlServer.setProperty("sqlserver.clave", "a"); configSqlServer.save(); } Host = (String) configSqlServer.getProperty("sqlserver.host"); Puerto = (String) configSqlServer.getProperty("sqlserver.puerto"); Servicio = (String) configSqlServer.getProperty("sqlserver.servicio"); Usuario = (String) configSqlServer.getProperty("sqlserver.usuario"); Clave = (String) configSqlServer.getProperty("sqlserver.clave"); } } catch (ConfigurationException ex) { Logger.getLogger(MotorConfiguracion.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.gs.obevo.db.impl.core.compare.data.DbDataComparisonConfigFactory.java
public static DbDataComparisonConfig createFromProperties(String path) { try {/*from ww w .j a va 2 s. co m*/ URL url = DbDataComparisonConfigFactory.class.getClassLoader().getResource(path); if (url == null) { url = new File(path).toURI().toURL(); } if (url == null) { throw new IllegalArgumentException("Could not find resource or file at path: " + path); } return createFromProperties(new PropertiesConfiguration(url)); } catch (ConfigurationException e) { throw new RuntimeException(e); } catch (MalformedURLException e) { throw new IllegalArgumentException("Could not find resource or file at path: " + path, e); } }