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; }
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); } } }
/** * Add the property with the <em>container configuration</em>. * <b>Warning: </b>{@link #getProperty(String)} on this key may not return the same value set by this method * if there is any other configuration that contain the same property and is in front of the * <em>container configuration</em> in the configurations list. */ @Override public void addProperty(String key, Object value) { containerConfiguration.addProperty(key, value); }
/** * Add the property with the <em>container configuration</em>. * <b>Warning: </b>{@link #getProperty(String)} on this key may not return the same value set by this method * if there is any other configuration that contain the same property and is in front of the * <em>container configuration</em> in the configurations list. */ @Override public void addProperty(String key, Object value) { containerConfiguration.addProperty(key, value); }
/** * Calls <code>config.addrProperty()</code>. If the underlying configuration * is {@link ConcurrentCompositeConfiguration}, it calls {@link ConcurrentCompositeConfiguration#setOverrideProperty(String, Object)} * instead. */ @Override public void addProperty(String key, String value) { if (config instanceof ConcurrentCompositeConfiguration) { ((ConcurrentCompositeConfiguration) config).setOverrideProperty(key, value); } else { config.addProperty(key, value); } }
/** * Calls <code>config.addrProperty()</code>. If the underlying configuration * is {@link ConcurrentCompositeConfiguration}, it calls {@link ConcurrentCompositeConfiguration#setOverrideProperty(String, Object)} * instead. */ @Override public void addProperty(String key, String value) { if (config instanceof ConcurrentCompositeConfiguration) { ((ConcurrentCompositeConfiguration) config).setOverrideProperty(key, value); } else { config.addProperty(key, value); } }
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; }
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 List<String> getServices() { Set<String> applications = new LinkedHashSet<>(); for (URL provider : getUrls()) { String application = provider.getParameter("application"); Set<String> hosts = new LinkedHashSet<>(); for (ServiceInstance serviceInstance : getInstances(application)) { String scheme = "http://"; if (serviceInstance.isSecure()) { scheme = "https://"; } String host = scheme + serviceInstance.getHost() + ":" + serviceInstance.getPort(); hosts.add(host); } if (logger.isDebugEnabled()) { logger.debug(application + ".ribbon.listOfServers = " + StringUtils.join(hosts, ",")); } ConfigurationManager.getConfigInstance() .addProperty(application + ".ribbon.listOfServers", StringUtils.join(hosts, ",")); applications.add(application); } return new ArrayList<>(applications); }
/** * Adds a property to this configuration. This implementation will * temporarily disable list delimiter parsing, so that even if the value * contains the list delimiter, only a single record will be written into * the managed table. The implementation of {@code getProperty()} * will take care about delimiters. So list delimiters are fully supported * by {@code DatabaseConfiguration}, but internally treated a bit * differently. * * @param key the key of the new property * @param value the value to be added */ @Override public void addProperty(String key, Object value) { boolean parsingFlag = isDelimiterParsingDisabled(); try { if (value instanceof String) { // temporarily disable delimiter parsing setDelimiterParsingDisabled(true); } super.addProperty(key, value); } finally { setDelimiterParsingDisabled(parsingFlag); } }
/** * Adds a property to this configuration. This implementation will * temporarily disable list delimiter parsing, so that even if the value * contains the list delimiter, only a single record will be written into * the managed table. The implementation of {@code getProperty()} * will take care about delimiters. So list delimiters are fully supported * by {@code DatabaseConfiguration}, but internally treated a bit * differently. * * @param key the key of the new property * @param value the value to be added */ @Override public void addProperty(String key, Object value) { boolean parsingFlag = isDelimiterParsingDisabled(); try { if (value instanceof String) { // temporarily disable delimiter parsing setDelimiterParsingDisabled(true); } super.addProperty(key, value); } finally { setDelimiterParsingDisabled(parsingFlag); } }
public void setProperty(String key, Object value) { fireEvent(EVENT_SET_PROPERTY, key, value, true); setDetailEvents(false); try { clearProperty(key); addProperty(key, value); } finally { setDetailEvents(true); } fireEvent(EVENT_SET_PROPERTY, key, value, false); }
public void setProperty(String key, Object value) { fireEvent(EVENT_SET_PROPERTY, key, value, true); setDetailEvents(false); try { clearProperty(key); addProperty(key, value); } finally { setDetailEvents(true); } fireEvent(EVENT_SET_PROPERTY, key, value, false); }
@Test public void testDataStorage() throws IllegalDataStorageTypeException, IllegalDataStorageException { DataStorage dataStorage = DataStorageManager.newDataStorage("test"); assert dataStorage instanceof TestDataStorage; // get eagle.storage.type (value: test) from src/test/resources/application.conf DataStorage dataStorage2 = DataStorageManager.getDataStorageByEagleConfig(); assert dataStorage2 instanceof TestDataStorage; AbstractConfiguration configuration = new CombinedConfiguration(); configuration.addProperty(DataStorageManager.EAGLE_STORAGE_TYPE,"test"); DataStorage dataStorage3 = DataStorageManager.newDataStorage(configuration); assert dataStorage3 instanceof TestDataStorage; Properties properties = new Properties(); properties.put(DataStorageManager.EAGLE_STORAGE_TYPE, "test"); DataStorage dataStorage4 = DataStorageManager.newDataStorage(properties); assert dataStorage4 instanceof TestDataStorage; } }