List of usage examples for org.apache.commons.configuration SubnodeConfiguration getString
public String getString(String key)
From source file:com.hipstogram.context.config.sections.ZookeeperSection.java
public ZookeeperSection(SubnodeConfiguration zookeeper) { this.port = zookeeper.getInt("port"); this.host = zookeeper.getString("host"); }
From source file:com.oltpbenchmark.DBWorkload.java
private static List<String> get_weights(String plugin, SubnodeConfiguration work) { List<String> weight_strings = new LinkedList<String>(); @SuppressWarnings("unchecked") List<SubnodeConfiguration> weights = work.configurationsAt("weights"); boolean weights_started = false; for (SubnodeConfiguration weight : weights) { // stop if second attributed node encountered if (weights_started && weight.getRootNode().getAttributeCount() > 0) { break; }//from w w w. j a v a2 s . c o m //start adding node values, if node with attribute equal to current plugin encountered if (weight.getRootNode().getAttributeCount() > 0 && weight.getRootNode().getAttribute(0).getValue().equals(plugin)) { weights_started = true; } if (weights_started) { weight_strings.add(weight.getString("")); } } return weight_strings; }
From source file:com.github.steveash.typedconfig.HierarchicalConfigurationSanityTest.java
@Test public void testNestedFirst() throws Exception { assertEquals(42, config.getInt("atParent")); SubnodeConfiguration nested = config.configurationAt("nested(0)"); assertEquals("nested1", nested.getString("a")); assertEquals(42, nested.getParent().getInt("atParent")); }
From source file:com.github.steveash.typedconfig.HierarchicalConfigurationSanityTest.java
@Test public void testDoubleNested() throws Exception { assertEquals(42, config.getInt("atParent")); SubnodeConfiguration nested = config.configurationAt("doubleNested.nested"); assertEquals("nested3", nested.getString("a")); assertEquals(42, nested.getParent().getInt("atParent")); }
From source file:com.intuit.tank.vm.settings.ReportingConfig.java
/** * @return the products//from ww w . j a v a2s . co m */ public String getReaderClass() { String ret = DEFAULT_READER; if (config != null) { try { SubnodeConfiguration configurationAt = config.configurationAt(KEY_READER); String string = configurationAt.getString(""); if (StringUtils.isNotBlank(string)) { ret = string; } else { LOG.warn("Reader not configured. Using default of " + ret); } } catch (Exception e) { LOG.warn("Reader specified more than once. Using default of " + ret); } } return ret; }
From source file:com.intuit.tank.vm.settings.ReportingConfig.java
/** * @return the products/* w ww .java 2s. c om*/ */ public String getReporterClass() { String ret = DEFAULT_REPORTER; if (config != null) { try { SubnodeConfiguration configurationAt = config.configurationAt(KEY_REPORTER); String string = configurationAt.getString(""); if (StringUtils.isNotBlank(string)) { ret = string; } else { LOG.warn("Reporter not configured. Using default of " + ret); } } catch (Exception e) { LOG.warn("Reporter specified more than once. Using default of " + ret); } } return ret; }
From source file:com.versatus.jwebshield.DBHelper.java
public DBHelper(Configuration config) throws Exception { try {/*w w w . j a v a 2 s .c o m*/ Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); SubnodeConfiguration fields = ((XMLConfiguration) config).configurationAt("securityLock"); if (envCtx != null) { ds = (DataSource) envCtx.lookup(fields.getString("dbJndiName")); } } catch (javax.naming.NoInitialContextException ne) { } catch (Exception e) { logger.error("constructor", e); } }
From source file:com.github.technosf.posterer.transports.commons.CommonsConfiguratorPropertiesImpl.java
/** * // w w w. j a v a2s .c o m */ private void initializeRequestSet() { for (HierarchicalConfiguration c : config.configurationsAt("requests/request")) { int hashCode = Integer.parseInt((String) c.getRootNode().getAttributes("id").get(0).getValue()); SubnodeConfiguration request = getRequest(hashCode); RequestBean pdi = new RequestBean(request.getString("endpoint"), request.getString("payload"), request.getString("method"), request.getString("contentType"), request.getBoolean("base64"), request.getString("httpUser"), request.getString("httpPassword")); assert (hashCode == pdi.hashCode()); requestProperties.put(pdi.hashCode(), pdi); addEndpoint(pdi.getEndpoint()); } }
From source file:core.commonapp.server.data.RequiredDataReader.java
/** * Initialize data reader//from ww w. java 2s. c o m * * if there are relationships that need to be defined. In the xml define the * forgein relation first. Then reference the relation as the value of the * columns with ${RelationType.KeyValue}. The relation type is the class * name with no package. i.e. 'forgeinKey=${GeoType._STATE}' */ public void read(String filename) { try { log.debug("Reading data file {0}.", filename); XMLConfiguration reader = new XMLConfiguration(getClass().getResource(filename)); List<SubnodeConfiguration> records = reader.configurationsAt("record"); for (SubnodeConfiguration record : records) { String beanName = record.getString("[@bean]"); Object object = context.getBean(beanName); ConfigurationNode node = record.getRootNode(); List<ConfigurationNode> attributes = node.getAttributes(); // attempt to load from db, if found then use it to update // instead of a new object to insert Object dbObject = null; String key = record.getString("[@key]"); if (object instanceof Keyable && key != null) { Keyable keyable = (Keyable) object; // FIXME: Find existing record // KeyedCache cache = context.getBean(KeyedCache.class); // // // KeyedCacheStore<?> store = cache.getCacheStore(object.getClass()); // // // // // Object dao = context.getBean("defaultDao"); // dbObject = ((DefaultDao) dao).getEntityManager().createQuery(" from " + object.getClass() + " where key = " + key); if (dbObject != null) { log.debug("Found keyed object in database (dbObject={0}).", dbObject); // set the object to the one in the db so we can update the // fields with data from xml object = dbObject; } } for (ConfigurationNode attribute : attributes) { String name = attribute.getName(); String value = (String) attribute.getValue(); if (value.startsWith("$")) { // remove the wrapping ${...} // TODO: reg expr error check format value = value.substring(2); value = value.substring(0, value.length() - 1); log.debug("Static data reference found (refId={0})", value); // set method String methodName = "set" + name.substring(0, 1).toUpperCase() + name.substring(1); Method method = getMethod(object, methodName); method.invoke(object, referenceMap.get(value)); } else if ("%CURRENT_TIMESTAMP".equals(value)) { String methodName = "set" + name.substring(0, 1).toUpperCase() + name.substring(1); Method method = getMethod(object, methodName); method.invoke(object, new Date()); } else if ("refId".equals(name)) { referenceMap.put(value, object); log.debug("Adding declared reference object by id (refId={0},object={1}).", value, object); } else if (!"bean".equals(name)) { String methodName = "set" + name.substring(0, 1).toUpperCase() + name.substring(1); Method method = getMethod(object, methodName); method.invoke(object, value); } } // if the object is keyable then infer the reference if (object instanceof Keyable) { Keyable keyable = (Keyable) object; String refId = keyable.getClass().getSimpleName().replace("HibernateImpl", "") + "." + keyable.getKey(); referenceMap.put(refId, object); log.debug("Inferred reference for object (refId={0},object={1}).", refId, object); } // add object to list for saving dataObjects.add(object); } } catch (ConfigurationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } }
From source file:com.versatus.jwebshield.filter.SessionCheckFilter.java
/** * @see Filter#init(FilterConfig)// w w w . j a v a 2 s.c o m */ @Override public void init(FilterConfig fConfig) throws ServletException { String file = fConfig.getServletContext().getInitParameter("configFile"); if (file != null) { UrlExclusionList urlExList = new UrlExclusionList(); fConfig.getServletContext().setAttribute(SecurityConstant.SESSION_CHECK_URL_EXCL_LIST_ATTR_NAME, urlExList); try { XMLConfiguration config = new XMLConfiguration(file); SubnodeConfiguration fields = config.configurationAt("sessionCheck"); List<Object> exclusionList = fields.getList("sessionCheckUrlExclusions"); redirectPage = fields.getString("redirectPage"); attributeToCheck = fields.getString("attributeToCheck"); send401 = fields.getBoolean("send401"); if (exclusionList != null) { for (Object obj : exclusionList) { urlExList.addUrl((String) obj); } } // logger.info("init: sessionCheckUrlExclusions=" + // exclusionList); logger.info("init: sessionCheckUrlExclusionsList=" + urlExList); logger.info("init: redirectPage=" + redirectPage); } catch (Exception cex) { logger.error("init: unable to load configFile " + file, cex); } } else { logger.error("init: No configFile specified"); } }