use of org.apache.commons.configuration.Configuration in project opennms by OpenNMS.
the class DefaultOtrsConfigDao method getProperties.
/**
* Retrieves the properties defined in the otrs.properties file.
*
* @return a
* <code>java.util.Properties object containing otrs plugin defined properties
* @throws IOException
*/
private Configuration getProperties() {
Configuration config = new PropertiesConfiguration();
String propsFile = null;
try {
propsFile = new File(new File(System.getProperty("opennms.home"), "etc"), "otrs.properties").getCanonicalPath();
LOG.debug("loading properties from: {}", propsFile);
config = new PropertiesConfiguration(propsFile);
} catch (final ConfigurationException e) {
LOG.error("Unable to load properties from {}", propsFile, e);
} catch (final IOException e) {
LOG.error("Exception when trying to find OTRS configuration properties from {}", propsFile, e);
}
return config;
}
use of org.apache.commons.configuration.Configuration 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.Configuration 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.Configuration in project winery by eclipse.
the class CsarExporter method addNamespacePrefixes.
/**
* Writes the configured mapping namespaceprefix -> namespace to the archive
* <p>
* This is kind of a quick hack. TODO: during the import, the prefixes should be extracted using JAXB and stored in
* the NamespacesResource
*/
private void addNamespacePrefixes(ArchiveOutputStream zos, IRepository repository) throws IOException {
Configuration configuration = repository.getConfiguration(new NamespacesId());
if (configuration instanceof PropertiesConfiguration) {
// Quick hack: direct serialization only works for PropertiesConfiguration
PropertiesConfiguration pconf = (PropertiesConfiguration) configuration;
ArchiveEntry archiveEntry = new ZipArchiveEntry(CsarExporter.PATH_TO_NAMESPACES_PROPERTIES);
zos.putArchiveEntry(archiveEntry);
try {
pconf.save(zos);
} catch (ConfigurationException e) {
CsarExporter.LOGGER.debug(e.getMessage(), e);
zos.write("#Could not export properties".getBytes());
zos.write(("#" + e.getMessage()).getBytes());
}
zos.closeArchiveEntry();
}
}
use of org.apache.commons.configuration.Configuration in project wcomponents by BorderTech.
the class StandaloneLauncher method main.
/**
* The entry point when the launcher is run as a java application.
*
* @param args command-line arguments, ignored.
* @throws Exception on error
*/
public static void main(final String[] args) throws Exception {
// Set the logger to use the text area logger
System.setProperty("org.apache.commons.logging.Log", "com.github.bordertech.wcomponents.lde.StandaloneLauncher$TextAreaLogger");
// Set the port number to a random port
Configuration internalWComponentConfig = Config.getInstance();
CompositeConfiguration config = new CompositeConfiguration(new MapConfiguration(new HashMap<String, Object>()));
// Internal WComponent config next
config.addConfiguration(internalWComponentConfig);
config.setProperty(ConfigurationProperties.LDE_SERVER_PORT, 0);
Config.setConfiguration(config);
getInstance().launcher.run();
getInstance().log("LDE now running on " + getInstance().launcher.getUrl() + '\n');
}
Aggregations