use of org.apache.commons.configuration.PropertiesConfiguration in project opennms by OpenNMS.
the class ReadOnlyRtConfigDao method getProperties.
/**
* Retrieves the properties defined in the rt.properties file.
*
* @return a <code>java.util.Properties</code> object containing rt plugin defined properties
*
* @author <a href="mailto:jonathan@opennms.org">Jonathan Sartin</a>
*/
protected Configuration getProperties() {
final long now = System.currentTimeMillis();
if (m_config == null || now > (m_lastUpdated + TIMEOUT)) {
String propsFile = getFile();
LOG.debug("loading properties from: {}", propsFile);
try {
m_config = new PropertiesConfiguration(propsFile);
m_lastUpdated = now;
} catch (final ConfigurationException e) {
LOG.error("Unable to load RT properties", e);
}
}
return m_config;
}
use of org.apache.commons.configuration.PropertiesConfiguration in project jangaroo-tools by CoreMedia.
the class PropertyClassGenerator method generate.
@Override
public File generate(File propertiesFile) {
PropertiesConfiguration p = new PropertiesConfiguration();
p.setDelimiterParsingDisabled(true);
Reader r = null;
try {
r = new BufferedReader(new InputStreamReader(new FileInputStream(propertiesFile), "UTF-8"));
p.load(r);
} catch (IOException e) {
throw new PropcException("Error while parsing properties file", propertiesFile, e);
} catch (ConfigurationException e) {
throw new PropcException("Error while parsing properties file", propertiesFile, e);
} finally {
try {
if (r != null) {
r.close();
}
} catch (IOException e) {
// not really
}
}
ResourceBundleClass bundle = new ResourceBundleClass(PropcHelper.computeBaseClassName(locations, propertiesFile));
// Create properties class, which registers itself with the bundle.
return generateJangarooClass(new PropertiesClass(bundle, PropcHelper.computeLocale(propertiesFile), p, propertiesFile));
}
use of org.apache.commons.configuration.PropertiesConfiguration in project metron by apache.
the class SettingsLoader method loadKnownHosts.
public static Map<String, JSONObject> loadKnownHosts(String config_path) throws ConfigurationException, ParseException {
Configuration hosts = new PropertiesConfiguration(config_path);
Iterator<String> keys = hosts.getKeys();
Map<String, JSONObject> known_hosts = new HashMap<String, JSONObject>();
JSONParser parser = new JSONParser();
while (keys.hasNext()) {
String key = keys.next().trim();
JSONArray value = (JSONArray) parser.parse(hosts.getProperty(key).toString());
known_hosts.put(key, (JSONObject) value.get(0));
}
return known_hosts;
}
use of org.apache.commons.configuration.PropertiesConfiguration in project metron by apache.
the class SettingsLoader method loadTopologyIdnetifier.
@SuppressWarnings("unchecked")
public static JSONObject loadTopologyIdnetifier(String config_path) throws ConfigurationException {
Configuration config = new PropertiesConfiguration(config_path);
String topology = config.getString("topology.id", "unknown");
String instance = config.getString("instance.id", "unknown");
JSONObject identifier = new JSONObject();
identifier.put("topology", topology);
identifier.put("topology_instance", instance);
return identifier;
}
use of org.apache.commons.configuration.PropertiesConfiguration in project oxCore by GluuFederation.
the class FileConfiguration method loadProperties.
protected void loadProperties() {
try {
this.propertiesConfiguration = new PropertiesConfiguration(this.fileName);
this.loaded = true;
} catch (ConfigurationException ex) {
LOG.debug(String.format("Failed to load '%s' configuration file from config folder", this.fileName));
}
}
Aggregations