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 voidattach(Environment environment) Attach aConfigurationPropertySourcesupport to the specifiedEnvironment.static ConfigurablePropertyResolvercreatePropertyResolver(MutablePropertySources propertySources) Create a newPropertyResolverthat resolves property values against an underlying set ofPropertySources.static Iterable<ConfigurationPropertySource>from(Iterable<PropertySource<?>> sources) ReturnIterablecontaining newConfigurationPropertySourceinstances adapted from the given SpringPropertySources.static Iterable<ConfigurationPropertySource>from(PropertySource<?> source) ReturnIterablecontaining a single newConfigurationPropertySourceadapted from the given SpringPropertySource.static Iterable<ConfigurationPropertySource>get(Environment environment) Return a set ofConfigurationPropertySourceinstances that have previously beenattachedto theEnvironment.static booleanisAttachedConfigurationPropertySource(PropertySource<?> propertySource) Determines if the specificPropertySourceis theConfigurationPropertySourcethat wasattachedto theEnvironment.
-
Method Details
-
createPropertyResolver
public static ConfigurablePropertyResolver createPropertyResolver(MutablePropertySources propertySources) Create a newPropertyResolverthat resolves property values against an underlying set ofPropertySources. Provides anConfigurationPropertySourceaware and optimized alternative toPropertySourcesPropertyResolver.- Parameters:
propertySources- the set ofPropertySourceobjects to use- Returns:
- a
ConfigurablePropertyResolverimplementation - Since:
- 2.5.0
-
isAttachedConfigurationPropertySource
Determines if the specificPropertySourceis theConfigurationPropertySourcethat wasattachedto theEnvironment.- Parameters:
propertySource- the property source to test- Returns:
trueif this is the attachedConfigurationPropertySource
-
attach
Attach aConfigurationPropertySourcesupport to the specifiedEnvironment. Adapts eachPropertySourcemanaged by the environment to aConfigurationPropertySourceand allows classicPropertySourcesPropertyResolvercalls to resolve usingconfiguration property names.The attached resolver will dynamically track any additions or removals from the underlying
Environmentproperty sources.- Parameters:
environment- the source environment (must be an instance ofConfigurableEnvironment)- See Also:
-
get
Return a set ofConfigurationPropertySourceinstances that have previously beenattachedto 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
ReturnIterablecontaining a single newConfigurationPropertySourceadapted from the given SpringPropertySource.- Parameters:
source- the Spring property source to adapt- Returns:
- an
Iterablecontaining a single newly adaptedSpringConfigurationPropertySource
-
from
ReturnIterablecontaining newConfigurationPropertySourceinstances 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
Iterablecontaining newly adaptedSpringConfigurationPropertySourceinstances
-