Example usage for org.apache.commons.configuration Configuration getStringArray

List of usage examples for org.apache.commons.configuration Configuration getStringArray

Introduction

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

Prototype

String[] getStringArray(String key);

Source Link

Document

Get an array of strings associated with the given configuration key.

Usage

From source file:org.sonar.plugins.xaml.XamlLanguage.java

/**
 * {@inheritDoc}/*from w w w  . j a  v a 2  s . c  o  m*/
 */
public XamlLanguage(Configuration config) {
    super(KEY);
    sourceSuffixes = createStringArray(config.getStringArray(XamlPlugin.SOURCE_FILE_SUFFIXES_KEY),
            DEFAULT_SOURCE_SUFFIXES);
    fileSuffixes = sourceSuffixes;
}

From source file:org.sonar.server.configuration.ConfigurationLogger.java

static String getTruncatedProperty(Configuration configuration, String key) {
    String property = StringUtils.join(configuration.getStringArray(key), ",");
    return StringUtils.abbreviate(property, 100);
}

From source file:org.ublog.benchmark.cassandra.DataStoreCassandra.java

public void initialize() throws Exception {
    this.keyspace = "Twitter";

    Configuration conf = new PropertiesConfiguration("cassandra.properties");
    String[] nodes = conf.getStringArray("node");
    this.max_active_connections = conf.getInt("maxActiveConnections");
    this.partitioner = conf.getString("partitioner");
    this.inst = new String[nodes.length];
    for (int i = 0; i < nodes.length; i++) {
        String[] split = nodes[i].split(":");
        if (split.length == 2) {
            int port = new Integer(split[1]);
            this.inst[i] = InetAddress.getByName(split[0]).getHostName() + ":" + port;
        } else {//  w w  w. jav  a2  s.com
            logger.error("Nodes configuration is wrong");
            throw new ConfigurationException("Nodes must be in the format hostName:port");
        }
    }

    String hosts = "";
    int i = 0;
    for (String str : inst) {
        if (i < this.inst.length - 1) {
            hosts += str + ",";
        } else {
            hosts += str;
        }
        i++;
    }
    System.out.println("HOSTS: " + hosts);
    CassandraHostConfigurator cassandraHostConfigurator = new CassandraHostConfigurator(hosts);

    cassandraHostConfigurator.setMaxActive(this.max_active_connections);
    cassandraHostConfigurator.setMaxIdle(CassandraHost.DEFAULT_MAX_IDLE);
    cassandraHostConfigurator.setExhaustedPolicy(ExhaustedPolicy.WHEN_EXHAUSTED_BLOCK);
    cassandraHostConfigurator.setMaxWaitTimeWhenExhausted(CassandraHost.DEFAULT_MAX_WAITTIME_WHEN_EXHAUSTED);
    cassandraHostConfigurator.setTimestampResolution("MICROSECONDS");
    System.out.println(cassandraHostConfigurator.toString());
    this.connPool = CassandraClientPoolFactory.getInstance().createNew(cassandraHostConfigurator);
}

From source file:org.ublog.benchmark.voldemort.DataStoreVoldemort.java

public void initialize() throws Exception {
    Configuration conf = new PropertiesConfiguration("voldemort.properties");
    String[] nodes = conf.getStringArray("node");
    List<String> listNodes = new ArrayList<String>();
    for (String tmp : nodes) {
        String[] split = tmp.split(":");
        if (split.length == 2) {
            int port = new Integer(split[1]);
            listNodes.add("tcp://" + split[0] + ":" + port);
        } else {//  w  ww.j a  v  a  2 s  .  c om
            logger.error("Nodes configuration is wrong");
            throw new ConfigurationException("Nodes must be in the format hostName:port");
        }
    }

    ClientConfig config = new ClientConfig();
    config.setBootstrapUrls(listNodes);
    config.setMaxConnectionsPerNode(3);
    config.setMaxThreads(3);
    this.factory = new SocketStoreClientFactory(config);
    this.users = factory.getStoreClient("users");
    this.friendsTimeLine = factory.getStoreClient("friendsTimeLine");
    this.tweets = factory.getStoreClient("tweets");
    this.tagsStore = factory.getStoreClient("tags");
}

From source file:org.wso2.andes.configuration.qpid.ServerConfiguration.java

@SuppressWarnings("unchecked")
protected void setupVirtualHosts(org.apache.commons.configuration.Configuration conf)
        throws ConfigurationException {

    String[] vhostFiles = conf.getStringArray("virtualhosts");
    org.apache.commons.configuration.Configuration vhostConfig = conf.subset("virtualhosts");

    // Only one configuration mechanism allowed
    if (!(vhostFiles.length == 0) && !vhostConfig.subset("virtualhost").isEmpty()) {
        throw new ConfigurationException(
                "Only one of external or embedded virtualhosts configuration allowed.");
    }/*ww w .j a v  a  2 s  . c o  m*/

    // We can only have one vhosts XML file included
    if (vhostFiles.length > 1) {
        throw new ConfigurationException(
                "Only one external virtualhosts configuration file allowed, " + "multiple filenames found.");
    }

    // Virtualhost configuration object
    org.apache.commons.configuration.Configuration vhostConfiguration = new HierarchicalConfiguration();

    // Load from embedded configuration if possible
    if (!vhostConfig.subset("virtualhost").isEmpty()) {
        vhostConfiguration = vhostConfig;
    } else {
        // Load from the external configuration if possible
        for (String fileName : vhostFiles) {
            // Open the vhosts XML file and copy values from it to our config
            _vhostsFile = new File(fileName);
            if (!_vhostsFile.exists()) {
                throw new ConfigurationException("Virtualhosts file does not exist");
            }
            vhostConfiguration = parseConfig(new File(fileName));

            // save the default virtualhost name
            String defaultVirtualHost = vhostConfiguration.getString("default");
            _configuration.setProperty("virtualhosts.default", defaultVirtualHost);
        }
    }

    // Now extract the virtual host names from the configuration object
    List hosts = vhostConfiguration.getList("virtualhost.name");
    for (Object host : hosts) {
        String name = (String) host;

        // Add the virtual hosts to the server configuration
        VirtualHostConfiguration virtualhost = new VirtualHostConfiguration(name,
                vhostConfiguration.subset("virtualhost." + name));
        _virtualHosts.put(virtualhost.getName(), virtualhost);
    }
}

From source file:uk.gov.gchq.gaffer.gafferpop.GafferPopGraph.java

private static Graph createGraph(final Configuration configuration) {
    final String graphId = configuration.getString(GRAPH_ID);
    if (null == graphId) {
        throw new IllegalArgumentException(GRAPH_ID + " property is required");
    }//from   w  ww. j a va 2s.c o  m

    final Path storeProps = Paths.get(configuration.getString(STORE_PROPERTIES));
    final Schema.Builder schemaBuilder = new Schema.Builder();
    for (final String schemaPath : configuration.getStringArray(SCHEMAS)) {
        schemaBuilder.merge(Schema.fromJson(Paths.get(schemaPath)));
    }

    return new Graph.Builder().graphId(graphId).storeProperties(storeProps).addSchema(schemaBuilder.build())
            .build();
}

From source file:umich.ms.batmass.gui.viewers.map2d.options.Map2DOptions.java

/**
 * Converts HEX colors stored in an Apache Commons Configuration, e.g.:<br/>
 * <code>defaultConfig.addProperty("colorPivots", new String[]{"#000000", "#00007F", "#0000FF"});</code>
 * to {@link java.awt.Color}[].//  ww w .  j  av a  2s .c om
 * @param config
 * @return
 */
public static Color[] getColorsFromConfig(Configuration config) {
    String[] colorsArr = config.getStringArray("colorPivots");
    Color[] colors = new Color[colorsArr.length];
    for (int i = 0; i < colorsArr.length; i++) {
        colors[i] = Color.decode(colorsArr[i]);
    }
    return colors;
}

From source file:util.AbstractReadSystemConfigurations.java

private static String[] readSystemEmailAccountname() {

    String[] accountname = null;//from w  ww  .  j  av  a 2  s . com

    try {
        final Configuration config = new PropertiesConfiguration(PATH);
        accountname = config.getStringArray("systemEmail.accountname");

    } catch (final ConfigurationException e) {
        LOG.error(e.toString());
    }

    return accountname;
}

From source file:util.AbstractReadSystemConfigurations.java

private static String[] readSeeksServers() {

    String[] seeksServers = null;

    try {// w w w  .jav  a 2 s.c  o  m
        final Configuration config = new PropertiesConfiguration(PATH);
        seeksServers = config.getStringArray("seeksServer.domains");

    } catch (final ConfigurationException e) {
        LOG.error(e.toString());
    }

    return seeksServers;
}