Java 类org.springframework.core.env.EnumerablePropertySource 实例源码

项目:configx    文件:PropertiesFileConfigItemPostProcessor.java   
/**
     * 处理配置属性文件中的属性源
     *
     * @param propertySource
     * @param propertySourceName
     */
    private void processPropertySource(EnumerablePropertySource<ConfigItemList> propertySource, String propertySourceName) {
        // 属性文件内容
        if (!propertySource.containsProperty(propertySourceName)) {
            return;
        }
        String content = propertySource.getProperty(propertySourceName).toString();
        if (StringUtils.isEmpty(content)) {
            return;
        }

        ConfigItemList configItemList = propertySource.getSource();
        if (configItemList == null) {
            return;
        }

        Properties properties = loadProperties(propertySourceName, content);
//      PropertiesPropertySource pps = new PropertiesPropertySource(propertySourceName, properties);
        if (properties != null && !properties.isEmpty()) {
            for (Map.Entry<?, ?> entry : properties.entrySet()) {
                if (entry.getKey() != null) {
                    configItemList.addItem(new ConfigItem(entry.getKey().toString(), entry.getValue().toString()));
                }
            }
        }
    }
项目:holon-core    文件:DefaultEnvironmentConfigPropertyProvider.java   
@Override
public Stream<String> getPropertyNames() throws UnsupportedOperationException {
    List<String> names = new LinkedList<>();
    if (ConfigurableEnvironment.class.isAssignableFrom(getEnvironment().getClass())) {
        MutablePropertySources propertySources = ((ConfigurableEnvironment) getEnvironment()).getPropertySources();
        if (propertySources != null) {
            Iterator<PropertySource<?>> i = propertySources.iterator();
            while (i.hasNext()) {
                PropertySource<?> source = i.next();
                if (source instanceof EnumerablePropertySource) {
                    String[] propertyNames = ((EnumerablePropertySource<?>) source).getPropertyNames();
                    if (propertyNames != null) {
                        names.addAll(Arrays.asList(propertyNames));
                    }
                }
            }
        }
    }
    return names.stream();
}
项目:taboola-cronyx    文件:EnvironmentUtil.java   
public static Properties findProps(ConfigurableEnvironment env, String prefix){
    Properties props = new Properties();

    for (PropertySource<?> source : env.getPropertySources()) {
        if (source instanceof EnumerablePropertySource) {
            EnumerablePropertySource<?> enumerable = (EnumerablePropertySource<?>) source;
            for (String name : enumerable.getPropertyNames()) {
                if (name.startsWith(prefix)) {
                    props.putIfAbsent(name, enumerable.getProperty(name));
                }
            }

        }
    }

    return props;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertySourceUtils.java   
/**
 * Return a Map of all values from the specified {@link PropertySources} that start
 * with a particular key.
 * @param propertySources the property sources to scan
 * @param rootPrefix a root prefix to be prepended to the keyPrefix (can be
 * {@code null})
 * @param keyPrefix the key prefixes to test
 * @return a map of all sub properties starting with the specified key prefixes.
 * @see #getSubProperties(PropertySources, String, String)
 */
public static Map<String, Object> getSubProperties(PropertySources propertySources,
        String rootPrefix, String keyPrefix) {
    RelaxedNames keyPrefixes = new RelaxedNames(keyPrefix);
    Map<String, Object> subProperties = new LinkedHashMap<String, Object>();
    for (PropertySource<?> source : propertySources) {
        if (source instanceof EnumerablePropertySource) {
            for (String name : ((EnumerablePropertySource<?>) source)
                    .getPropertyNames()) {
                String key = PropertySourceUtils.getSubKey(name, rootPrefix,
                        keyPrefixes);
                if (key != null && !subProperties.containsKey(key)) {
                    subProperties.put(key, source.getProperty(name));
                }
            }
        }
    }
    return Collections.unmodifiableMap(subProperties);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EnvironmentEndpoint.java   
@Override
public Map<String, Object> invoke() {
    Map<String, Object> result = new LinkedHashMap<String, Object>();
    result.put("profiles", getEnvironment().getActiveProfiles());
    for (Entry<String, PropertySource<?>> entry : getPropertySources().entrySet()) {
        PropertySource<?> source = entry.getValue();
        String sourceName = entry.getKey();
        if (source instanceof EnumerablePropertySource) {
            EnumerablePropertySource<?> enumerable = (EnumerablePropertySource<?>) source;
            Map<String, Object> properties = new LinkedHashMap<String, Object>();
            for (String name : enumerable.getPropertyNames()) {
                properties.put(name, sanitize(name, enumerable.getProperty(name)));
            }
            properties = postProcessSourceProperties(sourceName, properties);
            if (properties != null) {
                result.put(sourceName, properties);
            }
        }
    }
    return result;
}
项目:spring-boot-concourse    文件:PropertySourceUtils.java   
/**
 * Return a Map of all values from the specified {@link PropertySources} that start
 * with a particular key.
 * @param propertySources the property sources to scan
 * @param rootPrefix a root prefix to be prepended to the keyPrefix (can be
 * {@code null})
 * @param keyPrefix the key prefixes to test
 * @return a map of all sub properties starting with the specified key prefixes.
 * @see #getSubProperties(PropertySources, String, String)
 */
public static Map<String, Object> getSubProperties(PropertySources propertySources,
        String rootPrefix, String keyPrefix) {
    RelaxedNames keyPrefixes = new RelaxedNames(keyPrefix);
    Map<String, Object> subProperties = new LinkedHashMap<String, Object>();
    for (PropertySource<?> source : propertySources) {
        if (source instanceof EnumerablePropertySource) {
            for (String name : ((EnumerablePropertySource<?>) source)
                    .getPropertyNames()) {
                String key = PropertySourceUtils.getSubKey(name, rootPrefix,
                        keyPrefixes);
                if (key != null && !subProperties.containsKey(key)) {
                    subProperties.put(key, source.getProperty(name));
                }
            }
        }
    }
    return Collections.unmodifiableMap(subProperties);
}
项目:spring-boot-concourse    文件:EnvironmentEndpoint.java   
@Override
public Map<String, Object> invoke() {
    Map<String, Object> result = new LinkedHashMap<String, Object>();
    result.put("profiles", getEnvironment().getActiveProfiles());
    for (Entry<String, PropertySource<?>> entry : getPropertySources().entrySet()) {
        PropertySource<?> source = entry.getValue();
        String sourceName = entry.getKey();
        if (source instanceof EnumerablePropertySource) {
            EnumerablePropertySource<?> enumerable = (EnumerablePropertySource<?>) source;
            Map<String, Object> map = new LinkedHashMap<String, Object>();
            for (String name : enumerable.getPropertyNames()) {
                map.put(name, sanitize(name, enumerable.getProperty(name)));
            }
            result.put(sourceName, map);
        }
    }
    return result;
}
项目:camunda-bpm-cloud    文件:ConfigserverSpikeApplication.java   
private Map<String, Object> properties() {
  Map<String, Object> map = new HashMap();

  if (environment instanceof ConfigurableEnvironment) {
    for (PropertySource<?> propertySource : ((ConfigurableEnvironment) environment).getPropertySources()) {
      if (propertySource instanceof EnumerablePropertySource) {
        for (String key : ((EnumerablePropertySource) propertySource).getPropertyNames()) {
          if (StringUtils.startsWithAny(key, "spring", "eureka", "camunda.bpm")) {
            map.put(key, propertySource.getProperty(key));
          }
        }
      }
    }
  }

  return map;
}
项目:contestparser    文件:PropertySourceUtils.java   
/**
 * Return a Map of all values from the specified {@link PropertySources} that start
 * with a particular key.
 * @param propertySources the property sources to scan
 * @param rootPrefix a root prefix to be prepended to the keyPrefex (can be
 * {@code null})
 * @param keyPrefix the key prefixes to test
 * @return a map of all sub properties starting with the specified key prefixes.
 * @see #getSubProperties(PropertySources, String, String)
 */
public static Map<String, Object> getSubProperties(PropertySources propertySources,
        String rootPrefix, String keyPrefix) {
    RelaxedNames keyPrefixes = new RelaxedNames(keyPrefix);
    Map<String, Object> subProperties = new LinkedHashMap<String, Object>();
    for (PropertySource<?> source : propertySources) {
        if (source instanceof EnumerablePropertySource) {
            for (String name : ((EnumerablePropertySource<?>) source)
                    .getPropertyNames()) {
                String key = PropertySourceUtils.getSubKey(name, rootPrefix,
                        keyPrefixes);
                if (key != null && !subProperties.containsKey(key)) {
                    subProperties.put(key, source.getProperty(name));
                }
            }
        }
    }
    return Collections.unmodifiableMap(subProperties);
}
项目:contestparser    文件:EnvironmentEndpoint.java   
@Override
public Map<String, Object> invoke() {
    Map<String, Object> result = new LinkedHashMap<String, Object>();
    result.put("profiles", getEnvironment().getActiveProfiles());
    for (Entry<String, PropertySource<?>> entry : getPropertySources().entrySet()) {
        PropertySource<?> source = entry.getValue();
        String sourceName = entry.getKey();
        if (source instanceof EnumerablePropertySource) {
            EnumerablePropertySource<?> enumerable = (EnumerablePropertySource<?>) source;
            Map<String, Object> map = new LinkedHashMap<String, Object>();
            for (String name : enumerable.getPropertyNames()) {
                map.put(name, sanitize(name, enumerable.getProperty(name)));
            }
            result.put(sourceName, map);
        }
    }
    return result;
}
项目:indoqa-boot    文件:SystemInfo.java   
private static Map<String, SpringProperty> initSpringProperties(ConfigurableEnvironment springEnvironment) {
    Map<String, SpringProperty> springProperties = new HashMap<>();

    for (PropertySource<?> eachPropertySource : springEnvironment.getPropertySources()) {
        if (!(eachPropertySource instanceof EnumerablePropertySource)) {
            continue;
        }

        EnumerablePropertySource<?> enumerablePropertySource = (EnumerablePropertySource<?>) eachPropertySource;
        for (String prop : enumerablePropertySource.getPropertyNames()) {
            String sourceName = enumerablePropertySource.getName();

            SpringProperty springProperty = springProperties.get(prop);
            if (springProperty == null) {
                springProperty = new SpringProperty(prop);
            }

            springProperty.setValue(enumerablePropertySource.getProperty(prop), sourceName);
            springProperties.put(prop, springProperty);
        }
    }

    return filterSystemAndEnvironmentProperties(springProperties);
}
项目:muon-java    文件:AutoConfigurationFactoryBean.java   
@Override
public AutoConfiguration getObject() throws Exception {
    Assert.notNull(serviceName);
    String resolvedServiceName = embeddedValueResolver.resolveStringValue(serviceName);
    List<String> resolvedTags = resolveTags(tags);

    return MuonConfigBuilder
            .withServiceIdentifier(resolvedServiceName)
            .addWriter(autoConfig -> {
                ConfigurableEnvironment configurableEnvironment = (ConfigurableEnvironment) environment;
                for (PropertySource<?> propertySource : configurableEnvironment.getPropertySources()) {
                    if (propertySource instanceof EnumerablePropertySource) {
                        final EnumerablePropertySource enumerablePropertySource = (EnumerablePropertySource) propertySource;
                        for (String name : enumerablePropertySource.getPropertyNames()) {
                            autoConfig.getProperties().put(name, enumerablePropertySource.getProperty(name));
                        }
                    }
                }
            })
            .withTags(resolvedTags.toArray(new String[resolvedTags.size()]))
            .build();
}
项目:grails-boot    文件:GspAutoConfiguration.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void updateFlatConfig() {
    super.updateFlatConfig();
    if(this.environment instanceof ConfigurableEnvironment) {
        ConfigurableEnvironment configurableEnv = ((ConfigurableEnvironment)environment);
        for(PropertySource<?> propertySource : configurableEnv.getPropertySources()) {
            if(propertySource instanceof EnumerablePropertySource) {
                EnumerablePropertySource<?> enumerablePropertySource = (EnumerablePropertySource)propertySource;
                for(String propertyName : enumerablePropertySource.getPropertyNames()) {
                    flatConfig.put(propertyName, enumerablePropertySource.getProperty(propertyName));
                }
            }
        }
    }
}
项目:cloudbreak    文件:CloudbreakTest.java   
private Map<String, String> getAllKnownProperties(Environment env) {
    Map<String, String> rtn = new HashMap<>();
    if (env instanceof ConfigurableEnvironment) {
        for (PropertySource<?> propertySource : ((ConfigurableEnvironment) env).getPropertySources()) {
            if (propertySource instanceof EnumerablePropertySource) {
                LOGGER.info("processing property source ::: " + propertySource.getName());
                for (String key : ((EnumerablePropertySource) propertySource).getPropertyNames()) {
                    String value = propertySource.getProperty(key).toString();
                    if (StringUtils.isEmpty(value)) {
                        rtn.put(key, propertySource.getProperty(key).toString());
                    }
                }
            }
        }
    }
    return rtn;
}
项目:configx    文件:ConfigItemChangeEvent.java   
public ConfigItemChangeEvent(Object source, VersionPropertySource<ConfigItemList> versionPropertySource) {
    super(source);
    this.version = versionPropertySource.getVersion();

    EnumerablePropertySource<ConfigItemList> enumerablePropertySource = versionPropertySource.getSource();
    if (enumerablePropertySource != null) {
        ConfigItemList configItemList = enumerablePropertySource.getSource();
        if (configItemList != null) {
            this.itemList = configItemList.getItems();
        }
    }
}
项目:spring-cloud-discovery-version-filter    文件:PropertyTranslatorPostProcessor.java   
private MapPropertySource findZuulPropertySource(ConfigurableEnvironment environment) {
  for (PropertySource<?> propertySource : environment.getPropertySources()) {
    if (propertySource instanceof MapPropertySource) {
      for (String key : ((EnumerablePropertySource) propertySource).getPropertyNames()) {
        if (key.toLowerCase().startsWith(ZUUL_SERVICE_VERSIONS_ROOT)) {
          return (MapPropertySource) propertySource;
        }
      }
    }
  }
  return null;
}
项目:jetcache    文件:ConfigTree.java   
public Map<String, Object> getProperties() {
    Map<String, Object> m = new HashMap<>();
    for (PropertySource<?> source : environment.getPropertySources()) {
        if (source instanceof EnumerablePropertySource) {
            for (String name : ((EnumerablePropertySource<?>) source)
                    .getPropertyNames()) {
                if (name != null && name.startsWith(prefix)) {
                    String subKey = name.substring(prefix.length());
                    m.put(subKey, source.getProperty(name));
                }
            }
        }
    }
    return m;
}
项目:zipkin-sparkstreaming    文件:ZipkinStorageConsumerAutoConfiguration.java   
static Properties extractZipkinProperties(ConfigurableEnvironment env) {
  Properties properties = new Properties();
  Iterator<PropertySource<?>> it = env.getPropertySources().iterator();
  while (it.hasNext()) {
    PropertySource<?> next = it.next();
    if (!(next instanceof EnumerablePropertySource)) continue;
    EnumerablePropertySource source = (EnumerablePropertySource) next;
    for (String name : source.getPropertyNames()) {
      if (name.startsWith("zipkin")) properties.put(name, source.getProperty(name));
    }
  }
  return properties;
}
项目:rmap    文件:KafkaPropertyUtils.java   
/**
 * Returns the property key/value pairs found in {@code sources} and returns them in a {@code Map}.  Only instances
 * of {@code EnumerablePropertySource} are considered.  If {@code sources} contains other types of
 * {@code PropertySource}, they will be ignored, and <em>not</em> included in the returned {@code Map}.
 * <p>
 * If {@code prefix} is provided, only properties that start with the supplied prefix will be included in the
 * returned {@code Map}.  If {@code strip} is {@code true} and {@code prefix} is non-null, the {@code prefix} will
 * be stripped from the property key in the returned {@code Map}.
 * </p>
 *
 * @param sources {@code MutablePropertySources} whose key/value pairs are enumerated and placed into the returned
 *                {@code Map}
 * @param prefix only include properties whose key starts with the supplied prefix, may be {@code null}
 * @param strip if {@code true}, strip the {@code prefix} off of the property key in the returned {@code Map}
 * @return a {@code Map} containing the enumerated property keys and values from {@code sources}
 */
public static Map<String, Object> asMap(MutablePropertySources sources, String prefix, boolean strip) {
    Map<String, Object> props = new HashMap<>();

    filterEnumerablePropertySources(sources).forEach(source -> {
        if (!(source instanceof EnumerablePropertySource)) {
            return;
        }
        Stream.of(((EnumerablePropertySource)source).getPropertyNames())
                .filter(propName -> prefix == null || propName.startsWith(prefix))
                .peek(propName -> LOG.debug(
                        "Found kafka property prefix: [{}], property name: [{}]", prefix, propName))
                .collect(Collectors.toMap(
                        propName -> (prefix == null || !strip || !propName.startsWith(prefix)) ?
                                propName : propName.substring(prefix.length()),
                        source::getProperty,
                        (val1, val2) -> {
                            LOG.debug("Merging kafka property value [{}], [{}]: [{}] wins",
                                    val1, val2, val2);
                            return val2;
                        },
                        () -> props
                ))
                .forEach((key, value) -> LOG.debug("Kafka property: [{}]=[{}]",
                        key, (isNullValue(value)) ? "null" : value));
    });
    return props;
}
项目:rmap    文件:KafkaPropertyUtils.java   
/**
 * Filters the supplied {@code MutablePropertySources} for instances of {@code EnumerablePropertySource}, and
 * returns a new {@code MutablePropertySource} containing <em>only</em> {@code EnumerablePropertySource} sources.
 *
 * @param sources property sources that may contain instances of {@code EnumerablePropertySource}
 * @return property sources that contain <em>only</em> {@code EnumerablePropertySource}
 */
public static MutablePropertySources filterEnumerablePropertySources(MutablePropertySources sources) {
    MutablePropertySources enumerableSources = new MutablePropertySources();

    sources.forEach(source -> {
                if (source instanceof EnumerablePropertySource) {
                    enumerableSources.addLast(source);
                }
            });
    return enumerableSources;
}
项目:spring4-understanding    文件:InlinedPropertiesTestPropertySourceTests.java   
@Test
@SuppressWarnings("rawtypes")
public void propertyNameOrderingIsPreservedInEnvironment() {
    final String[] expectedPropertyNames = new String[] { "foo", "baz", "enigma", "x.y.z", "server.url",
        "key.value.1", "key.value.2", "key.value.3" };
    EnumerablePropertySource eps = (EnumerablePropertySource) env.getPropertySources().get(
        INLINED_PROPERTIES_PROPERTY_SOURCE_NAME);
    assertArrayEquals(expectedPropertyNames, eps.getPropertyNames());
}
项目:jeesuite-libs    文件:EnvironmentHelper.java   
public static Map<String, Object> getAllProperties(String prefix){
    init();
    if(environment == null)return null;
    MutablePropertySources propertySources = ((ConfigurableEnvironment)environment).getPropertySources();

    Map<String, Object> properties = new LinkedHashMap<String, Object>();
    for (PropertySource<?> source : propertySources) {
        if(source.getName().startsWith("servlet") || source.getName().startsWith("system")){
            continue;
        }
        if (source instanceof EnumerablePropertySource) {
            for (String name : ((EnumerablePropertySource<?>) source) .getPropertyNames()) {
                boolean match = StringUtils.isEmpty(prefix);
                if(!match){
                    match = name.startsWith(prefix);
                }
                if(match){                      
                    Object value = source.getProperty(name);
                    if(value != null){
                        properties.put(name, value);
                    }
                }
            }
        }
    }
    return Collections.unmodifiableMap(properties);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigFileApplicationListener.java   
ConfigurationPropertySources(Collection<PropertySource<?>> sources) {
    super(APPLICATION_CONFIGURATION_PROPERTY_SOURCE_NAME, sources);
    this.sources = sources;
    List<String> names = new ArrayList<String>();
    for (PropertySource<?> source : sources) {
        if (source instanceof EnumerablePropertySource) {
            names.addAll(Arrays.asList(
                    ((EnumerablePropertySource<?>) source).getPropertyNames()));
        }
    }
    this.names = names.toArray(new String[names.size()]);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertySourcesPropertyValues.java   
private void processPropertySource(PropertySource<?> source,
        PropertySourcesPropertyResolver resolver) {
    if (source instanceof CompositePropertySource) {
        processCompositePropertySource((CompositePropertySource) source, resolver);
    }
    else if (source instanceof EnumerablePropertySource) {
        processEnumerablePropertySource((EnumerablePropertySource<?>) source,
                resolver, this.includes);
    }
    else {
        processNonEnumerablePropertySource(source, resolver);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertySourcesPropertyValues.java   
private void processEnumerablePropertySource(EnumerablePropertySource<?> source,
        PropertySourcesPropertyResolver resolver,
        PropertyNamePatternsMatcher includes) {
    if (source.getPropertyNames().length > 0) {
        for (String propertyName : source.getPropertyNames()) {
            if (includes.matches(propertyName)) {
                Object value = getEnumerableProperty(source, resolver, propertyName);
                putIfAbsent(propertyName, value, source);
            }
        }
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertySourcesPropertyValues.java   
private Object getEnumerableProperty(EnumerablePropertySource<?> source,
        PropertySourcesPropertyResolver resolver, String propertyName) {
    try {
        return resolver.getProperty(propertyName, Object.class);
    }
    catch (RuntimeException ex) {
        // Probably could not resolve placeholders, ignore it here
        return source.getProperty(propertyName);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:YamlPropertySourceLoaderTests.java   
@Test
public void orderedItems() throws Exception {
    StringBuilder yaml = new StringBuilder();
    List<String> expected = new ArrayList<String>();
    for (char c = 'a'; c <= 'z'; c++) {
        yaml.append(c + ": value" + c + "\n");
        expected.add(String.valueOf(c));
    }
    ByteArrayResource resource = new ByteArrayResource(yaml.toString().getBytes());
    EnumerablePropertySource<?> source = (EnumerablePropertySource<?>) this.loader
            .load("resource", resource, null);
    assertThat(source).isNotNull();
    assertThat(source.getPropertyNames())
            .isEqualTo(expected.toArray(new String[] {}));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EnvironmentMvcEndpoint.java   
private void getNames(PropertySources propertySources, NameCallback callback) {
    for (PropertySource<?> propertySource : propertySources) {
        if (propertySource instanceof EnumerablePropertySource) {
            EnumerablePropertySource<?> source = (EnumerablePropertySource<?>) propertySource;
            for (String name : source.getPropertyNames()) {
                callback.addName(name);
            }
        }
    }
}
项目:spring-hocon-property-source    文件:HoconPropertySourceLoaderTest.java   
@Test
public void propertyParseIsEqualToYaml() throws Exception {
    HoconPropertySourceLoader hoconLoader = new HoconPropertySourceLoader();
    YamlPropertySourceLoader yamlLoader = new YamlPropertySourceLoader();

    EnumerablePropertySource hoconParse = loadProperties(hoconLoader, "/application.conf");
    EnumerablePropertySource yamlParse = loadProperties(yamlLoader, "/application.yaml");

    verifyPropertyKeysAreSame(hoconParse, yamlParse);
    verifyPropertyValuesAreSame(hoconParse, yamlParse);
}
项目:spring-hocon-property-source    文件:HoconPropertySourceLoaderTest.java   
private void verifyPropertyKeysAreSame(EnumerablePropertySource hoconParse, EnumerablePropertySource yamlParse) {
    String[] hoconProperties = hoconParse.getPropertyNames();
    Arrays.sort(hoconProperties);
    String[] yamlProperties = yamlParse.getPropertyNames();
    Arrays.sort(yamlProperties);

    assertThat(hoconProperties, is(yamlProperties));
}
项目:spring-boot-concourse    文件:ConfigFileApplicationListener.java   
ConfigurationPropertySources(Collection<PropertySource<?>> sources) {
    super(APPLICATION_CONFIGURATION_PROPERTY_SOURCE_NAME, sources);
    this.sources = sources;
    List<String> names = new ArrayList<String>();
    for (PropertySource<?> source : sources) {
        if (source instanceof EnumerablePropertySource) {
            names.addAll(Arrays.asList(
                    ((EnumerablePropertySource<?>) source).getPropertyNames()));
        }
    }
    this.names = names.toArray(new String[names.size()]);
}
项目:spring-boot-concourse    文件:PropertySourcesPropertyValues.java   
private void processPropertySource(PropertySource<?> source,
        PropertySourcesPropertyResolver resolver) {
    if (source instanceof CompositePropertySource) {
        processCompositePropertySource((CompositePropertySource) source, resolver);
    }
    else if (source instanceof EnumerablePropertySource) {
        processEnumerablePropertySource((EnumerablePropertySource<?>) source,
                resolver, this.includes);
    }
    else {
        processNonEnumerablePropertySource(source, resolver);
    }
}
项目:spring-boot-concourse    文件:PropertySourcesPropertyValues.java   
private void processEnumerablePropertySource(EnumerablePropertySource<?> source,
        PropertySourcesPropertyResolver resolver,
        PropertyNamePatternsMatcher includes) {
    if (source.getPropertyNames().length > 0) {
        for (String propertyName : source.getPropertyNames()) {
            if (includes.matches(propertyName)) {
                Object value = getEnumerableProperty(source, resolver, propertyName);
                putIfAbsent(propertyName, value, source);
            }
        }
    }
}
项目:spring-boot-concourse    文件:PropertySourcesPropertyValues.java   
private Object getEnumerableProperty(EnumerablePropertySource<?> source,
        PropertySourcesPropertyResolver resolver, String propertyName) {
    try {
        return resolver.getProperty(propertyName, Object.class);
    }
    catch (RuntimeException ex) {
        // Probably could not resolve placeholders, ignore it here
        return source.getProperty(propertyName);
    }
}
项目:spring-boot-concourse    文件:YamlPropertySourceLoaderTests.java   
@Test
public void orderedItems() throws Exception {
    StringBuilder yaml = new StringBuilder();
    List<String> expected = new ArrayList<String>();
    for (char c = 'a'; c <= 'z'; c++) {
        yaml.append(c + ": value" + c + "\n");
        expected.add(String.valueOf(c));
    }
    ByteArrayResource resource = new ByteArrayResource(yaml.toString().getBytes());
    EnumerablePropertySource<?> source = (EnumerablePropertySource<?>) this.loader
            .load("resource", resource, null);
    assertThat(source).isNotNull();
    assertThat(source.getPropertyNames())
            .isEqualTo(expected.toArray(new String[] {}));
}
项目:spring-boot-concourse    文件:EnvironmentMvcEndpoint.java   
private void getNames(PropertySources propertySources, NameCallback callback) {
    for (PropertySource<?> propertySource : propertySources) {
        if (propertySource instanceof EnumerablePropertySource) {
            EnumerablePropertySource<?> source = (EnumerablePropertySource<?>) propertySource;
            for (String name : source.getPropertyNames()) {
                callback.addName(name);
            }
        }
    }
}
项目:jasypt-spring-boot    文件:EncryptableEnumerablePropertySourceWrapper.java   
public EncryptableEnumerablePropertySourceWrapper(EnumerablePropertySource<T> delegate, EncryptablePropertyResolver resolver) {
    super(delegate.getName(), delegate.getSource());
    Assert.notNull(delegate, "PropertySource delegate cannot be null");
    Assert.notNull(resolver, "EncryptablePropertyResolver cannot be null");
    this.delegate = delegate;
    this.resolver = resolver;
}
项目:contestparser    文件:ConfigFileEnvironmentPostProcessor.java   
ConfigurationPropertySources(Collection<PropertySource<?>> sources) {
    super(NAME, sources);
    this.sources = sources;
    List<String> names = new ArrayList<String>();
    for (PropertySource<?> source : sources) {
        if (source instanceof EnumerablePropertySource) {
            names.addAll(Arrays.asList(
                    ((EnumerablePropertySource<?>) source).getPropertyNames()));
        }
    }
    this.names = names.toArray(new String[names.size()]);
}
项目:contestparser    文件:PropertySourcesPropertyValues.java   
private void processPropertySource(PropertySource<?> source,
        PropertySourcesPropertyResolver resolver) {
    if (source instanceof CompositePropertySource) {
        processCompositePropertySource((CompositePropertySource) source, resolver);
    }
    else if (source instanceof EnumerablePropertySource) {
        processEnumerablePropertySource((EnumerablePropertySource<?>) source,
                resolver, this.includes);
    }
    else {
        processNonEnumerablePropertySource(source, resolver);
    }
}
项目:contestparser    文件:PropertySourcesPropertyValues.java   
private void processEnumerablePropertySource(EnumerablePropertySource<?> source,
        PropertySourcesPropertyResolver resolver,
        PropertyNamePatternsMatcher includes) {
    if (source.getPropertyNames().length > 0) {
        for (String propertyName : source.getPropertyNames()) {
            if (includes.matches(propertyName)) {
                Object value = getEnumerableProperty(source, resolver, propertyName);
                putIfAbsent(propertyName, value, source);
            }
        }
    }
}