public static AbstractConfiguration convertEnvVariable(AbstractConfiguration source) { Iterator<String> keys = source.getKeys(); while (keys.hasNext()) { String key = keys.next(); String[] separatedKey = key.split(CONFIG_KEY_SPLITER); if (separatedKey.length == 1) { continue; } String newKey = String.join(".", separatedKey); source.addProperty(newKey, source.getProperty(key)); } return source; }
@Override protected Properties mergeProperties() throws IOException { Properties properties = super.mergeProperties(); AbstractConfiguration config = ConfigurationManager.getConfigInstance(); Iterator<String> iter = config.getKeys(); while (iter.hasNext()) { String key = iter.next(); Object value = config.getProperty(key); properties.put(key, value); } return properties; }
private static void duplicateCseConfigToServicecomb(AbstractConfiguration source) { Iterator<String> keys = source.getKeys(); while (keys.hasNext()) { String key = keys.next(); if (!key.startsWith(CONFIG_CSE_PREFIX)) { continue; } String servicecombKey = CONFIG_SERVICECOMB_PREFIX + key.substring(key.indexOf(".") + 1); if (!source.containsKey(servicecombKey)) { source.addProperty(servicecombKey, source.getProperty(key)); } else { LOGGER .warn( "Key {} with an ambiguous item {} exists, it's recommended to use only one of them.", key, servicecombKey); } } }
@Override public Iterator<String> getKeys() { return config.getKeys(); }
/** * {@inheritDoc} This implementation returns keys that either match the * prefix or start with the prefix followed by a dot ('.'). So the call * {@code getKeys("db");} will find the keys {@code db}, * {@code db.user}, or {@code db.password}, but not the key * {@code dbdriver}. */ public Iterator<String> getKeys(String prefix) { return new PrefixedKeysIterator(getKeys(), prefix); }
/** * {@inheritDoc} This implementation returns keys that either match the * prefix or start with the prefix followed by a dot ('.'). So the call * {@code getKeys("db");} will find the keys {@code db}, * {@code db.user}, or {@code db.password}, but not the key * {@code dbdriver}. */ public Iterator<String> getKeys(String prefix) { return new PrefixedKeysIterator(getKeys(), prefix); }
/** * Get the list of the keys contained in the sub configurations that match the * specified prefix. * */ @Override public Iterator<String> getKeys(String prefix) { Set<String> keys = new LinkedHashSet<String>(); for (Iterator<String> it = overrideProperties.getKeys(prefix); it.hasNext();) { keys.add(it.next()); } for (Configuration config : configList) { for (Iterator<String> it = config.getKeys(prefix); it.hasNext();) { keys.add(it.next()); } } return keys.iterator(); }
public static AbstractConfiguration convertEnvVariable(AbstractConfiguration source) { Iterator<String> keys = source.getKeys(); while (keys.hasNext()) { String key = keys.next(); String[] separatedKey = key.split(CONFIG_KEY_SPLITER); if (separatedKey.length == 1) { continue; } String newKey = String.join(".", separatedKey); source.addProperty(newKey, source.getProperty(key)); } return source; }
/** * Get the list of the keys contained in the sub configurations that match the * specified prefix. * */ @Override public Iterator<String> getKeys(String prefix) { Set<String> keys = new LinkedHashSet<String>(); for (Iterator<String> it = overrideProperties.getKeys(prefix); it.hasNext();) { keys.add(it.next()); } for (Configuration config : configList) { for (Iterator<String> it = config.getKeys(prefix); it.hasNext();) { keys.add(it.next()); } } return keys.iterator(); }
private static Map<String, Object> toMap(Config config) { AbstractConfiguration configuration = config.getConfiguration(); Iterator<String> keys = configuration.getKeys(); Map<String, Object> result = Maps.newHashMap(); while (keys.hasNext()) { String key = keys.next(); result.put(key, configuration.getString(key)); } return result; } }
@Override protected Properties mergeProperties() throws IOException { Properties properties = super.mergeProperties(); AbstractConfiguration config = ConfigurationManager.getConfigInstance(); Iterator<String> iter = config.getKeys(); while (iter.hasNext()) { String key = iter.next(); Object value = config.getProperty(key); properties.put(key, value); } return properties; }
private static void duplicateCseConfigToServicecomb(AbstractConfiguration source) { Iterator<String> keys = source.getKeys(); while (keys.hasNext()) { String key = keys.next(); if (!key.startsWith(CONFIG_CSE_PREFIX)) { continue; } String servicecombKey = CONFIG_SERVICECOMB_PREFIX + key.substring(key.indexOf(".") + 1); if (!source.containsKey(servicecombKey)) { source.addProperty(servicecombKey, source.getProperty(key)); } else { LOGGER .warn( "Key {} with an ambiguous item {} exists, it's recommended to use only one of them.", key, servicecombKey); } } }
private static Map<String, Object> createPropertiesMap() { Properties properties = new Properties(); Iterator<String> iter = getConfigInstance().getKeys(JERSEY_ROOT_PACKAGE); while (iter.hasNext()) { String key = iter.next(); properties.setProperty(key, getConfigInstance().getString(key)); } return new TypeSafePropertiesDelegate(properties); }
private static Map<String, Object> createPropertiesMap() { Properties properties = new Properties(); Iterator<String> iter = getConfigInstance().getKeys(JERSEY_ROOT_PACKAGE); while (iter.hasNext()) { String key = iter.next(); properties.setProperty(key, getConfigInstance().getString(key)); } return new TypeSafePropertiesDelegate(properties); }
/** * Get all the keys contained by sub configurations. * * @throws ConcurrentModificationException if concurrent modification happens on any sub configuration * when it is iterated to get all the keys * */ public Iterator<String> getKeys() throws ConcurrentModificationException { Set<String> keys = new LinkedHashSet<String>(); for (Iterator<String> it = overrideProperties.getKeys(); it.hasNext();) { keys.add(it.next()); } for (Configuration config : configList) { for (Iterator<String> it = config.getKeys(); it.hasNext();) { try { keys.add(it.next()); } catch (ConcurrentModificationException e) { logger.error("unexpected exception when iterating the keys for configuration " + config + " with name " + getNameForConfiguration(config)); throw e; } } } return keys.iterator(); }
private static Map<String, Object> createPropertiesMap() { Properties properties = new Properties(); Iterator<String> iter = getConfigInstance().getKeys(JERSEY_ROOT_PACKAGE); while (iter.hasNext()) { String key = iter.next(); properties.setProperty(key, getConfigInstance().getString(key)); } return new TypeSafePropertiesDelegate(properties); }
@Override public String[] getPropertyNames() { return Iterators.toArray(ConfigurationManager.getConfigInstance().getKeys(), String.class); }
for (Iterator<String> it = getKeys(); it.hasNext();)
@Test public void testEmpty() { final Config emptyConfig = Config.getEmptyConfig(); Assert.assertNotNull(emptyConfig); Assert.assertFalse(emptyConfig.getConfiguration().getKeys().hasNext()); }
@Test public void testEmpty() { final Config emptyConfig = Config.getEmptyConfig(); Assert.assertNotNull(emptyConfig); Assert.assertFalse(emptyConfig.getConfiguration().getKeys().hasNext()); } }