org.springframework.beans.factory.config

## 类 PropertyResourceConfigurer

- java.lang.Object
- - org.springframework.core.io.support.PropertiesLoaderSupport
  - - org.springframework.beans.factory.config.PropertyResourceConfigurer

- 所有已实现的接口:
    BeanFactoryPostProcessor, org.springframework.core.Ordered, org.springframework.core.PriorityOrdered
  直接已知子类:
    PlaceholderConfigurerSupport, PropertyOverrideConfigurer

      public abstract class PropertyResourceConfigurer
      extends org.springframework.core.io.support.PropertiesLoaderSupport
      implements BeanFactoryPostProcessor, org.springframework.core.PriorityOrdered

  Allows for configuration of individual bean property values from a property resource, i.e. a properties file. Useful for custom config files targeted at system administrators that override bean properties configured in the application context.

  Two concrete implementations are provided in the distribution:

  - `PropertyOverrideConfigurer` for "beanName.property=value" style overriding (pushing values from a properties file into bean definitions)
  - `PropertyPlaceholderConfigurer` for replacing "${...}" placeholders (pulling values from a properties file into bean definitions)

  Property values can be converted after reading them in, through overriding the `convertPropertyValue(java.lang.String)` method. For example, encrypted values can be detected and decrypted accordingly before processing them.

  从以下版本开始:
    02.10.2003
  作者:
    Juergen Hoeller
  另请参阅:
    `PropertyOverrideConfigurer`, `PropertyPlaceholderConfigurer`

- - ### 字段概要

    - ### 从类继承的字段 org.springframework.core.io.support.PropertiesLoaderSupport

      `localOverride, localProperties, logger`

    - ### 从接口继承的字段 org.springframework.core.Ordered

      `HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

  - ### 构造器概要

    构造器
    构造器和说明
    `PropertyResourceConfigurer()`

  - ### 方法概要

    所有方法 实例方法 抽象方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `protected void` | `convertProperties(Properties props)` Convert the given merged properties, converting property values if necessary.
    `protected String` | `convertProperty(String propertyName, String propertyValue)` Convert the given property from the properties source to the value which should be applied.
    `protected String` | `convertPropertyValue(String originalValue)` Convert the given property value from the properties source to the value which should be applied.
    `int` | `getOrder()`
    `void` | `postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)` Merge, convert and process properties against the given bean factory.
    `protected abstract void` | `processProperties(ConfigurableListableBeanFactory beanFactory, Properties props)` Apply the given Properties to the given BeanFactory.
    `void` | `setOrder(int order)` Set the order value of this object for sorting purposes.

    - ### 从类继承的方法 org.springframework.core.io.support.PropertiesLoaderSupport

      `loadProperties, mergeProperties, setFileEncoding, setIgnoreResourceNotFound, setLocalOverride, setLocation, setLocations, setProperties, setPropertiesArray, setPropertiesPersister`

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 构造器详细资料

    - #### PropertyResourceConfigurer

          public PropertyResourceConfigurer()

  - ### 方法详细资料

    - #### setOrder

          public void setOrder(int order)

      Set the order value of this object for sorting purposes.
      另请参阅:
        `PriorityOrdered`

    - #### getOrder

          public int getOrder()

      指定者:
        `getOrder` 在接口中 `org.springframework.core.Ordered`

    - #### postProcessBeanFactory

          public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
                                      throws BeansException

      Merge, convert and process properties against the given bean factory.
      指定者:
        `postProcessBeanFactory` 在接口中 `BeanFactoryPostProcessor`
      参数:
        `beanFactory` - the bean factory used by the application context
      抛出:
        `BeanInitializationException` - if any properties cannot be loaded
        `BeansException` - in case of errors

    - #### convertProperties

          protected void convertProperties(Properties props)

      Convert the given merged properties, converting property values if necessary. The result will then be processed.

      The default implementation will invoke `convertPropertyValue(java.lang.String)` for each property value, replacing the original with the converted value.

      参数:
        `props` - the Properties to convert
      另请参阅:
        `processProperties(org.springframework.beans.factory.config.ConfigurableListableBeanFactory, java.util.Properties)`

    - #### convertProperty

          protected String convertProperty(String propertyName,
                                           String propertyValue)

      Convert the given property from the properties source to the value which should be applied.

      The default implementation calls `convertPropertyValue(String)`.

      参数:
        `propertyName` - the name of the property that the value is defined for
        `propertyValue` - the original value from the properties source
      返回:
        the converted value, to be used for processing
      另请参阅:
        `convertPropertyValue(String)`

    - #### convertPropertyValue

          protected String convertPropertyValue(String originalValue)

      Convert the given property value from the properties source to the value which should be applied.

      The default implementation simply returns the original value. Can be overridden in subclasses, for example to detect encrypted values and decrypt them accordingly.

      参数:
        `originalValue` - the original value from the properties source (properties file or local "properties")
      返回:
        the converted value, to be used for processing
      另请参阅:
        `PropertiesLoaderSupport.setProperties(java.util.Properties)`, `PropertiesLoaderSupport.setLocations(org.springframework.core.io.Resource...)`, `PropertiesLoaderSupport.setLocation(org.springframework.core.io.Resource)`, `convertProperty(String, String)`

    - #### processProperties

          protected abstract void processProperties(ConfigurableListableBeanFactory beanFactory,
                                                    Properties props)
                                             throws BeansException

      Apply the given Properties to the given BeanFactory.
      参数:
        `beanFactory` - the BeanFactory used by the application context
        `props` - the Properties to apply
      抛出:
        `BeansException` - in case of errors