org.springframework.boot.env

Class PropertySourcesLoader



  • public class PropertySourcesLoader
    extends Object
    Utility that can be used to MutablePropertySources using PropertySourceLoaders.
    Author:
    Phillip Webb
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      Set<String> getAllFileExtensions()
      Returns all file extensions that could be loaded.
      org.springframework.core.env.MutablePropertySources getPropertySources()
      Return the MutablePropertySources being loaded.
      org.springframework.core.env.PropertySource<?> load(org.springframework.core.io.Resource resource)
      Load the specified resource (if possible) and add it as the first source.
      org.springframework.core.env.PropertySource<?> load(org.springframework.core.io.Resource resource, String profile)
      Load the profile-specific properties from the specified resource (if any) and add it as the first source.
      org.springframework.core.env.PropertySource<?> load(org.springframework.core.io.Resource resource, String name, String profile)
      Load the profile-specific properties from the specified resource (if any), give the name provided and add it as the first source.
      org.springframework.core.env.PropertySource<?> load(org.springframework.core.io.Resource resource, String group, String name, String profile)
      Load the profile-specific properties from the specified resource (if any), give the name provided and add it to a group of property sources identified by the group name.
    • Constructor Detail

      • PropertySourcesLoader

        public PropertySourcesLoader()
        Create a new PropertySourceLoader instance backed by a new MutablePropertySources.
      • PropertySourcesLoader

        public PropertySourcesLoader(org.springframework.core.env.MutablePropertySources propertySources)
        Create a new PropertySourceLoader instance backed by the specified MutablePropertySources.
        Parameters:
        propertySources - the destination property sources
    • Method Detail

      • load

        public org.springframework.core.env.PropertySource<?> load(org.springframework.core.io.Resource resource)
                                                            throws IOException
        Load the specified resource (if possible) and add it as the first source.
        Parameters:
        resource - the source resource (may be null).
        Returns:
        the loaded property source or null
        Throws:
        IOException - if the source cannot be loaded
      • load

        public org.springframework.core.env.PropertySource<?> load(org.springframework.core.io.Resource resource,
                                                                   String profile)
                                                            throws IOException
        Load the profile-specific properties from the specified resource (if any) and add it as the first source.
        Parameters:
        resource - the source resource (may be null).
        profile - a specific profile to load or null to load the default.
        Returns:
        the loaded property source or null
        Throws:
        IOException - if the source cannot be loaded
      • load

        public org.springframework.core.env.PropertySource<?> load(org.springframework.core.io.Resource resource,
                                                                   String name,
                                                                   String profile)
                                                            throws IOException
        Load the profile-specific properties from the specified resource (if any), give the name provided and add it as the first source.
        Parameters:
        resource - the source resource (may be null).
        name - the root property name (may be null).
        profile - a specific profile to load or null to load the default.
        Returns:
        the loaded property source or null
        Throws:
        IOException - if the source cannot be loaded
      • load

        public org.springframework.core.env.PropertySource<?> load(org.springframework.core.io.Resource resource,
                                                                   String group,
                                                                   String name,
                                                                   String profile)
                                                            throws IOException
        Load the profile-specific properties from the specified resource (if any), give the name provided and add it to a group of property sources identified by the group name. Property sources are added to the end of a group, but new groups are added as the first in the chain being assembled. This means the normal sequence of calls is to first create the group for the default (null) profile, and then add specific groups afterwards (with the highest priority last). Property resolution from the resulting sources will consider all keys for a given group first and then move to the next group.
        Parameters:
        resource - the source resource (may be null).
        group - an identifier for the group that this source belongs to
        name - the root property name (may be null).
        profile - a specific profile to load or null to load the default.
        Returns:
        the loaded property source or null
        Throws:
        IOException - if the source cannot be loaded
      • getPropertySources

        public org.springframework.core.env.MutablePropertySources getPropertySources()
        Return the MutablePropertySources being loaded.
        Returns:
        the property sources
      • getAllFileExtensions

        public Set<String> getAllFileExtensions()
        Returns all file extensions that could be loaded.
        Returns:
        the file extensions

Copyright © 2018 Pivotal Software, Inc.. All rights reserved.