List of usage examples for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration
public PropertiesConfiguration(URL url) throws ConfigurationException
From source file:com.TersoSolutions.Jetstream.SDK.Application.User.JetstreamServiceClient.java
/** * Constructor for the JetstreamServiceClient. This client is the base * service for accessing the Jetstream REST endpoints. Reads information * from the service.properties file located at the root of the project * /*from w w w .j a va 2 s .co m*/ * @throws IllegalArgumentException */ public JetstreamServiceClient() { try { config = new PropertiesConfiguration("service.properties"); String jetstreamAPIUrl = config.getString("jetstream.baseuri"); String accessKey = config.getString("jetstream.accesskey"); init(jetstreamAPIUrl, accessKey); } catch (ConfigurationException e) { e.printStackTrace(); } }
From source file:com.denimgroup.threadfix.cli.HttpRestUtilsTests.java
@Test public void testSetKey() { PropertiesManager utils = new PropertiesManager(); utils.setKey(TestPropertiesManager.API_KEY); try {/* w w w . j a v a 2 s .c o m*/ Configuration properties = new PropertiesConfiguration("threadfix.properties"); assertEquals(TestPropertiesManager.API_KEY, properties.getString("key")); } catch (ConfigurationException e) { assertFalse(true); } }
From source file:eu.tango.energymodeller.energypredictor.workloadpredictor.CpuRecentHistoryWorkloadPredictor.java
/** * This sets up a CPU Recent History Workload Predictor. The main need is to * establish the time window by which the workload predictor must work. *//*ww w . j av a 2s . c om*/ public CpuRecentHistoryWorkloadPredictor() { try { PropertiesConfiguration config; if (new File(CONFIG_FILE).exists()) { config = new PropertiesConfiguration(CONFIG_FILE); } else { config = new PropertiesConfiguration(); config.setFile(new File(CONFIG_FILE)); } config.setAutoSave(true); //This will save the configuration file back to disk. In case the defaults need setting. readSettings(config); } catch (ConfigurationException ex) { Logger.getLogger(CpuOnlyEnergyPredictor.class.getName()).log(Level.SEVERE, "Taking the default load from the settings file did not work", ex); } }
From source file:io.apiman.manager.api.micro.ManagerApiMicroServiceConfig.java
/** * @see io.apiman.manager.api.core.config.ApiManagerConfig#loadProperties() *//* w ww .j a v a 2 s .co m*/ @Override protected Configuration loadProperties() { CompositeConfiguration config = (CompositeConfiguration) super.loadProperties(); try { String propsUrl = System.getProperty(APIMAN_PROPERTIES_URL); if (propsUrl == null) { propsUrl = getClass().getClassLoader().getResource("micro-apiman.properties").toString(); //$NON-NLS-1$ } config.addConfiguration(new PropertiesConfiguration(new URL(propsUrl))); } catch (Exception e) { throw new RuntimeException(e); } return config; }
From source file:net.sourceforge.jukebox.model.SettingsTest.java
/** * Tests the <code>load</code> and <code>save</code> methods. * @throws IOException IOException/*from w w w . j a v a 2s. c o m*/ * @throws ConfigurationException ConfigurationException */ @Test public final void testLoad() throws IOException, ConfigurationException { Settings settings = new Settings(); settings.setContentFolder("/var/media"); settings.setPlayerUrl("http://localhost/play"); settings.setModifiedDays(MODIFIED_DAYS); File file = File.createTempFile("dummy", "properties"); file.deleteOnExit(); PropertiesConfiguration configuration = new PropertiesConfiguration(file); settings.save(configuration); Settings savedSettings = new Settings(); savedSettings.load(configuration); assertEquals(settings, savedSettings); }
From source file:eu.learnpad.ca.config.PropertyUtil.java
public PropertyUtil(String configFileLocation) { try {/*from w w w. jav a 2 s . co m*/ this.properties = new PropertiesConfiguration(configFileLocation); } catch (ConfigurationException e) { log.error("Cannot load application properties for dashboard component from : " + configFileLocation + "\n Loaded Default ConfFile Instead.", e); try { this.properties = new PropertiesConfiguration(DEFAULT_CONFIG_FILE_LOCATION); } catch (ConfigurationException e1) { e1.printStackTrace(); } } }
From source file:fr.jetoile.hadoopunit.component.Neo4jBootstrap.java
private void loadConfig() throws BootstrapException { try {//from www . java 2 s .com configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE); } catch (ConfigurationException e) { throw new BootstrapException("bad config", e); } port = configuration.getInt(HadoopUnitConfig.NEO4J_PORT_KEY); ip = configuration.getString(HadoopUnitConfig.NEO4J_IP_KEY); tmp = configuration.getString(HadoopUnitConfig.NEO4J_TEMP_DIR_KEY); }
From source file:com.nesscomputing.config.util.ClasspathConfigStrategy.java
@Override public AbstractConfiguration load(final String configName, final String configPath) throws ConfigurationException { final String classpathPrefix = getLocation().getPath(); // A property configuration lives in a configuration directory and is called // "config.properties" final String[] propertyFileNames = new String[] { classpathPrefix + "/" + configPath + "/config.properties", classpathPrefix + "/" + configName + ".properties" }; for (String propertyFileName : propertyFileNames) { LOG.trace("Trying to load '%s'...", propertyFileName); final URL configUrl = Config.class.getResource(propertyFileName); if (configUrl != null) { LOG.trace("... succeeded"); return new PropertiesConfiguration(configUrl); } else {//from w ww . j ava 2 s.c om LOG.trace("... failed"); } } return null; }
From source file:es.bsc.servicess.ide.IDEProperties.java
/** Constructor * @param file Properties File/*from w w w. jav a2 s . c o m*/ * @throws ConfigurationException */ public IDEProperties(File file) throws ConfigurationException { config = new PropertiesConfiguration(file); }
From source file:com.opentable.config.util.FileConfigStrategy.java
@Override public AbstractConfiguration load(final String configName, final String configPath) throws ConfigurationException { if (!(directoryLocation.exists() && directoryLocation.isDirectory() && directoryLocation.canRead())) { return null; }//from w w w . j a v a2s . co m // A property configuration lives in a configuration directory and is called // "config.properties" final File[] propertyFiles = new File[] { new File(directoryLocation, configPath + File.separator + "config.properties"), new File(directoryLocation, configName + ".properties") }; for (final File propertyFile : propertyFiles) { if (propertyFile.exists() && propertyFile.isFile() && propertyFile.canRead()) { LOG.trace("Trying to load '{}'...", propertyFile); try { final AbstractConfiguration config = new PropertiesConfiguration(propertyFile); LOG.trace("... succeeded"); return config; } catch (ConfigurationException ce) { LOG.trace("... failed", ce); } } else { LOG.debug("'{}' does not exist", propertyFile); } } return null; }