Search in sources :

Example 41 with PropertiesConfiguration

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;
}
Also used : ConfigurationException(org.apache.commons.configuration.ConfigurationException) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Example 42 with PropertiesConfiguration

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));
}
Also used : InputStreamReader(java.io.InputStreamReader) ConfigurationException(org.apache.commons.configuration.ConfigurationException) ResourceBundleClass(net.jangaroo.properties.model.ResourceBundleClass) BufferedReader(java.io.BufferedReader) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) PropcException(net.jangaroo.properties.api.PropcException) PropertiesClass(net.jangaroo.properties.model.PropertiesClass) IOException(java.io.IOException) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) FileInputStream(java.io.FileInputStream)

Example 43 with PropertiesConfiguration

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;
}
Also used : Configuration(org.apache.commons.configuration.Configuration) XMLConfiguration(org.apache.commons.configuration.XMLConfiguration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) JSONObject(org.json.simple.JSONObject) HashMap(java.util.HashMap) JSONArray(org.json.simple.JSONArray) JSONParser(org.json.simple.parser.JSONParser) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Example 44 with PropertiesConfiguration

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;
}
Also used : Configuration(org.apache.commons.configuration.Configuration) XMLConfiguration(org.apache.commons.configuration.XMLConfiguration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) JSONObject(org.json.simple.JSONObject) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Example 45 with PropertiesConfiguration

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));
    }
}
Also used : ConfigurationException(org.apache.commons.configuration.ConfigurationException) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Aggregations

PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)118 File (java.io.File)38 Configuration (org.apache.commons.configuration.Configuration)33 ConfigurationException (org.apache.commons.configuration.ConfigurationException)33 IOException (java.io.IOException)12 Test (org.testng.annotations.Test)11 BeforeClass (org.testng.annotations.BeforeClass)10 MetricsRegistry (com.yammer.metrics.core.MetricsRegistry)9 IndexLoadingConfigMetadata (com.linkedin.pinot.common.metadata.segment.IndexLoadingConfigMetadata)8 FileBasedInstanceDataManager (com.linkedin.pinot.core.data.manager.offline.FileBasedInstanceDataManager)8 FileInputStream (java.io.FileInputStream)7 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)7 URL (java.net.URL)6 ServerQueryExecutorV1Impl (com.linkedin.pinot.core.query.executor.ServerQueryExecutorV1Impl)5 ServerConf (com.linkedin.pinot.server.conf.ServerConf)5 FileNotFoundException (java.io.FileNotFoundException)5 Path (java.nio.file.Path)5 HashMap (java.util.HashMap)5 Properties (java.util.Properties)5 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)4