use of org.apache.commons.configuration.ConfigurationException in project metron by apache.
the class ConfigurationManager method getConfiguration.
/**
* Common method to load content of all configuration resources defined in
* 'config-definition.xml'.
*
* @param configDefFilePath
* the config def file path
* @return Configuration
*/
public static Configuration getConfiguration(String configDefFilePath) {
if (configurationsCache.containsKey(configDefFilePath)) {
return configurationsCache.get(configDefFilePath);
}
CombinedConfiguration configuration = null;
synchronized (configurationsCache) {
if (configurationsCache.containsKey(configDefFilePath)) {
return configurationsCache.get(configDefFilePath);
}
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
String filePath = getConfigDefFilePath(configDefFilePath);
LOGGER.info("loading from 'configDefFilePath' : {}", filePath);
builder.setFile(new File(filePath));
try {
configuration = builder.getConfiguration(true);
configurationsCache.put(filePath, configuration);
} catch (ConfigurationException | ConfigurationRuntimeException e) {
LOGGER.info("Exception in loading property files.", e);
}
}
return configuration;
}
use of org.apache.commons.configuration.ConfigurationException in project winery by eclipse.
the class AutoSaveListener method configurationChanged.
@Override
public void configurationChanged(ConfigurationEvent event) {
if (!event.isBeforeUpdate()) {
try {
if (!Files.exists(this.path.getParent())) {
Files.createDirectories(this.path.getParent());
}
} catch (IOException ce) {
AutoSaveListener.LOGGER.error("Could not update properties file", ce);
return;
}
try (OutputStream out = Files.newOutputStream(this.path, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {
OutputStreamWriter writer = new OutputStreamWriter(out);
this.configuration.save(writer);
} catch (ConfigurationException | IOException ce) {
AutoSaveListener.LOGGER.error("Could not update properties file", ce);
}
}
}
use of org.apache.commons.configuration.ConfigurationException in project winery by eclipse.
the class FilebasedRepository method getConfiguration.
@Override
public Configuration getConfiguration(RepositoryFileReference ref) {
Path path = this.ref2AbsolutePath(ref);
PropertiesConfiguration configuration = new PropertiesConfiguration();
if (Files.exists(path)) {
try (Reader r = Files.newBufferedReader(path, Charset.defaultCharset())) {
configuration.load(r);
} catch (ConfigurationException | IOException e) {
FilebasedRepository.LOGGER.error("Could not read config file", e);
throw new IllegalStateException("Could not read config file", e);
}
}
configuration.addConfigurationListener(new AutoSaveListener(path, configuration));
return configuration;
}
use of org.apache.commons.configuration.ConfigurationException in project opennms by OpenNMS.
the class DefaultRemedyConfigDao method getProperties.
/**
* Retrieves the properties defined in the remedy.properties file.
*
* @param remedyTicketerPlugin
* @return a
* <code>java.util.Properties object containing remedy plugin defined properties
*/
private Configuration getProperties() {
if (m_config != null)
return m_config;
String propsFile = new String(System.getProperty("opennms.home") + "/etc/remedy.properties");
LOG.debug("loading properties from: {}", propsFile);
Configuration config = null;
try {
config = new PropertiesConfiguration(propsFile);
} catch (final ConfigurationException e) {
LOG.debug("Unable to load properties from {}", propsFile, e);
}
m_config = config;
return config;
}
use of org.apache.commons.configuration.ConfigurationException in project opennms by OpenNMS.
the class DroolsTicketerConfigDao method getProperties.
/**
* Retrieves the properties defined in the drools-ticketer.properties file.
*/
private Configuration getProperties() {
String propsFile = new String(System.getProperty("opennms.home") + "/etc/drools-ticketer.properties");
LOG.debug("loading properties from: {}", propsFile);
Configuration config = null;
try {
config = new PropertiesConfiguration(propsFile);
} catch (final ConfigurationException e) {
LOG.debug("Unable to load properties from {}", propsFile, e);
}
return config;
}
Aggregations