Class ConfigurationPropertySources

java.lang.Object
org.springframework.boot.context.properties.source.ConfigurationPropertySources

public final class ConfigurationPropertySources extends Object
Provides access to ConfigurationPropertySources.
Since:
2.0.0
  • Method Details

    • createPropertyResolver

      public static org.springframework.core.env.ConfigurablePropertyResolver createPropertyResolver(org.springframework.core.env.MutablePropertySources propertySources)
      Create a new PropertyResolver that resolves property values against an underlying set of PropertySources. Provides an ConfigurationPropertySource aware and optimized alternative to PropertySourcesPropertyResolver.
      Parameters:
      propertySources - the set of PropertySource 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 specific PropertySource is the ConfigurationPropertySource that was attached to the Environment.
      Parameters:
      propertySource - the property source to test
      Returns:
      true if this is the attached ConfigurationPropertySource
    • attach

      public static void attach(org.springframework.core.env.Environment environment)
      Attach a ConfigurationPropertySource support to the specified Environment. Adapts each PropertySource managed by the environment to a ConfigurationPropertySource and allows classic PropertySourcesPropertyResolver calls to resolve using configuration 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 of ConfigurableEnvironment)
      See Also:
    • get

      public static Iterable<ConfigurationPropertySource> get(org.springframework.core.env.Environment environment)
      Return a set of ConfigurationPropertySource instances that have previously been attached to the Environment.
      Parameters:
      environment - the source environment (must be an instance of ConfigurableEnvironment)
      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)
      Return Iterable containing a single new ConfigurationPropertySource adapted from the given Spring PropertySource.
      Parameters:
      source - the Spring property source to adapt
      Returns:
      an Iterable containing a single newly adapted SpringConfigurationPropertySource
    • from

      public static Iterable<ConfigurationPropertySource> from(Iterable<org.springframework.core.env.PropertySource<?>> sources)
      Return Iterable containing new ConfigurationPropertySource instances adapted from the given Spring PropertySources.

      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 a MutablePropertySources

      Parameters:
      sources - the Spring property sources to adapt
      Returns:
      an Iterable containing newly adapted SpringConfigurationPropertySource instances