Example usage for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration

List of usage examples for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration

Introduction

In this page you can find the example usage for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration.

Prototype

public PropertiesConfiguration() 

Source Link

Document

Creates an empty PropertyConfiguration object which can be used to synthesize a new Properties file by adding values and then saving().

Usage

From source file:com.uber.hoodie.utilities.UtilHelpers.java

/**
 *
 * TODO: Support hierarchical config files (see CONFIGURATION-609 for sample)
 *
 * @param fs/*  w w w . j a v a 2  s  . c om*/
 * @param cfgPath
 * @return
 */
public static PropertiesConfiguration readConfig(FileSystem fs, Path cfgPath) {
    try {
        FSDataInputStream in = fs.open(cfgPath);
        PropertiesConfiguration config = new PropertiesConfiguration();
        config.load(in);
        in.close();
        return config;
    } catch (IOException e) {
        throw new HoodieIOException("Unable to read config file at :" + cfgPath, e);
    } catch (ConfigurationException e) {
        throw new HoodieDeltaStreamerException("Invalid configs found in config file at :" + cfgPath, e);
    }
}

From source file:com.mobiaware.util.PropertyManager.java

private void loadProperties(final String fileName) {
    if (StringUtils.isNotBlank(fileName)) {
        File file = new File(fileName);
        try (InputStream is = file.isFile() ? new FileInputStream(file)
                : getClass().getClassLoader().getResourceAsStream((fileName))) {
            if (is != null) {
                PropertiesConfiguration config = new PropertiesConfiguration();

                config.load(is);// w  w w . j  a v  a2  s .  co  m
                _configuration.addConfiguration(config);
            } else {
                throw new IllegalArgumentException("Property file " + fileName + " was not found.");
            }
        } catch (IOException e) {
            LOG.error(Throwables.getStackTraceAsString(e));
            throw new IllegalArgumentException("Error loading properties file", e);
        } catch (ConfigurationException e) {
            LOG.error(Throwables.getStackTraceAsString(e));
            throw new IllegalArgumentException("Error loading properties file", e);
        }
    }
}

From source file:dk.dma.ais.abnormal.analyzer.AbnormalAnalyzerAppTestModule.java

@Provides
@Singleton//from  ww  w  .  j  av a2s. co m
Configuration provideConfiguration() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.setProperty(CONFKEY_ANALYSIS_DRIFT_PERIOD, 10);
    configuration.setProperty(CONFKEY_ANALYSIS_DRIFT_DISTANCE, 500);
    configuration.setProperty(CONFKEY_ANALYSIS_DRIFT_SOG_MIN, 1);
    configuration.setProperty(CONFKEY_ANALYSIS_DRIFT_SOG_MAX, 5);
    configuration.setProperty(CONFKEY_ANALYSIS_DRIFT_COGHDG, 45);
    return configuration;
}

From source file:com.pinterest.pinlater.backends.redis.RedisQueueMonitorTest.java

@BeforeClass
public static void beforeClass() throws Exception {
    // If there is no local Redis, skip this test.
    Assume.assumeTrue(LocalRedisChecker.isRunning(REDIS_PORT));

    // If there is no local Redis, skip this test.
    Assume.assumeTrue(LocalRedisChecker.isRunning(REDIS_PORT));

    configuration = new PropertiesConfiguration();
    try {/* w w  w  .j  ava 2 s.c  o m*/
        configuration.load(ClassLoader.getSystemResourceAsStream("pinlater.redis.test.properties"));
    } catch (ConfigurationException e) {
        throw new RuntimeException(e);
    }
    InputStream redisConfigStream = ClassLoader.getSystemResourceAsStream("redis.local.json");

    backend = new PinLaterRedisBackend(configuration, redisConfigStream, "localhost",
            System.currentTimeMillis());
}

From source file:edu.cmu.lti.oaqa.bioasq.triple.retrieval.GoPubMedTripleRetrievalExecutor.java

@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
    super.initialize(context);

    String conf = UimaContextHelper.getConfigParameterStringValue(context, "conf");
    PropertiesConfiguration gopubmedProperties = new PropertiesConfiguration();
    try {//  w ww  . j av  a  2  s.  c o m
        gopubmedProperties.load(getClass().getResourceAsStream(conf));
    } catch (ConfigurationException e) {
        throw new ResourceInitializationException(e);
    }
    service = new GoPubMedService(gopubmedProperties);
    pages = UimaContextHelper.getConfigParameterIntValue(context, "pages", 1);
    hits = UimaContextHelper.getConfigParameterIntValue(context, "hits", 100);
    bopQueryStringConstructor = new BagOfPhraseQueryStringConstructor();
}

From source file:edu.cmu.lti.oaqa.bioasq.concept.retrieval.GoPubMedConceptRetrievalExecutor.java

@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
    super.initialize(context);
    String conf = UimaContextHelper.getConfigParameterStringValue(context, "conf");
    PropertiesConfiguration gopubmedProperties = new PropertiesConfiguration();
    try {/*www  . j  a va 2s.  co m*/
        gopubmedProperties.load(getClass().getResourceAsStream(conf));
    } catch (ConfigurationException e) {
        throw new ResourceInitializationException(e);
    }
    service = new GoPubMedService(gopubmedProperties);
    pages = UimaContextHelper.getConfigParameterIntValue(context, "pages", 1);
    hits = UimaContextHelper.getConfigParameterIntValue(context, "hits", 100);
    bopQueryStringConstructor = new BagOfPhraseQueryStringConstructor();
    timeout = UimaContextHelper.getConfigParameterIntValue(context, "timeout", 4);
    limit = UimaContextHelper.getConfigParameterIntValue(context, "limit", Integer.MAX_VALUE);
}

From source file:com.linkedin.pinot.server.api.restlet.TableSizeResourceTest.java

@BeforeTest
public void setupTest() throws Exception {

    INDEX_DIR = Files.createTempDirectory(TableSizeResourceTest.class.getName() + "_segmentDir").toFile();
    File confFile = new File(TestUtils.getFileFromResourceUrl(
            InstanceServerStarter.class.getClassLoader().getResource("conf/pinot.properties")));
    PropertiesConfiguration config = new PropertiesConfiguration();
    config.setDelimiterParsingDisabled(false);
    config.load(confFile);/*from w  w w. ja va 2s . c om*/
    ServerConf serverConf = new ServerConf(config);

    LOGGER.info("Trying to create a new ServerInstance!");
    serverInstance = new ServerInstance();
    LOGGER.info("Trying to initial ServerInstance!");
    serverInstance.init(serverConf, new MetricsRegistry());
    LOGGER.info("Trying to start ServerInstance!");
    serverInstance.start();
    apiService = new AdminApiService(serverInstance);
    apiService.start(Integer.parseInt(CommonConstants.Server.DEFAULT_ADMIN_API_PORT));
}

From source file:com.joe.utilities.core.configuration.admin.repository.ConfigurationRepositoryImpl.java

/**
*
*///  w  w  w.  j  a  v  a 2  s  .  c om
public ConfigurationRepositoryImpl() throws GlobalConfigurationException {

    this.systemProperty = new SystemConfiguration();
    this.defaultProperty = Globals.loadDefaultProperties();

    PropertiesConfiguration customerGlobalProperties = Globals.loadCustomerGlobalProperties();
    if (customerGlobalProperties != null) {
        this.overrideProperty = customerGlobalProperties;
    } else {
        this.overrideProperty = new PropertiesConfiguration();
    }
    this.overrideProperty.setAutoSave(true);
}

From source file:com.linkedin.pinot.common.segment.fetcher.SegmentFetcherFactoryTest.java

License:asdf

@Test
public void testGetSegmentFetcherBasedOnURI() throws Exception {
    _segmentFetcherFactory.init(new PropertiesConfiguration());

    Assert.assertTrue(_segmentFetcherFactory
            .getSegmentFetcherBasedOnURI("http://something:wer:") instanceof HttpSegmentFetcher);
    Assert.assertTrue(_segmentFetcherFactory
            .getSegmentFetcherBasedOnURI("file://a/asdf/wer/fd/e") instanceof LocalFileSegmentFetcher);

    Assert.assertNull(_segmentFetcherFactory.getSegmentFetcherBasedOnURI("abc:///something"));
    Assert.assertNull(_segmentFetcherFactory.getSegmentFetcherBasedOnURI("https://something"));
    try {//w w w. j av a2 s .co  m
        _segmentFetcherFactory.getSegmentFetcherBasedOnURI("https:");
        Assert.fail();
    } catch (URISyntaxException e) {
        // Expected
    }
}

From source file:com.linkedin.pinot.server.starter.ServerBuilder.java

/**
 * Construct from config file path//from  w  w w  . j ava 2  s  . c o  m
 * @param configFilePath Path to the config file
 * @param metricsRegistry
 * @throws Exception
 */
public ServerBuilder(File configFilePath, MetricsRegistry metricsRegistry) throws Exception {
    this.metricsRegistry = metricsRegistry;
    if (!configFilePath.exists()) {
        LOGGER.error("configuration file: " + configFilePath.getAbsolutePath() + " does not exist.");
        throw new ConfigurationException(
                "configuration file: " + configFilePath.getAbsolutePath() + " does not exist.");
    }

    // build _serverConf
    PropertiesConfiguration serverConf = new PropertiesConfiguration();
    serverConf.setDelimiterParsingDisabled(false);
    serverConf.load(configFilePath);
    _serverConf = new ServerConf(serverConf);

    initMetrics();
}