List of usage examples for org.apache.commons.configuration Configuration getList
List getList(String key);
From source file:org.apache.james.postage.configuration.ConfigurationLoader.java
private void addSendProfiles(PostageConfiguration postageConfiguration, Configuration configuration, String scenario) {// w ww . j av a2 s .co m List<String> profileNames = configuration.getList(scenario + ".profiles.profile[@name]"); log.debug("profiles contained in scenario " + postageConfiguration.getId() + ": " + profileNames.size()); Iterator<String> profileIter = profileNames.iterator(); int profileCount = 0; while (profileIter.hasNext()) { String profileName = profileIter.next(); SendProfile profile = new SendProfile(profileName); String profilePath = getIndexedPropertyName(scenario + ".profiles.profile", profileCount); profile.setSourceInternal(convertToInternalExternalFlag( configuration.getString(getAttributedPropertyName(profilePath, "source")))); profile.setTargetInternal(convertToInternalExternalFlag( configuration.getString(getAttributedPropertyName(profilePath, "target")))); addMailSender(profile, configuration, profilePath); postageConfiguration.addProfile(profile); profileCount++; } }
From source file:org.apache.james.postage.configuration.ConfigurationLoader.java
private void addMailSender(SendProfile profile, Configuration configuration, String profilePath) { List<String> mailSenders = configuration.getList(profilePath + ".send[@count-per-min]"); Iterator<String> mailSenderIter = mailSenders.iterator(); int mailSenderCount = 0; while (mailSenderIter.hasNext()) { mailSenderIter.next(); // ignore String mailSenderPath = getIndexedPropertyName(profilePath + ".send", mailSenderCount); MailSender mailSender = new MailSender(profile); mailSender.setSubject(configuration.getString(getAttributedPropertyName(mailSenderPath, "subject"), "Apache JAMES Postage test mail")); mailSender.setSendPerMinute(/*from w w w .ja v a 2 s .c o m*/ configuration.getInt(getAttributedPropertyName(mailSenderPath, "count-per-min"))); mailSender.setSizeMinText( configuration.getInt(getAttributedPropertyName(mailSenderPath, "text-size-min"), 0)); mailSender.setSizeMaxText( configuration.getInt(getAttributedPropertyName(mailSenderPath, "text-size-max"), 0)); mailSender.setSizeMinBinary( configuration.getInt(getAttributedPropertyName(mailSenderPath, "binary-size-min"), 0)); mailSender.setSizeMaxBinary( configuration.getInt(getAttributedPropertyName(mailSenderPath, "binary-size-max"), 0)); mailSender.setMailFactoryClassname( configuration.getString(getAttributedPropertyName(mailSenderPath, "mail-factory-class"), null)); profile.addMailSender(mailSender); mailSenderCount++; } }
From source file:org.apache.marmotta.loader.core.test.CLITest.java
@Test public void testInputFile() throws ParseException { Configuration cfg = MarmottaLoader.parseOptions(new String[] { "-f", "file1.ttl", "-f", "file2.ttl" }); Assert.assertEquals(2, cfg.getList(LoaderOptions.FILES).size()); Assert.assertThat(cfg.getList(LoaderOptions.FILES), hasItems((Object) "file1.ttl", "file2.ttl")); }
From source file:org.apache.marmotta.loader.core.test.CLITest.java
@Test public void testInputDir() throws ParseException { Configuration cfg = MarmottaLoader.parseOptions(new String[] { "-d", "dir1", "-d", "dir2" }); Assert.assertEquals(2, cfg.getList(LoaderOptions.DIRS).size()); Assert.assertThat(cfg.getList(LoaderOptions.DIRS), hasItems((Object) "dir1", "dir2")); }
From source file:org.apache.marmotta.platform.core.util.FallbackConfiguration.java
@Override public List<Object> getList(String key) { final Configuration mem = getInMemoryConfiguration(); if (mem.containsKey(key)) return mem.getList(key); else//from www . j a va 2 s. c o m return super.getList(key); }
From source file:org.apache.marmotta.platform.core.webservices.CoreApplication.java
@Override public synchronized Set<Class<?>> getClasses() { if (classes == null) { classes = new HashSet<Class<?>>(); try {/* www. jav a 2s. c o m*/ Enumeration<URL> modulePropertiesEnum = this.getClass().getClassLoader() .getResources("kiwi-module.properties"); while (modulePropertiesEnum.hasMoreElements()) { URL moduleUrl = modulePropertiesEnum.nextElement(); Configuration moduleProperties = null; try { moduleProperties = new PropertiesConfiguration(moduleUrl); for (Object clsName : moduleProperties.getList("webservices")) { if (!"".equals(clsName)) { try { Class<?> cls = Class.forName(clsName.toString()); classes.add(cls); log.debug("module {}: registered webservice {}", moduleProperties.getString("name"), cls.getCanonicalName()); } catch (ClassNotFoundException e) { log.error("could not load class {}, it was not found", clsName.toString()); } } } } catch (ConfigurationException e) { log.error("configuration exception: {}", e.getMessage()); } } } catch (IOException e) { log.error("I/O error while trying to load kiwi-module.properties file: {}", e.getMessage()); } } return classes; }
From source file:org.apache.metron.filters.BroMessageFilter.java
/** * @param conf Commons configuration for reading properties files * @param key Key in a JSON mesage where the protocol field is located *///from w ww.j a v a 2 s.c o m @SuppressWarnings({ "unchecked", "rawtypes" }) public BroMessageFilter(Configuration conf, String key) { _key = key; _known_protocols = new HashSet<>(); List known_protocols = conf.getList("source.known.protocols"); _known_protocols.addAll(known_protocols); }
From source file:org.apache.qpid.server.store.berkeleydb.AbstractBDBMessageStore.java
protected Map<String, String> getConfigMap(Map<String, String> defaultConfig, Configuration config, String prefix) throws ConfigurationException { final List<Object> argumentNames = config.getList(prefix + ".name"); final List<Object> argumentValues = config.getList(prefix + ".value"); final int initialSize = argumentNames.size() + defaultConfig.size(); final Map<String, String> attributes = new HashMap<String, String>(initialSize); attributes.putAll(defaultConfig);/*from w ww. ja v a 2 s.c om*/ for (int i = 0; i < argumentNames.size(); i++) { final String argName = argumentNames.get(i).toString(); final String argValue = argumentValues.get(i).toString(); attributes.put(argName, argValue); } return Collections.unmodifiableMap(attributes); }
From source file:org.apache.tinkerpop.gremlin.driver.Settings.java
/** * Read configuration from a file into a new {@link Settings} object. *///ww w.jav a 2 s .c o m public static Settings from(final Configuration conf) { final Settings settings = new Settings(); if (conf.containsKey("port")) settings.port = conf.getInt("port"); if (conf.containsKey("nioPoolSize")) settings.nioPoolSize = conf.getInt("nioPoolSize"); if (conf.containsKey("workerPoolSize")) settings.workerPoolSize = conf.getInt("workerPoolSize"); if (conf.containsKey("username")) settings.username = conf.getString("username"); if (conf.containsKey("password")) settings.password = conf.getString("password"); if (conf.containsKey("jaasEntry")) settings.jaasEntry = conf.getString("jaasEntry"); if (conf.containsKey("protocol")) settings.protocol = conf.getString("protocol"); if (conf.containsKey("hosts")) settings.hosts = conf.getList("hosts").stream().map(Object::toString).collect(Collectors.toList()); if (conf.containsKey("serializer.className")) { final SerializerSettings serializerSettings = new SerializerSettings(); final Configuration serializerConf = conf.subset("serializer"); if (serializerConf.containsKey("className")) serializerSettings.className = serializerConf.getString("className"); final Configuration serializerConfigConf = conf.subset("serializer.config"); if (IteratorUtils.count(serializerConfigConf.getKeys()) > 0) { final Map<String, Object> m = new HashMap<>(); serializerConfigConf.getKeys().forEachRemaining(name -> { m.put(name, serializerConfigConf.getProperty(name)); }); serializerSettings.config = m; } settings.serializer = serializerSettings; } final Configuration connectionPoolConf = conf.subset("connectionPool"); if (IteratorUtils.count(connectionPoolConf.getKeys()) > 0) { final ConnectionPoolSettings cpSettings = new ConnectionPoolSettings(); if (connectionPoolConf.containsKey("channelizer")) cpSettings.channelizer = connectionPoolConf.getString("channelizer"); if (connectionPoolConf.containsKey("enableSsl")) cpSettings.enableSsl = connectionPoolConf.getBoolean("enableSsl"); if (connectionPoolConf.containsKey("trustCertChainFile")) cpSettings.trustCertChainFile = connectionPoolConf.getString("trustCertChainFile"); if (connectionPoolConf.containsKey("minSize")) cpSettings.minSize = connectionPoolConf.getInt("minSize"); if (connectionPoolConf.containsKey("maxSize")) cpSettings.maxSize = connectionPoolConf.getInt("maxSize"); if (connectionPoolConf.containsKey("minSimultaneousUsagePerConnection")) cpSettings.minSimultaneousUsagePerConnection = connectionPoolConf .getInt("minSimultaneousUsagePerConnection"); if (connectionPoolConf.containsKey("maxSimultaneousUsagePerConnection")) cpSettings.maxSimultaneousUsagePerConnection = connectionPoolConf .getInt("maxSimultaneousUsagePerConnection"); if (connectionPoolConf.containsKey("maxInProcessPerConnection")) cpSettings.maxInProcessPerConnection = connectionPoolConf.getInt("maxInProcessPerConnection"); if (connectionPoolConf.containsKey("minInProcessPerConnection")) cpSettings.minInProcessPerConnection = connectionPoolConf.getInt("minInProcessPerConnection"); if (connectionPoolConf.containsKey("maxWaitForConnection")) cpSettings.maxWaitForConnection = connectionPoolConf.getInt("maxWaitForConnection"); if (connectionPoolConf.containsKey("maxContentLength")) cpSettings.maxContentLength = connectionPoolConf.getInt("maxContentLength"); if (connectionPoolConf.containsKey("reconnectInterval")) cpSettings.reconnectInterval = connectionPoolConf.getInt("reconnectInterval"); if (connectionPoolConf.containsKey("reconnectInitialDelay")) cpSettings.reconnectInitialDelay = connectionPoolConf.getInt("reconnectInitialDelay"); if (connectionPoolConf.containsKey("resultIterationBatchSize")) cpSettings.resultIterationBatchSize = connectionPoolConf.getInt("resultIterationBatchSize"); if (connectionPoolConf.containsKey("keepAliveInterval")) cpSettings.keepAliveInterval = connectionPoolConf.getLong("keepAliveInterval"); settings.connectionPool = cpSettings; } return settings; }
From source file:org.apache.tinkerpop.gremlin.hadoop.process.computer.util.MemoryMapReduce.java
@Override public void loadState(final Configuration configuration) { this.memoryKeys = new HashSet((List) configuration.getList(Constants.GREMLIN_HADOOP_MEMORY_KEYS)); }