Class ConfigurationPropertySources
java.lang.Object
org.springframework.boot.context.properties.source.ConfigurationPropertySources
Provides access to
ConfigurationPropertySources
.- Since:
- 2.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
attach
(org.springframework.core.env.Environment environment) Attach aConfigurationPropertySource
support to the specifiedEnvironment
.static org.springframework.core.env.ConfigurablePropertyResolver
createPropertyResolver
(org.springframework.core.env.MutablePropertySources propertySources) Create a newPropertyResolver
that resolves property values against an underlying set ofPropertySources
.static Iterable<ConfigurationPropertySource>
ReturnIterable
containing newConfigurationPropertySource
instances adapted from the given SpringPropertySources
.static Iterable<ConfigurationPropertySource>
from
(org.springframework.core.env.PropertySource<?> source) ReturnIterable
containing a single newConfigurationPropertySource
adapted from the given SpringPropertySource
.static Iterable<ConfigurationPropertySource>
get
(org.springframework.core.env.Environment environment) Return a set ofConfigurationPropertySource
instances that have previously beenattached
to theEnvironment
.static boolean
isAttachedConfigurationPropertySource
(org.springframework.core.env.PropertySource<?> propertySource) Determines if the specificPropertySource
is theConfigurationPropertySource
that wasattached
to theEnvironment
.
-
Method Details
-
createPropertyResolver
public static org.springframework.core.env.ConfigurablePropertyResolver createPropertyResolver(org.springframework.core.env.MutablePropertySources propertySources) Create a newPropertyResolver
that resolves property values against an underlying set ofPropertySources
. Provides anConfigurationPropertySource
aware and optimized alternative toPropertySourcesPropertyResolver
.- Parameters:
propertySources
- the set ofPropertySource
objects to use- Returns:
- a
ConfigurablePropertyResolver
implementation - Since:
- 2.5.0
-
isAttachedConfigurationPropertySource
public static boolean isAttachedConfigurationPropertySource(org.springframework.core.env.PropertySource<?> propertySource) Determines if the specificPropertySource
is theConfigurationPropertySource
that wasattached
to theEnvironment
.- Parameters:
propertySource
- the property source to test- Returns:
true
if this is the attachedConfigurationPropertySource
-
attach
public static void attach(org.springframework.core.env.Environment environment) Attach aConfigurationPropertySource
support to the specifiedEnvironment
. Adapts eachPropertySource
managed by the environment to aConfigurationPropertySource
and allows classicPropertySourcesPropertyResolver
calls to resolve usingconfiguration property names
.The attached resolver will dynamically track any additions or removals from the underlying
Environment
property sources.- Parameters:
environment
- the source environment (must be an instance ofConfigurableEnvironment
)- See Also:
-
get
public static Iterable<ConfigurationPropertySource> get(org.springframework.core.env.Environment environment) Return a set ofConfigurationPropertySource
instances that have previously beenattached
to theEnvironment
.- Parameters:
environment
- the source environment (must be an instance ofConfigurableEnvironment
)- Returns:
- an iterable set of configuration property sources
- Throws:
IllegalStateException
- if not configuration property sources have been attached
-
from
public static Iterable<ConfigurationPropertySource> from(org.springframework.core.env.PropertySource<?> source) ReturnIterable
containing a single newConfigurationPropertySource
adapted from the given SpringPropertySource
.- Parameters:
source
- the Spring property source to adapt- Returns:
- an
Iterable
containing a single newly adaptedSpringConfigurationPropertySource
-
from
public static Iterable<ConfigurationPropertySource> from(Iterable<org.springframework.core.env.PropertySource<?>> sources) ReturnIterable
containing newConfigurationPropertySource
instances adapted from the given SpringPropertySources
.This method will flatten any nested property sources and will filter all
stub property sources
. Updates to the underlying source, identified by changes in the sources returned by its iterator, will be automatically tracked. The underlying source should be thread safe, for example aMutablePropertySources
- Parameters:
sources
- the Spring property sources to adapt- Returns:
- an
Iterable
containing newly adaptedSpringConfigurationPropertySource
instances
-