private String getFromConfigSource(ConfigSource[] configSources, String key) { for (ConfigSource configSource : configSources) { if (configSource.getPropertyValue(key) != null) { return configSource.getConfigName(); } } return null; }
/** * Resolve all values for the given key, from all registered ConfigSources ordered by their * ordinal value in ascending ways. If more {@link ConfigSource}s have the same ordinal, their * order is undefined. * * @param key under which configuration is stored * @return List with all found property values, sorted in ascending order of their ordinal. * @see org.apache.deltaspike.core.spi.config.ConfigSource#getOrdinal() */ public static List<String> getAllPropertyValues(String key) { List<ConfigSource> appConfigSources = sortAscending(new ArrayList<ConfigSource>(Arrays.asList(getConfigSources()))); List<String> result = new ArrayList<String>(); String value; for (ConfigSource configSource : appConfigSources) { value = configSource.getPropertyValue(key); if (value != null) { value = filterConfigValue(key, value); if (!result.contains(value)) { result.add(value); } } } return result; }
/** * Resolve all values for the given key. * * @param key * * @return a List of all found property values, sorted by their ordinal in ascending order * * @see org.apache.deltaspike.core.spi.config.ConfigSource#getOrdinal() */ public static List<String> getAllPropertyValues(String key) { ConfigSource[] configSources = getConfigProvider().getConfig().getConfigSources(); List<String> result = new ArrayList<String>(); for (int i = configSources.length; i > 0; i--) { String value = configSources[i - 1].getPropertyValue(key); if (value != null) { value = filterConfigValue(key, value); if (!result.contains(value)) { result.add(value); } } } return result; }
/** * Resolve all values for the given key. * * @param key * * @return a List of all found property values, sorted by their ordinal in ascending order * * @see org.apache.deltaspike.core.spi.config.ConfigSource#getOrdinal() */ public static List<String> getAllPropertyValues(String key) { ConfigSource[] configSources = getConfigProvider().getConfig().getConfigSources(); List<String> result = new ArrayList<String>(); for (int i = configSources.length; i > 0; i--) { String value = configSources[i - 1].getPropertyValue(key); if (value != null) { value = filterConfigValue(key, value); if (!result.contains(value)) { result.add(value); } } } return result; }
private String getPropertyValue(String key) { String value; for (ConfigSource configSource : config.getConfigSources()) { value = configSource.getPropertyValue(key); if (value != null) { if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE, "found value {0} for key {1} in ConfigSource {2}.", new Object[]{config.filterConfigValue(key, value, true), key, configSource.getConfigName()}); } if (this.evaluateVariables) { value = resolveVariables(value); } return config.filterConfigValue(key, value, false); } if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINER, "NO value found for key {0} in ConfigSource {1}.", new Object[]{key, configSource.getConfigName()}); } } return null; }
/** * Resolve the property value by going through the list of configured {@link ConfigSource}s * and use the one with the highest priority. * * @param key the property key. * @return the configured property value from the {@link ConfigSource} with the highest ordinal or * null if there is no configured value for it. */ public static String getPropertyValue(String key) { ConfigSource[] appConfigSources = getConfigSources(); String value; for (ConfigSource configSource : appConfigSources) { value = configSource.getPropertyValue(key); if (value != null) { LOG.log(Level.FINE, "found value {0} for key {1} in ConfigSource {2}.", new Object[]{filterConfigValueForLog(key, value), key, configSource.getConfigName()}); return filterConfigValue(key, value); } LOG.log(Level.FINER, "NO value found for key {0} in ConfigSource {1}.", new Object[]{key, configSource.getConfigName()}); } return null; }