Example usage for org.apache.commons.configuration AbstractConfiguration setDefaultListDelimiter

List of usage examples for org.apache.commons.configuration AbstractConfiguration setDefaultListDelimiter

Introduction

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

Prototype

public static void setDefaultListDelimiter(char delimiter) 

Source Link

Document

For configurations extending AbstractConfiguration, allow them to change the listDelimiter from the default comma (",").

Usage

From source file:com.netflix.config.DynamicURLConfigurationTestWithFileURL.java

@Test
public void testFileURLWithPropertiesUpdatedDynamically() throws IOException, InterruptedException {

    File file = File.createTempFile("DynamicURLConfigurationTestWithFileURL",
            "testFileURLWithPropertiesUpdatedDynamically");
    populateFile(file, "test.host=12312,123213", "test.host1=13212");

    AbstractConfiguration.setDefaultListDelimiter(',');
    DynamicURLConfiguration config = new DynamicURLConfiguration(0, 500, false, file.toURI().toString());
    Thread.sleep(1000);//from  w  w  w . j ava 2 s  . c om
    Assert.assertEquals(13212, config.getInt("test.host1"));
    Thread.sleep(1000);
    populateFile(file, "test.host=12312,123213", "test.host1=13212");
    populateFile(file, "test.host=12312,123213", "test.host1=13212");
    CopyOnWriteArrayList writeList = new CopyOnWriteArrayList();
    writeList.add("12312");
    writeList.add("123213");
    config.setProperty("sample.domain", "google,yahoo");
    Assert.assertEquals(writeList, config.getProperty("test.host"));

}

From source file:com.netflix.config.DynamicPropertyUpdaterTest.java

/**
 * Test method for {@link com.charter.aesd.archaius.DynamicPropertyUpdater#updateProperties(com.netflix.config.WatchedUpdateResult, org.apache.commons.configuration.Configuration, boolean)}.
 * @throws InterruptedException //  w ww .  j  a v a  2 s  .  co  m
 */
@Test
public void testUpdateProperties() throws InterruptedException {
    AbstractConfiguration.setDefaultListDelimiter(',');
    AbstractConfiguration config = new ConcurrentCompositeConfiguration();
    config.addConfigurationListener(new ExpandedConfigurationListenerAdapter(new MyListener()));
    MyListener.resetCount();
    config.setProperty("test", "host,host1,host2");
    config.setProperty("test12", "host12");
    Map<String, Object> added = Maps.newHashMap();
    added.put("test.host", "test,test1");
    Map<String, Object> changed = Maps.newHashMap();
    changed.put("test", "host,host1");
    changed.put("test.host", "");
    dynamicPropertyUpdater.updateProperties(WatchedUpdateResult.createIncremental(added, changed, null), config,
            false);
    assertEquals("", config.getProperty("test.host"));
    assertEquals(2, ((CopyOnWriteArrayList) (config.getProperty("test"))).size());
    assertTrue(((CopyOnWriteArrayList) (config.getProperty("test"))).contains("host"));
    assertTrue(((CopyOnWriteArrayList) (config.getProperty("test"))).contains("host1"));
    assertEquals(5, MyListener.count);
}

From source file:elaborate.editor.config.Configuration.java

public XMLConfiguration load(Reader reader) {
    try {/*from   www . ja  va2s  . c  o m*/
        messages = Maps.newTreeMap();
        AbstractConfiguration.setDefaultListDelimiter(',');
        XMLConfiguration config = new XMLConfiguration();
        config.clear();
        config.load(reader);
        processConfiguration(config);
        xmlConfig = config;
        return config;
    } catch (ConfigurationException e) {
        throw new RuntimeException("Failed to load configuration", e);
    }
}

From source file:com.netflix.config.DynamicPropertyUpdaterTest.java

@Test
public void testAddorChangeProperty() {
    AbstractConfiguration.setDefaultListDelimiter(',');
    AbstractConfiguration config = new ConcurrentCompositeConfiguration();
    config.addConfigurationListener(new ExpandedConfigurationListenerAdapter(new MyListener()));
    MyListener.resetCount();//from   w ww.  j  a v  a2  s .  c  om
    config.setProperty("test.host", "test,test1,test2");
    assertEquals(1, MyListener.count);
    dynamicPropertyUpdater.addOrChangeProperty("test.host", "test,test1,test2", config);
    assertEquals(3, ((CopyOnWriteArrayList) (config.getProperty("test.host"))).size());
    assertTrue(((CopyOnWriteArrayList) (config.getProperty("test.host"))).contains("test"));
    assertTrue(((CopyOnWriteArrayList) (config.getProperty("test.host"))).contains("test1"));
    assertTrue(((CopyOnWriteArrayList) (config.getProperty("test.host"))).contains("test2"));
    assertEquals(1, MyListener.count);
    dynamicPropertyUpdater.addOrChangeProperty("test.host", "test,test1,test2", config);
    assertEquals(3, ((CopyOnWriteArrayList) (config.getProperty("test.host"))).size());
    assertTrue(((CopyOnWriteArrayList) (config.getProperty("test.host"))).contains("test"));
    assertTrue(((CopyOnWriteArrayList) (config.getProperty("test.host"))).contains("test1"));
    assertTrue(((CopyOnWriteArrayList) (config.getProperty("test.host"))).contains("test2"));
    assertEquals(1, MyListener.count);
    dynamicPropertyUpdater.addOrChangeProperty("test.host", "test,test1", config);
    assertEquals(2, ((CopyOnWriteArrayList) (config.getProperty("test.host"))).size());
    assertTrue(((CopyOnWriteArrayList) (config.getProperty("test.host"))).contains("test"));
    assertTrue(((CopyOnWriteArrayList) (config.getProperty("test.host"))).contains("test1"));
    assertEquals(2, MyListener.count);

    dynamicPropertyUpdater.addOrChangeProperty("test.host1", "test1,test12", config);
    assertEquals(2, ((CopyOnWriteArrayList) (config.getProperty("test.host1"))).size());
    assertTrue(((CopyOnWriteArrayList) (config.getProperty("test.host1"))).contains("test1"));
    assertTrue(((CopyOnWriteArrayList) (config.getProperty("test.host1"))).contains("test12"));
    assertEquals(3, MyListener.count);

    config.setProperty("test.host1", "test1.test12");
    dynamicPropertyUpdater.addOrChangeProperty("test.host1", "test1.test12", config);
    assertEquals("test1.test12", config.getProperty("test.host1"));
    assertEquals(4, MyListener.count);
}

From source file:com.qmetry.qaf.automation.core.ConfigurationManager.java

/**
 * Private constructor, prevents instantiation from other classes
 */
private ConfigurationManager() {
    AbstractConfiguration.setDefaultListDelimiter(';');
}

From source file:com.netflix.config.DynamicPropertyUpdaterTest.java

@Test
public void testAddorUpdatePropertyWithColonDelimiter() {
    AbstractConfiguration.setDefaultListDelimiter(':');
    AbstractConfiguration config = new ConcurrentCompositeConfiguration();
    config.addConfigurationListener(new ExpandedConfigurationListenerAdapter(new MyListener()));
    MyListener.resetCount();//from w w w . j av a2 s  .  com
    config.setProperty("test.host", "test:test1:test2");
    assertEquals(1, MyListener.count);
    dynamicPropertyUpdater.addOrChangeProperty("test.host", "test:test1:test2", config);
    assertEquals(3, ((CopyOnWriteArrayList) (config.getProperty("test.host"))).size());
    assertTrue(((CopyOnWriteArrayList) (config.getProperty("test.host"))).contains("test"));
    assertTrue(((CopyOnWriteArrayList) (config.getProperty("test.host"))).contains("test1"));
    assertTrue(((CopyOnWriteArrayList) (config.getProperty("test.host"))).contains("test2"));
    assertEquals(1, MyListener.count); // the config is not set again. when the value is still not changed.
    config.setProperty("test.host1", "test1:test12");
    // changing the new object value , the config.setProperty should be called again.
    dynamicPropertyUpdater.addOrChangeProperty("test.host1", "test1.test12", config);
    assertEquals("test1.test12", config.getProperty("test.host1"));
    assertEquals(3, MyListener.count);
}

From source file:org.apache.james.backends.cassandra.init.configuration.ClusterConfiguration.java

public static ClusterConfiguration from(Configuration configuration) {
    AbstractConfiguration.setDefaultListDelimiter(',');
    return ClusterConfiguration.builder().hosts(listCassandraServers(configuration))
            .keyspace(Optional.ofNullable(configuration.getString(CASSANDRA_KEYSPACE, null)))
            .replicationFactor(Optional.ofNullable(configuration.getInteger(REPLICATION_FACTOR, null)))
            .minDelay(Optional.ofNullable(configuration.getInteger(CONNECTION_RETRY_MIN_DELAY, null)))
            .maxRetry(Optional.ofNullable(configuration.getInteger(CONNECTION_MAX_RETRY, null)))
            .queryLoggerConfiguration(QueryLoggerConfiguration.from(configuration))
            .poolingOptions(readPoolingOptions(configuration))
            .readTimeoutMillis(Optional.ofNullable(configuration.getInteger(READ_TIMEOUT_MILLIS, null)))
            .connectTimeoutMillis(Optional.ofNullable(configuration.getInteger(CONNECT_TIMEOUT_MILLIS, null)))
            .build();//from   w  w  w .  j  av a2s  .  co m
}

From source file:org.apache.james.backends.es.ElasticSearchConfiguration.java

private static ImmutableList<Host> getHosts(Configuration propertiesReader) throws ConfigurationException {
    AbstractConfiguration.setDefaultListDelimiter(',');
    Optional<String> masterHost = Optional
            .ofNullable(propertiesReader.getString(ELASTICSEARCH_MASTER_HOST, null));
    Optional<Integer> masterPort = Optional.ofNullable(propertiesReader.getInteger(ELASTICSEARCH_PORT, null));
    List<String> multiHosts = Arrays.asList(propertiesReader.getStringArray(ELASTICSEARCH_HOSTS));

    validateHostsConfigurationOptions(masterHost, masterPort, multiHosts);

    if (masterHost.isPresent()) {
        return ImmutableList.of(Host.from(masterHost.get(), masterPort.get()));
    } else {//  www  .j  a  v  a  2s . c o m
        return multiHosts.stream().map(ipAndPort -> Host.parse(ipAndPort, DEFAULT_PORT_AS_OPTIONAL))
                .collect(Guavate.toImmutableList());
    }
}

From source file:org.apache.james.modules.mailbox.TikaConfigurationReader.java

public static TikaConfiguration readTikaConfiguration(Configuration configuration) {
    AbstractConfiguration.setDefaultListDelimiter(',');
    Optional<Boolean> enabled = Optional.ofNullable(configuration.getBoolean(TIKA_ENABLED, null));

    Optional<Boolean> cacheEnabled = Optional.ofNullable(configuration.getBoolean(TIKA_CACHE_ENABLED, null));

    Optional<String> host = Optional.ofNullable(configuration.getString(TIKA_HOST, null));

    Optional<Integer> port = Optional.ofNullable(configuration.getInteger(TIKA_PORT, null));

    Optional<Integer> timeoutInMillis = Optional.ofNullable(configuration.getInteger(TIKA_TIMEOUT_IN_MS, null));

    Optional<Duration> cacheEvictionPeriod = Optional
            .ofNullable(configuration.getString(TIKA_CACHE_EVICTION_PERIOD, null))
            .map(rawString -> TimeConverter.getMilliSeconds(rawString, TimeConverter.Unit.SECONDS))
            .map(Duration::ofMillis);

    Optional<Long> cacheWeight = Optional.ofNullable(configuration.getString(TIKA_CACHE_WEIGHT_MAX, null))
            .map(Throwing.function(Size::parse)).map(Size::asBytes);

    Set<String> contentTypeBlacklist = StreamUtils
            .ofNullable(configuration.getStringArray(TIKA_CONTENT_TYPE_BLACKLIST)).map(String::trim)
            .collect(ImmutableSet.toImmutableSet());

    return TikaConfiguration.builder().enable(enabled).host(host).port(port).timeoutInMillis(timeoutInMillis)
            .cacheEnable(cacheEnabled).cacheEvictionPeriod(cacheEvictionPeriod).cacheWeightInBytes(cacheWeight)
            .contentTypeBlacklist(contentTypeBlacklist).build();
}

From source file:org.esco.grouperui.tools.property.PropertyManagerFactory.java

/**
 * Default constructor.
 */
public PropertyManagerFactory() {
    AbstractConfiguration.setDefaultListDelimiter(ESCOConstantes.ARRAY_DELIMITER);
}