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

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigurationPropertiesBindingPostProcessor.java   
private PropertySources loadPropertySources(String[] locations,
        boolean mergeDefaultSources) {
    try {
        PropertySourcesLoader loader = new PropertySourcesLoader();
        for (String location : locations) {
            Resource resource = this.resourceLoader
                    .getResource(this.environment.resolvePlaceholders(location));
            String[] profiles = this.environment.getActiveProfiles();
            for (int i = profiles.length; i-- > 0;) {
                String profile = profiles[i];
                loader.load(resource, profile);
            }
            loader.load(resource);
        }
        MutablePropertySources loaded = loader.getPropertySources();
        if (mergeDefaultSources) {
            for (PropertySource<?> propertySource : this.propertySources) {
                loaded.addLast(propertySource);
            }
        }
        return loaded;
    }
    catch (IOException ex) {
        throw new IllegalStateException(ex);
    }
}
项目: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);
}
项目:spring-boot-concourse    文件:ConfigurationPropertiesBindingPostProcessor.java   
private PropertySources loadPropertySources(String[] locations,
        boolean mergeDefaultSources) {
    try {
        PropertySourcesLoader loader = new PropertySourcesLoader();
        for (String location : locations) {
            Resource resource = this.resourceLoader
                    .getResource(this.environment.resolvePlaceholders(location));
            String[] profiles = this.environment.getActiveProfiles();
            for (int i = profiles.length; i-- > 0;) {
                String profile = profiles[i];
                loader.load(resource, profile);
            }
            loader.load(resource);
        }
        MutablePropertySources loaded = loader.getPropertySources();
        if (mergeDefaultSources) {
            for (PropertySource<?> propertySource : this.propertySources) {
                loaded.addLast(propertySource);
            }
        }
        return loaded;
    }
    catch (IOException ex) {
        throw new IllegalStateException(ex);
    }
}
项目: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);
}
项目:contestparser    文件:ConfigurationPropertiesBindingPostProcessor.java   
private PropertySources deducePropertySources() {
    PropertySourcesPlaceholderConfigurer configurer = getSinglePropertySourcesPlaceholderConfigurer();
    if (configurer != null) {
        // Flatten the sources into a single list so they can be iterated
        return new FlatPropertySources(configurer.getAppliedPropertySources());
    }

    if (this.environment instanceof ConfigurableEnvironment) {
        MutablePropertySources propertySources = ((ConfigurableEnvironment) this.environment)
                .getPropertySources();
        return new FlatPropertySources(propertySources);
    }

    // empty, so not very useful, but fulfils the contract
    return new MutablePropertySources();
}
项目:contestparser    文件:ConfigurationPropertiesBindingPostProcessor.java   
private PropertySources loadPropertySources(String[] locations,
        boolean mergeDefaultSources) {
    try {
        PropertySourcesLoader loader = new PropertySourcesLoader();
        for (String location : locations) {
            Resource resource = this.resourceLoader
                    .getResource(this.environment.resolvePlaceholders(location));
            String[] profiles = this.environment.getActiveProfiles();
            for (int i = profiles.length; i-- > 0;) {
                String profile = profiles[i];
                loader.load(resource, profile);
            }
            loader.load(resource);
        }
        MutablePropertySources loaded = loader.getPropertySources();
        if (mergeDefaultSources) {
            for (PropertySource<?> propertySource : this.propertySources) {
                loaded.addLast(propertySource);
            }
        }
        return loaded;
    }
    catch (IOException ex) {
        throw new IllegalStateException(ex);
    }
}
项目: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);
}
项目:rmap    文件:KafkaPropertyUtils.java   
/**
 * Renders a {@code PropertySources} as a {@code Stream<PropertySource>}
 *
 * @param sources PropertySources
 * @return a {@code Stream} of {@code PropertySource}
 */
public static Stream<PropertySource<?>> asStream(PropertySources sources) {
    if (sources == null) {
        return Stream.empty();
    }
    Iterable<PropertySource<?>> iterable = sources::iterator;
    return StreamSupport.stream(iterable.spliterator(), false);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigurationPropertiesBindingPostProcessor.java   
private PropertySources deducePropertySources() {
    PropertySourcesPlaceholderConfigurer configurer = getSinglePropertySourcesPlaceholderConfigurer();
    if (configurer != null) {
        // Flatten the sources into a single list so they can be iterated
        return new FlatPropertySources(configurer.getAppliedPropertySources());
    }
    if (this.environment instanceof ConfigurableEnvironment) {
        MutablePropertySources propertySources = ((ConfigurableEnvironment) this.environment)
                .getPropertySources();
        return new FlatPropertySources(propertySources);
    }
    // empty, so not very useful, but fulfils the contract
    return new MutablePropertySources();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertySourcesPropertyValues.java   
/**
 * Create a new PropertyValues from the given PropertySources.
 * @param propertySources a PropertySources instance
 * @param nonEnumerableFallbackNames the property names to try in lieu of an
 * {@link EnumerablePropertySource}.
 * @param includes the property name patterns to include
 */
PropertySourcesPropertyValues(PropertySources propertySources,
        Collection<String> nonEnumerableFallbackNames,
        PropertyNamePatternsMatcher includes) {
    Assert.notNull(propertySources, "PropertySources must not be null");
    Assert.notNull(includes, "Includes must not be null");
    this.propertySources = propertySources;
    this.nonEnumerableFallbackNames = nonEnumerableFallbackNames;
    this.includes = includes;
    PropertySourcesPropertyResolver resolver = new PropertySourcesPropertyResolver(
            propertySources);
    for (PropertySource<?> source : propertySources) {
        processPropertySource(source, resolver);
    }
}
项目: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-boot-concourse    文件:ConfigurationPropertiesBindingPostProcessor.java   
private PropertySources deducePropertySources() {
    PropertySourcesPlaceholderConfigurer configurer = getSinglePropertySourcesPlaceholderConfigurer();
    if (configurer != null) {
        // Flatten the sources into a single list so they can be iterated
        return new FlatPropertySources(configurer.getAppliedPropertySources());
    }
    if (this.environment instanceof ConfigurableEnvironment) {
        MutablePropertySources propertySources = ((ConfigurableEnvironment) this.environment)
                .getPropertySources();
        return new FlatPropertySources(propertySources);
    }
    // empty, so not very useful, but fulfils the contract
    return new MutablePropertySources();
}
项目:spring-boot-concourse    文件:PropertySourcesPropertyValues.java   
/**
 * Create a new PropertyValues from the given PropertySources.
 * @param propertySources a PropertySources instance
 * @param nonEnumerableFallbackNames the property names to try in lieu of an
 * {@link EnumerablePropertySource}.
 * @param includes the property name patterns to include
 */
PropertySourcesPropertyValues(PropertySources propertySources,
        Collection<String> nonEnumerableFallbackNames,
        PropertyNamePatternsMatcher includes) {
    Assert.notNull(propertySources, "PropertySources must not be null");
    Assert.notNull(includes, "Includes must not be null");
    this.propertySources = propertySources;
    this.nonEnumerableFallbackNames = nonEnumerableFallbackNames;
    this.includes = includes;
    PropertySourcesPropertyResolver resolver = new PropertySourcesPropertyResolver(
            propertySources);
    for (PropertySource<?> source : propertySources) {
        processPropertySource(source, resolver);
    }
}
项目: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);
            }
        }
    }
}
项目:elastic-config    文件:ElasticConfigSourceFactory.java   
public static PropertySources create(ElasticConfig... elasticConfigs) {
    Preconditions.checkNotNull(elasticConfigs);
    final MutablePropertySources sources = new MutablePropertySources();
    for (ElasticConfig elasticConfig : elasticConfigs) {
        sources.addLast(new RegistryPropertySource(elasticConfig));
    }
    return sources;
}
项目:contestparser    文件:PropertySourcesPropertyValues.java   
/**
 * Create a new PropertyValues from the given PropertySources.
 * @param propertySources a PropertySources instance
 * @param nonEnumerableFallbackNames the property names to try in lieu of an
 * {@link EnumerablePropertySource}.
 * @param includes the property name patterns to include
 */
PropertySourcesPropertyValues(PropertySources propertySources,
        Collection<String> nonEnumerableFallbackNames,
        PropertyNamePatternsMatcher includes) {
    Assert.notNull(propertySources, "PropertySources must not be null");
    Assert.notNull(includes, "Includes must not be null");
    this.propertySources = propertySources;
    this.nonEnumerableFallbackNames = nonEnumerableFallbackNames;
    this.includes = includes;
    PropertySourcesPropertyResolver resolver = new PropertySourcesPropertyResolver(
            propertySources);
    for (PropertySource<?> source : propertySources) {
        processPropertySource(source, resolver);
    }
}
项目:contestparser    文件: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);
            }
        }
    }
}
项目:config-toolkit    文件:ConfigGroupSourceFactory.java   
public static PropertySources create(ConfigGroup... configGroups) {
    Preconditions.checkNotNull(configGroups);
    final MutablePropertySources sources = new MutablePropertySources();
    for (ConfigGroup configGroup : configGroups) {
        sources.addLast(new ConfigGroupResource(configGroup));
    }
    return sources;
}
项目:rmap    文件:FactoryState.java   
void setSources(PropertySources sources) {
    sources.forEach(source -> this.sources.addLast(source));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigurationPropertiesBindingPostProcessor.java   
FlatPropertySources(PropertySources propertySources) {
    this.propertySources = propertySources;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertySourcesBinder.java   
public void setPropertySources(PropertySources propertySources) {
    this.propertySources = propertySources;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertySourcesBinder.java   
public PropertySources getPropertySources() {
    return this.propertySources;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertySourcesBinder.java   
private static PropertySources createPropertySources(
        PropertySource<?> propertySource) {
    MutablePropertySources propertySources = new MutablePropertySources();
    propertySources.addLast(propertySource);
    return propertySources;
}
项目:java-platform    文件:ConfigurationPropertySourcesPlaceholderConfigurer.java   
public void setPropertySources(PropertySources propertySources) {
    this.propertySources = new MutablePropertySources(propertySources);
}
项目:java-platform    文件:ConfigurationPropertySourcesPlaceholderConfigurer.java   
public PropertySources getAppliedPropertySources() throws IllegalStateException {
    Assert.state(this.appliedPropertySources != null, "PropertySources have not get been applied");
    return this.appliedPropertySources;
}
项目:elastic-jobx    文件:PlaceholderResolved.java   
private PropertySourcesPropertyResolver getPropertyResolverBeforeSpring4(final PropertySourcesPlaceholderConfigurer placeholderConfigurer) 
        throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    Field field = placeholderConfigurer.getClass().getDeclaredField("propertySources");
    field.setAccessible(true);
    return new PropertySourcesPropertyResolver((PropertySources) field.get(placeholderConfigurer));
}
项目:ElasticJob    文件:PlaceholderResolved.java   
private PropertySourcesPropertyResolver getPropertyResolverBeforeSpring4(final PropertySourcesPlaceholderConfigurer placeholderConfigurer) throws ReflectiveOperationException {
    return new PropertySourcesPropertyResolver((PropertySources) PropertySourcesPlaceholderConfigurer.class.getField("propertySources").get(placeholderConfigurer));
}
项目:spring-boot-concourse    文件:ConfigurationPropertiesBindingPostProcessor.java   
FlatPropertySources(PropertySources propertySources) {
    this.propertySources = propertySources;
}
项目:spring-boot-concourse    文件:PropertySourcesBinder.java   
public void setPropertySources(PropertySources propertySources) {
    this.propertySources = propertySources;
}
项目:spring-boot-concourse    文件:PropertySourcesBinder.java   
public PropertySources getPropertySources() {
    return this.propertySources;
}
项目:spring-boot-concourse    文件:PropertySourcesBinder.java   
private static PropertySources createPropertySources(
        PropertySource<?> propertySource) {
    MutablePropertySources propertySources = new MutablePropertySources();
    propertySources.addLast(propertySource);
    return propertySources;
}
项目:elastic-config    文件:PlaceholderResolved.java   
private PropertySourcesPropertyResolver getPropertyResolverBeforeSpring4(
    final PropertySourcesPlaceholderConfigurer placeholderConfigurer) throws ReflectiveOperationException {
    return new PropertySourcesPropertyResolver((PropertySources) PropertySourcesPlaceholderConfigurer.class
        .getField(PropertySourcesEnum.PROPERTYSOURCES.getName()).get(placeholderConfigurer));
}
项目:contestparser    文件:ConfigurationPropertiesBindingPostProcessor.java   
FlatPropertySources(PropertySources propertySources) {
    this.propertySources = propertySources;
}
项目:parallel-test-runner    文件:ThreadSpecificValueBeanPostProcessor.java   
private PropertySourcesPropertyResolverExtension(PropertySources propertySources) {
    super(propertySources);
}
项目:crigtt    文件:PropertySourcesMessageSource.java   
public PropertySources load() throws IOException {
    MutablePropertySources propSources = new MutablePropertySources();
    propSources.addFirst(new PropertiesPropertySource(UUID.randomUUID().toString(), this.mergeProperties()));

    return propSources;
}
项目:lams    文件:PropertySourcesPlaceholderConfigurer.java   
/**
 * Returns the property sources that were actually applied during
 * {@link #postProcessBeanFactory(ConfigurableListableBeanFactory) post-processing}.
 * @return the property sources that were applied
 * @throws IllegalStateException if the property sources have not yet been applied
 * @since 4.0
 */
public PropertySources getAppliedPropertySources() throws IllegalStateException {
    Assert.state(this.appliedPropertySources != null, "PropertySources have not get been applied");
    return this.appliedPropertySources;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PropertySourcesPropertyValues.java   
/**
 * Create a new PropertyValues from the given PropertySources.
 * @param propertySources a PropertySources instance
 * @param includePatterns property name patterns to include from system properties and
 * environment variables
 * @param nonEnumerableFallbackNames the property names to try in lieu of an
 * {@link EnumerablePropertySource}.
 */
public PropertySourcesPropertyValues(PropertySources propertySources,
        Collection<String> includePatterns,
        Collection<String> nonEnumerableFallbackNames) {
    this(propertySources, nonEnumerableFallbackNames,
            new PatternPropertyNamePatternsMatcher(includePatterns));
}
项目:spring-boot-concourse    文件:PropertySourcesPropertyValues.java   
/**
 * Create a new PropertyValues from the given PropertySources.
 * @param propertySources a PropertySources instance
 * @param includePatterns property name patterns to include from system properties and
 * environment variables
 * @param nonEnumerableFallbackNames the property names to try in lieu of an
 * {@link EnumerablePropertySource}.
 */
public PropertySourcesPropertyValues(PropertySources propertySources,
        Collection<String> includePatterns,
        Collection<String> nonEnumerableFallbackNames) {
    this(propertySources, nonEnumerableFallbackNames,
            new PatternPropertyNamePatternsMatcher(includePatterns));
}
项目:contestparser    文件:PropertySourcesPropertyValues.java   
/**
 * Create a new PropertyValues from the given PropertySources.
 * @param propertySources a PropertySources instance
 * @param includePatterns property name patterns to include from system properties and
 * environment variables
 * @param nonEnumerableFallbackNames the property names to try in lieu of an
 * {@link EnumerablePropertySource}.
 */
public PropertySourcesPropertyValues(PropertySources propertySources,
        Collection<String> includePatterns,
        Collection<String> nonEnumerableFallbackNames) {
    this(propertySources, nonEnumerableFallbackNames,
            new PatternPropertyNamePatternsMatcher(includePatterns));
}
项目:lams    文件:PropertySourcesPlaceholderConfigurer.java   
/**
 * Customize the set of {@link PropertySources} to be used by this configurer.
 * Setting this property indicates that environment property sources and local
 * properties should be ignored.
 * @see #postProcessBeanFactory
 */
public void setPropertySources(PropertySources propertySources) {
    this.propertySources = new MutablePropertySources(propertySources);
}