List of usage examples for org.apache.commons.configuration Configuration getKeys
Iterator getKeys();
From source file:com.amazon.janusgraph.TestGraphUtil.java
public WriteConfiguration appendClusterPartitionsAndStores(final BackendDataModel model, final WriteConfiguration config, final List<String> storeNames, final int janusGraphClusterPartitions) { final Configuration baseconfig = createTestConfig(model); final Iterator<String> it = baseconfig.getKeys(); while (it.hasNext()) { final String key = it.next(); config.set(key, baseconfig.getProperty(key)); }/*ww w. jav a 2 s . c o m*/ Preconditions.checkArgument(janusGraphClusterPartitions > 0); if (janusGraphClusterPartitions > 1) { config.set("cluster.max-partitions", Integer.toString(janusGraphClusterPartitions)); } for (String store : storeNames) { final String prefix = "storage.dynamodb.stores." + store; TestGraphUtil.configureStore(model.name(), provisionedReadAndWriteTps, config, isUnlimitedIops(), prefix); } return config; }
From source file:br.gov.frameworkdemoiselle.internal.configuration.JDBCConfigValueExtractor.java
@Override public Object getValue(String prefix, String key, Field field, Configuration configuration) throws Exception { JDBCConfigurationStore value = null; String regexp = "^(" + prefix + ")((.+)\\.)?(" + key + ")$"; Pattern pattern = Pattern.compile(regexp); for (Iterator<String> iter = configuration.getKeys(); iter.hasNext();) { String iterKey = iter.next(); Matcher matcher = pattern.matcher(iterKey); if (matcher.matches()) { String confKey = matcher.group(1) + (matcher.group(2) == null ? "" : matcher.group(2)) + matcher.group(4);//from ww w. j a v a 2 s . c om if (value == null) { value = new JDBCConfigurationStore(); } String mapKey = matcher.group(3) == null ? "default" : matcher.group(3); value.put(mapKey, configuration.getString(confKey)); } } return value; }
From source file:br.gov.frameworkdemoiselle.internal.implementation.ConfigurationMapValueExtractor.java
@Override public Object getValue(String prefix, String key, Field field, Configuration configuration) throws Exception { Map<String, Object> value = null; String regexp = "^(" + prefix + ")(" + key + ")(\\.(\\w+))?$"; Pattern pattern = Pattern.compile(regexp); for (Iterator<String> iter = configuration.getKeys(); iter.hasNext();) { String iterKey = iter.next(); Matcher matcher = pattern.matcher(iterKey); if (matcher.matches()) { String confKey = matcher.group(1) + matcher.group(2) + (matcher.group(3) != null ? matcher.group(3) : ""); /*matcher.group(1) + (matcher.group(2) == null ? "" : matcher.group(2)) + matcher.group(4);*/ if (value == null) { value = new HashMap<String, Object>(); }//from w w w . j av a2 s .co m String mapKey = matcher.group(4) == null ? "default" : matcher.group(4); value.put(mapKey, configuration.getString(confKey)); } } return value; }
From source file:com.processpuzzle.application.configuration.domain.PropertyContext.java
public Properties getProperties(String key) { Configuration subConfiguration = configuration.configurationAt(key); Properties properties = new Properties(); for (Iterator<?> iter = subConfiguration.getKeys(); iter.hasNext();) { String propertyKey = (String) iter.next(); String propertyValue = subConfiguration.getString(propertyKey); properties.put(propertyKey.replace('/', '.'), propertyValue); }/*from w ww. j a va2 s . co m*/ return properties; }
From source file:dk.itst.oiosaml.sp.develmode.DevelModeImpl.java
private Map<String, String[]> getAttributes(String user, Configuration conf) { String prefix = "oiosaml-sp.develmode." + user + "."; Map<String, String[]> attributes = new HashMap<String, String[]>(); Iterator<?> i = conf.getKeys(); while (i.hasNext()) { String key = (String) i.next(); if (key.startsWith(prefix)) { String attr = key.substring(prefix.length()); String[] value = conf.getStringArray(key); attributes.put(attr, value); }/*from ww w. j a v a2 s .c om*/ } return attributes; }
From source file:com.nokia.ant.taskdefs.AntConfigurationTask.java
private void importFile(final File file) { try {//www. j a v a 2s . c om String filename = file.getName(); Configuration config = null; if (filename.endsWith(".txt")) { config = new PropertiesConfiguration(file); } else if (filename.endsWith(".xml")) { config = new XMLConfiguration(file); } Iterator keysIter = config.getKeys(); while (keysIter.hasNext()) { String key = (String) keysIter.next(); getProject().setProperty(key, config.getString(key)); } } catch (ConfigurationException e) { throw new BuildException("Not able to import the ANT file " + e.getMessage()); } }
From source file:at.newmedialab.ldpath.backend.linkeddata.AbstractLDBackend.java
/** * Initialise a new sesame backend. Repository needs to be set using setRepository. *///from www .j ava 2 s .co m protected AbstractLDBackend() { ldCache = new LDCache(this); try { Configuration config = new PropertiesConfiguration("endpoints.properties"); HashSet<String> endpointNames = new HashSet<String>(); for (Iterator<String> it = config.getKeys(); it.hasNext();) { String key = it.next(); String[] components = key.split("\\."); if (components.length > 1) { endpointNames.add(components[0]); } } for (String endpointName : endpointNames) { String prefix = config.getString(endpointName + ".prefix", ""); String kind = config.getString(endpointName + ".kind", ""); String endpointUrl = config.getString(endpointName + ".endpoint", ""); String mimetype = config.getString(endpointName + ".mimetype", ""); long expiry = config.getLong(endpointName + ".expiry", (long) 86400); Endpoint.EndpointType type; try { type = Endpoint.EndpointType.valueOf(kind.toUpperCase()); } catch (Exception e) { type = Endpoint.EndpointType.LINKEDDATA; } if (prefix != null && prefix.startsWith(Endpoint.REGEX_INDICATOR)) { // Check for valid Regex try { Pattern.compile(prefix.substring(Endpoint.REGEX_INDICATOR.length())); } catch (PatternSyntaxException pse) { log.error("invalid regexp pattern in endpoint '{}' prefix definition: {}", endpointName, prefix); } } if (endpointUrl != null) { endpointUrl = endpointUrl.replace('<', '{').replace('>', '}'); } else { endpointUrl = ""; } Endpoint endpoint = new Endpoint(endpointName, type, prefix, endpointUrl, mimetype, expiry); log.info("Registering LD Cache Endpoint \"{}\"", endpointName); registerEndpoint(endpoint); } } catch (ConfigurationException e) { log.warn( "could not load configuration file endpoints.properties from current directory, home directory, or classpath"); } }
From source file:io.servicecomb.springboot.starter.configuration.CseEndpoint.java
private void append(Map<String, Object> map, Configuration config) { if (config instanceof ConfigurableEnvironmentConfiguration) { return;/*from w w w.j av a 2 s . co m*/ } if (config instanceof SystemConfiguration) { return; } if (config instanceof EnvironmentConfiguration) { return; } for (Iterator<String> iter = config.getKeys(); iter.hasNext();) { String key = iter.next(); map.put(key, config.getProperty(key)); } }
From source file:com.netflix.config.ConcurrentMapConfigurationTest.java
@Test public void testSubset() { Map<String, String> properties = new HashMap<String, String>(); properties.put("a", "x.y.a"); properties.put("b", "x.y.b"); properties.put("c", "x.y.c"); ConcurrentMapConfiguration config = new ConcurrentMapConfiguration(); for (String prop : properties.values()) { config.addProperty(prop, prop);/* w ww .j av a2 s. c o m*/ } Configuration subconfig = config.subset("x.y"); Set<String> subsetKeys = new HashSet<String>(); for (Iterator<String> i = subconfig.getKeys(); i.hasNext();) { String key = i.next(); subsetKeys.add(key); assertEquals(properties.get(key), subconfig.getString(key)); } assertEquals(properties.keySet(), subsetKeys); }
From source file:com.evolveum.midpoint.init.ConfigurationLoadTest.java
@Test(enabled = false) public void t03complexConfigTest() { LOGGER.info("---------------- complexConfigTest -----------------"); System.setProperty("midpoint.home", "target/midPointHome/"); StartupConfiguration sc = new StartupConfiguration(); assertNotNull(sc);/* w ww .j a va 2 s.c o m*/ sc.init(); Configuration c = sc.getConfiguration("midpoint"); assertEquals(c.getString("repository.repositoryServiceFactoryClass"), "com.evolveum.midpoint.repo.xml.XmlRepositoryServiceFactory"); @SuppressWarnings("unchecked") Iterator<String> i = c.getKeys(); while (i.hasNext()) { String key = i.next(); LOGGER.info(" " + key + " = " + c.getString(key)); } assertEquals(c.getString("repository.serverPath"), "target/midPointHome/"); //cleanup System.clearProperty("midpoint.home"); }