org.springframework.core.io.support

## Class ResourcePropertySource

- java.lang.Object
- - org.springframework.core.env.PropertySource<T>
  - - org.springframework.core.env.EnumerablePropertySource<Map<String,Object>>
    - - org.springframework.core.env.MapPropertySource
      - - org.springframework.core.env.PropertiesPropertySource
        - - org.springframework.core.io.support.ResourcePropertySource

-     public class ResourcePropertySource
      extends PropertiesPropertySource

  Subclass of `PropertiesPropertySource` that loads a `Properties` object from a given `Resource` or resource location such as `"classpath:/com/myco/foo.properties"` or `"file:/path/to/file.xml"`. Both traditional and XML-based properties file formats are supported, however in order for XML processing to take effect, the underlying `Resource`'s `getFilename()` method must return non-`null` and end in ".xml".
  Since:
    3.1
  Author:
    Chris Beams, Juergen Hoeller

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.springframework.core.env.PropertySource

      `PropertySource.StubPropertySource`

  - ### Field Summary

    - ### Fields inherited from class org.springframework.core.env.EnumerablePropertySource

      `EMPTY_NAMES_ARRAY, logger`

    - ### Fields inherited from class org.springframework.core.env.PropertySource

      `name, source`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ResourcePropertySource(EncodedResource resource)` Create a PropertySource based on Properties loaded from the given resource.
    `ResourcePropertySource(Resource resource)` Create a PropertySource based on Properties loaded from the given resource.
    `ResourcePropertySource(String location)` Create a PropertySource based on Properties loaded from the given resource location.
    `ResourcePropertySource(String location, ClassLoader classLoader)` Create a PropertySource based on Properties loaded from the given resource location and use the given class loader to load the resource, assuming it is prefixed with `classpath:`.
    `ResourcePropertySource(String name, EncodedResource resource)` Create a PropertySource having the given name based on Properties loaded from the given encoded resource.
    `ResourcePropertySource(String name, Resource resource)` Create a PropertySource having the given name based on Properties loaded from the given encoded resource.
    `ResourcePropertySource(String name, String location)` Create a PropertySource having the given name based on Properties loaded from the given resource location.
    `ResourcePropertySource(String name, String location, ClassLoader classLoader)` Create a PropertySource having the given name based on Properties loaded from the given resource location and using the given class loader to load the resource (assuming it is prefixed with `classpath:`).

  - ### Method Summary

    - ### Methods inherited from class org.springframework.core.env.MapPropertySource

      `getProperty, getPropertyNames`

    - ### Methods inherited from class org.springframework.core.env.EnumerablePropertySource

      `containsProperty`

    - ### Methods inherited from class org.springframework.core.env.PropertySource

      `equals, getName, getSource, hashCode, named, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ResourcePropertySource

          public ResourcePropertySource(String name,
                                        EncodedResource resource)
                                 throws IOException

      Create a PropertySource having the given name based on Properties loaded from the given encoded resource.
      Throws:
        `IOException`

    - #### ResourcePropertySource

          public ResourcePropertySource(EncodedResource resource)
                                 throws IOException

      Create a PropertySource based on Properties loaded from the given resource. The name of the PropertySource will be generated based on the `description` of the given resource.
      Throws:
        `IOException`

    - #### ResourcePropertySource

          public ResourcePropertySource(String name,
                                        Resource resource)
                                 throws IOException

      Create a PropertySource having the given name based on Properties loaded from the given encoded resource.
      Throws:
        `IOException`

    - #### ResourcePropertySource

          public ResourcePropertySource(Resource resource)
                                 throws IOException

      Create a PropertySource based on Properties loaded from the given resource. The name of the PropertySource will be generated based on the `description` of the given resource.
      Throws:
        `IOException`

    - #### ResourcePropertySource

          public ResourcePropertySource(String name,
                                        String location,
                                        ClassLoader classLoader)
                                 throws IOException

      Create a PropertySource having the given name based on Properties loaded from the given resource location and using the given class loader to load the resource (assuming it is prefixed with `classpath:`).
      Throws:
        `IOException`

    - #### ResourcePropertySource

          public ResourcePropertySource(String location,
                                        ClassLoader classLoader)
                                 throws IOException

      Create a PropertySource based on Properties loaded from the given resource location and use the given class loader to load the resource, assuming it is prefixed with `classpath:`. The name of the PropertySource will be generated based on the `description` of the resource.
      Throws:
        `IOException`

    - #### ResourcePropertySource

          public ResourcePropertySource(String name,
                                        String location)
                                 throws IOException

      Create a PropertySource having the given name based on Properties loaded from the given resource location. The default thread context class loader will be used to load the resource (assuming the location string is prefixed with `classpath:`.
      Throws:
        `IOException`

    - #### ResourcePropertySource

          public ResourcePropertySource(String location)
                                 throws IOException

      Create a PropertySource based on Properties loaded from the given resource location. The name of the PropertySource will be generated based on the `description` of the resource.
      Throws:
        `IOException`