Class ConfigurationPropertySources
- java.lang.Object
- org.springframework.boot.context.properties.source.ConfigurationPropertySources
public final class ConfigurationPropertySources extends Object
Provides access toConfigurationPropertySources
.- Since:
- 2.0.0
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
attach(org.springframework.core.env.Environment environment)
Attach aConfigurationPropertySource
support to the specifiedEnvironment
.static Iterable<ConfigurationPropertySource>
from(Iterable<org.springframework.core.env.PropertySource<?>> sources)
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 Detail
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(Environment)
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