List of usage examples for org.apache.commons.configuration Configuration getStringArray
String[] getStringArray(String key);
From source file:com.boozallen.cognition.lens.LensAPI.java
/** * Helper method for creating the spark context from the given cognition configuration * @return a new configured spark context *//*ww w . j a va 2s . c o m*/ public SparkContext createSparkContext() { SparkConf conf = new SparkConf(); Configuration config = cognition.getProperties(); conf.set("spark.serializer", KryoSerializer.class.getName()); conf.setAppName(config.getString("app.name")); conf.setMaster(config.getString("master")); Iterator<String> iterator = config.getKeys("spark"); while (iterator.hasNext()) { String key = iterator.next(); conf.set(key, config.getString(key)); } SparkContext sc = new SparkContext(conf); for (String jar : config.getStringArray("jars")) { sc.addJar(jar); } return sc; }
From source file:dk.dma.ais.abnormal.analyzer.AbnormalAnalyzerAppModule.java
@Provides @Named("shipNameFilter") Predicate<AisPacket> provideShipNameFilter() { Configuration configuration = getConfiguration(); String[] shipNames = configuration.getStringArray(CONFKEY_FILTER_SHIPNAME_SKIP); Predicate<AisPacket> filter = null; if (shipNames != null && shipNames.length > 0 && !(shipNames.length == 1 && shipNames[0].trim().length() == 0)) { String filterExpression = ""; for (int i = 0; i < shipNames.length; i++) { filterExpression += "t.name ~ " + shipNames[i]; if (i != shipNames.length - 1) { filterExpression += " | "; }// ww w .ja v a 2 s . c o m } LOG.debug("filterExpression: " + filterExpression); filter = parseExpressionFilter(filterExpression); LOG.info("Created ship name filter: " + filterExpression); } return filter != null ? filter : aisPacket -> false; }
From source file:com.appeligo.ccdataindexer.Indexer.java
private IndexWriter createIndexWriter() throws IOException { if (indexLocation == null) { return null; }//from w w w . j a v a 2 s .c o m File indexDir = new File(indexLocation); if (!indexDir.isDirectory()) { log.info("Creating Lucene index directory " + indexDir); indexDir.mkdirs(); } IndexWriter indexWriter = null; Configuration config = ConfigurationService.getConfiguration("system"); String[] stopWords = PorterStemAnalyzer.ENGLISH_STOP_WORDS; if (config != null) { stopWords = config.getStringArray("stopWords.word"); } log.info("Using stop words:" + Arrays.asList(stopWords)); while (indexWriter == null) { try { indexWriter = new IndexWriter(indexDir, new PorterStemAnalyzer(stopWords)); indexWriter.setMaxBufferedDocs(1000); indexWriter.setMaxMergeDocs(100); } catch (IOException e) { log.error("Failed to obtain lock for " + indexLocation + ". Trying again.", e); } } return indexWriter; }
From source file:com.impetus.kundera.ycsb.runner.YCSBRunner.java
public YCSBRunner(final String propertyFile, final Configuration config) { this.propertyFile = propertyFile; ycsbJarLocation = config.getString("ycsbjar.location"); clientjarlocation = config.getString("clientjar.location"); host = config.getString("hosts"); schema = config.getString("schema"); columnFamilyOrTable = config.getString("columnfamilyOrTable"); releaseNo = config.getDouble("release.no"); runType = config.getString("run.type", "load"); port = config.getInt("port"); password = config.getString("password"); clients = config.getStringArray("clients"); isUpdate = config.containsKey("update"); crudUtils = new HibernateCRUDUtils(); }
From source file:dk.itst.oiosaml.sp.develmode.DevelModeImpl.java
public void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain fc, Configuration conf) throws IOException, ServletException { // Inserted to avoid loginpage when a samlhandler is requested in develmode if (req.getServletPath().equals(conf.getProperty(Constants.PROP_SAML_SERVLET))) { log.debug("Develmode: Request to SAML servlet, access granted"); fc.doFilter(req, res);//from w ww .java2s . com return; } UserAssertionHolder.set(null); UserAssertion ua = (UserAssertion) req.getSession().getAttribute(Constants.SESSION_USER_ASSERTION); if (ua == null) { String[] users = conf.getStringArray("oiosaml-sp.develmode.users"); if (users == null || users.length == 0) { log.error("No users defined in properties. Set oiosaml-sp.develmode.users"); res.setStatus(500); HTTPUtils.sendCacheHeaders(res); render("nousers.vm", res, new HashMap<String, Object>()); return; } if (users.length == 1) { ua = selectUser(users[0], conf); } else { String selected = req.getParameter("__oiosaml_devel"); if (selected == null || !Arrays.asList(users).contains(selected)) { HTTPUtils.sendCacheHeaders(res); Map<String, Object> params = new HashMap<String, Object>(); params.put("users", users); params.put("params", buildParameterString(req.getParameterMap())); render("users.vm", res, params); return; } else { HTTPUtils.sendCacheHeaders(res); ua = selectUser(selected, conf); req.getSession().setAttribute(Constants.SESSION_USER_ASSERTION, ua); res.sendRedirect(req.getRequestURI() + "?" + buildParameterString(req.getParameterMap())); return; } } } if (ua != null) { req.getSession().setAttribute(Constants.SESSION_USER_ASSERTION, ua); UserAssertionHolder.set(ua); HttpServletRequestWrapper requestWrap = new SAMLHttpServletRequest(req, ua, ""); fc.doFilter(requestWrap, res); return; } else { log.error("No assertion found"); res.sendError(500); return; } }
From source file:at.salzburgresearch.kmt.zkconfig.ZookeeperConfigurationTest.java
@Test public void testList() throws Exception { Configuration config = new ZookeeperConfiguration(zkConnection, 5000, "/test"); final String key = UUID.randomUUID().toString(); final String val = "An extended List, with several, commas, that should stay within, the, same value,"; final List<?> list = Lists.transform(Arrays.asList(val.split(",")), new Function<String, String>() { @Override/*from w ww .j a va 2s . c o m*/ public String apply(String input) { return input.trim(); } }); assertThat(config.getProperty(key), nullValue()); config.setProperty(key, list); assertThat(config.getList(key), IsIterableContainingInOrder.contains(list.toArray())); assertThat(config.getString(key), is(val.split(",")[0].trim())); config.setProperty(key, val.split(",")); assertThat(config.getString(key), is(val.split(",")[0])); assertThat(config.getList(key), CoreMatchers.<Object>hasItems(val.split(","))); assertThat(config.getStringArray(key), arrayContaining(val.split(","))); assertThat(config.getStringArray(key), arrayWithSize(val.split(",").length)); }
From source file:es.bsc.demiurge.openstackjclouds.OpenStackJclouds.java
public OpenStackJclouds() { Configuration c = Config.INSTANCE.getConfiguration().subset(CONFIG_OPENSTACK_SUBSET_PREFIX); OpenStackCredentials credentials = new OpenStackCredentials(c.getString(OS_CONFIG_IP), c.getInt(OS_CONFIG_KEYSTONE_PORT), c.getString(OS_CONFIG_KEYSTONE_TENANT), c.getString(OS_CONFIG_KEYSTONE_USER), c.getString(OS_CONFIG_KEYSTONE_PASSWORD), c.getInt(OS_CONFIG_GLANCE_PORT), c.getString(OS_CONFIG_KEYSTONE_TENANT_ID)); openStackJcloudsApis = new OpenStackJcloudsApis(credentials); zone = openStackJcloudsApis.getNovaApi().getConfiguredZones().toArray()[0].toString(); this.securityGroups = c.getStringArray(OS_CONFIG_SECURITY_GROUPS); glanceConnector = new OpenStackGlance(credentials); this.hostNames.addAll(Arrays.asList(Config.INSTANCE.getConfiguration().getStringArray(CONFIG_HOSTS))); StringBuilder sb = new StringBuilder("Registering hostNames: "); for (String hn : hostNames) { sb.append('[').append(hn).append("], "); }// www .j a v a 2 s .c om logger.info(sb.toString()); }
From source file:ffx.autoparm.ForceFieldFilter_2.java
private void parse(CompositeConfiguration properties) { try {/*from w ww .jav a 2s . com*/ int numConfigs = properties.getNumberOfConfigurations(); /** * Loop over the configurations starting with lowest precedence. * This way higher precedence entries will overwrite lower * precedence entries within the ForceField instance. */ for (int n = numConfigs - 1; n >= 0; n--) { Configuration config = properties.getConfiguration(n); Iterator i = config.getKeys(); while (i.hasNext()) { String key = (String) i.next(); ForceFieldType type = null; try { type = ForceFieldType.valueOf(key.toUpperCase()); } catch (Exception e) { continue; } String list[] = config.getStringArray(key); for (String s : list) { // Add back the key to the input line. s = key + " " + s; String tokens[] = s.trim().split(" +"); String input = s; switch (type) { case ATOM: parseAtom(input, tokens); break; case ANGLE: parseAngle(input, tokens); break; case BIOTYPE: parseBioType(input, tokens); break; case BOND: parseBond(input, tokens); break; case CHARGE: parseCharge(input, tokens); break; case MULTIPOLE: parseMultipole(input, tokens); break; case OPBEND: parseOPBend(input, tokens); break; case STRBND: parseStrBnd(input, tokens); break; case PITORS: parsePiTorsion(input, tokens); break; case TORSION: parseTorsion(input, tokens); break; case TORTORS: parseTorsionTorsion(input, tokens); break; case UREYBRAD: parseUreyBradley(input, tokens); break; case VDW: parseVDW(input, tokens); break; case POLARIZE: parsePolarize(input, tokens); break; default: logger.warning("ForceField type recognized, but not stored:" + type); } } } } //forceField.checkPolarizationTypes(); } catch (Exception e) { String message = "Exception parsing force field."; logger.log(Level.WARNING, message, e); } }
From source file:ffx.potential.parsers.ForceFieldFilter.java
private void parse(CompositeConfiguration properties) { try {//from w w w .jav a 2s . c o m int numConfigs = properties.getNumberOfConfigurations(); /** * Loop over the configurations starting with lowest precedence. * This way higher precedence entries will overwrite lower * precedence entries within the ForceField instance. */ for (int n = numConfigs - 1; n >= 0; n--) { Configuration config = properties.getConfiguration(n); Iterator i = config.getKeys(); while (i.hasNext()) { String key = (String) i.next(); /** * If the key is not recognized as a force field keyword, * continue to the next key. */ if (!ForceField.isForceFieldKeyword(key)) { continue; } String list[] = config.getStringArray(key); for (String s : list) { // Add back the key to the input line. s = key + " " + s; // Split the line on the pound symbol to remove comments. String input = s.split("#+")[0]; String tokens[] = input.trim().split(" +"); // Parse keywords. if (parseKeyword(tokens)) { continue; } // Parse force field types. ForceFieldType type; try { type = ForceFieldType.valueOf(key.toUpperCase()); } catch (Exception e) { break; } switch (type) { case ATOM: parseAtom(input, tokens); break; case ANGLE: parseAngle(input, tokens); break; case BIOTYPE: parseBioType(input, tokens); break; case BOND: parseBond(input, tokens); break; case CHARGE: parseCharge(input, tokens); break; case MULTIPOLE: parseMultipole(input, tokens); break; case OPBEND: parseOPBend(input, tokens); break; case STRBND: parseStrBnd(input, tokens); break; case PITORS: parsePiTorsion(input, tokens); break; case IMPTORS: parseImproper(input, tokens); break; case TORSION: parseTorsion(input, tokens); break; case TORTORS: parseTorsionTorsion(input, tokens); break; case UREYBRAD: parseUreyBradley(input, tokens); break; case VDW: parseVDW(input, tokens); break; case POLARIZE: parsePolarize(input, tokens); break; case ISOLVRAD: parseISolvRad(input, tokens); break; case RELATIVESOLV: parseRelativeSolvation(input, tokens); break; default: logger.log(Level.WARNING, "ForceField type recognized, but not stored:{0}", type); } } } } forceField.checkPolarizationTypes(); } catch (Exception e) { String message = "Exception parsing force field."; logger.log(Level.WARNING, message, e); } }
From source file:com.boozallen.cognition.ingest.storm.topology.ConfigurableIngestTopology.java
protected void configureStorm(Configuration conf, Config stormConf) throws IllegalAccessException { stormConf.registerSerialization(LogRecord.class); //stormConf.registerSerialization(Entity.class); stormConf.registerMetricsConsumer(LoggingMetricsConsumer.class); for (Iterator<String> iter = conf.getKeys(); iter.hasNext();) { String key = iter.next(); String keyString = key.toString(); String cleanedKey = keyString.replaceAll("\\.\\.", "."); String schemaFieldName = cleanedKey.replaceAll("\\.", "_").toUpperCase() + "_SCHEMA"; Field field = FieldUtils.getField(Config.class, schemaFieldName); Object fieldObject = field.get(null); if (fieldObject == Boolean.class) stormConf.put(cleanedKey, conf.getBoolean(keyString)); else if (fieldObject == String.class) stormConf.put(cleanedKey, conf.getString(keyString)); else if (fieldObject == ConfigValidation.DoubleValidator) stormConf.put(cleanedKey, conf.getDouble(keyString)); else if (fieldObject == ConfigValidation.IntegerValidator) stormConf.put(cleanedKey, conf.getInt(keyString)); else if (fieldObject == ConfigValidation.PowerOf2Validator) stormConf.put(cleanedKey, conf.getLong(keyString)); else if (fieldObject == ConfigValidation.StringOrStringListValidator) stormConf.put(cleanedKey, Arrays.asList(conf.getStringArray(keyString))); else if (fieldObject == ConfigValidation.StringsValidator) stormConf.put(cleanedKey, Arrays.asList(conf.getStringArray(keyString))); else {//from w ww . j a va2 s . c o m logger.error( "{} cannot be configured from XML. Consider configuring in navie storm configuration."); throw new UnsupportedOperationException(cleanedKey + " cannot be configured from XML"); } } }