Class ConfigurationPropertySources
java.lang.Object
org.springframework.boot.context.properties.source.ConfigurationPropertySources
Provides access to
ConfigurationPropertySources
.- Since:
- 2.0.0
- Author:
- Phillip Webb
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
attach
(Environment environment) Attach aConfigurationPropertySource
support to the specifiedEnvironment
.static ConfigurablePropertyResolver
createPropertyResolver
(MutablePropertySources propertySources) Create a newPropertyResolver
that resolves property values against an underlying set ofPropertySources
.static Iterable<ConfigurationPropertySource>
from
(Iterable<PropertySource<?>> sources) ReturnIterable
containing newConfigurationPropertySource
instances adapted from the given SpringPropertySources
.static Iterable<ConfigurationPropertySource>
from
(PropertySource<?> source) ReturnIterable
containing a single newConfigurationPropertySource
adapted from the given SpringPropertySource
.static Iterable<ConfigurationPropertySource>
get
(Environment environment) Return a set ofConfigurationPropertySource
instances that have previously beenattached
to theEnvironment
.static boolean
isAttachedConfigurationPropertySource
(PropertySource<?> propertySource) Determines if the specificPropertySource
is theConfigurationPropertySource
that wasattached
to theEnvironment
.
-
Method Details
-
createPropertyResolver
public static ConfigurablePropertyResolver createPropertyResolver(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
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
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
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
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
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
-