org.springframework.context.support

## 类 AbstractResourceBasedMessageSource

- java.lang.Object
- - org.springframework.context.support.MessageSourceSupport
  - - org.springframework.context.support.AbstractMessageSource
    - - org.springframework.context.support.AbstractResourceBasedMessageSource

- 所有已实现的接口:
    HierarchicalMessageSource, MessageSource
  直接已知子类:
    ReloadableResourceBundleMessageSource, ResourceBundleMessageSource

      public abstract class AbstractResourceBasedMessageSource
      extends AbstractMessageSource

  Abstract base class for `MessageSource` implementations based on resource bundle conventions, such as `ResourceBundleMessageSource` and `ReloadableResourceBundleMessageSource`. Provides common configuration methods and corresponding semantic definitions.
  从以下版本开始:
    4.3
  作者:
    Juergen Hoeller
  另请参阅:
    `ResourceBundleMessageSource`, `ReloadableResourceBundleMessageSource`

- - ### 字段概要

    - ### 从类继承的字段 org.springframework.context.support.MessageSourceSupport

      `logger`

  - ### 构造器概要

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

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `addBasenames(String... basenames)` Add the specified basenames to the existing basename configuration.
    `Set<String>` | `getBasenameSet()` Return this `MessageSource`'s basename set, containing entries in the order of registration.
    `protected long` | `getCacheMillis()` Return the number of milliseconds to cache loaded properties files.
    `protected String` | `getDefaultEncoding()` Return the default charset to use for parsing properties files, if any.
    `protected boolean` | `isFallbackToSystemLocale()` Return whether to fall back to the system Locale if no files for a specific Locale have been found.
    `void` | `setBasename(String basename)` Set a single basename, following the basic ResourceBundle convention of not specifying file extension or language codes.
    `void` | `setBasenames(String... basenames)` Set an array of basenames, each following the basic ResourceBundle convention of not specifying file extension or language codes.
    `void` | `setCacheMillis(long cacheMillis)` Set the number of milliseconds to cache loaded properties files.
    `void` | `setCacheSeconds(int cacheSeconds)` Set the number of seconds to cache loaded properties files.
    `void` | `setDefaultEncoding(String defaultEncoding)` Set the default charset to use for parsing properties files.
    `void` | `setFallbackToSystemLocale(boolean fallbackToSystemLocale)` Set whether to fall back to the system Locale if no files for a specific Locale have been found.

    - ### 从类继承的方法 org.springframework.context.support.AbstractMessageSource

      `getCommonMessages, getDefaultMessage, getDefaultMessage, getMessage, getMessage, getMessage, getMessageFromParent, getMessageInternal, getParentMessageSource, isUseCodeAsDefaultMessage, resolveArguments, resolveCode, resolveCodeWithoutArguments, setCommonMessages, setParentMessageSource, setUseCodeAsDefaultMessage`

    - ### 从类继承的方法 org.springframework.context.support.MessageSourceSupport

      `createMessageFormat, formatMessage, isAlwaysUseMessageFormat, renderDefaultMessage, setAlwaysUseMessageFormat`

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

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

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

    - #### AbstractResourceBasedMessageSource

          public AbstractResourceBasedMessageSource()

  - ### 方法详细资料

    - #### setBasename

          public void setBasename(String basename)

      Set a single basename, following the basic ResourceBundle convention of not specifying file extension or language codes. The resource location format is up to the specific `MessageSource` implementation.

      Regular and XMl properties files are supported: e.g. "messages" will find a "messages.properties", "messages_en.properties" etc arrangement as well as "messages.xml", "messages_en.xml" etc.

      参数:
        `basename` - the single basename
      另请参阅:
        `setBasenames(java.lang.String...)`, `ResourceEditor`, `ResourceBundle`

    - #### setBasenames

          public void setBasenames(String... basenames)

      Set an array of basenames, each following the basic ResourceBundle convention of not specifying file extension or language codes. The resource location format is up to the specific `MessageSource` implementation.

      Regular and XMl properties files are supported: e.g. "messages" will find a "messages.properties", "messages_en.properties" etc arrangement as well as "messages.xml", "messages_en.xml" etc.

      The associated resource bundles will be checked sequentially when resolving a message code. Note that message definitions in a previous resource bundle will override ones in a later bundle, due to the sequential lookup.

      Note: In contrast to `addBasenames(java.lang.String...)`, this replaces existing entries with the given names and can therefore also be used to reset the configuration.

      参数:
        `basenames` - an array of basenames
      另请参阅:
        `setBasename(java.lang.String)`, `ResourceBundle`

    - #### addBasenames

          public void addBasenames(String... basenames)

      Add the specified basenames to the existing basename configuration.

      Note: If a given basename already exists, the position of its entry will remain as in the original set. New entries will be added at the end of the list, to be searched after existing basenames.

      从以下版本开始:
        4.3
      另请参阅:
        `setBasenames(java.lang.String...)`, `ResourceBundle`

    - #### getBasenameSet

          public Set<String> getBasenameSet()

      Return this `MessageSource`'s basename set, containing entries in the order of registration.

      Calling code may introspect this set as well as add or remove entries.

      从以下版本开始:
        4.3
      另请参阅:
        `addBasenames(java.lang.String...)`

    - #### setDefaultEncoding

          public void setDefaultEncoding(@Nullable
                                         String defaultEncoding)

      Set the default charset to use for parsing properties files. Used if no file-specific charset is specified for a file.

      Default is none, using the `java.util.Properties` default encoding: ISO-8859-1.

      Only applies to classic properties files, not to XML files.

      参数:
        `defaultEncoding` - the default charset

    - #### getDefaultEncoding

          @Nullable
          protected String getDefaultEncoding()

      Return the default charset to use for parsing properties files, if any.
      从以下版本开始:
        4.3

    - #### setFallbackToSystemLocale

          public void setFallbackToSystemLocale(boolean fallbackToSystemLocale)

      Set whether to fall back to the system Locale if no files for a specific Locale have been found. Default is "true"; if this is turned off, the only fallback will be the default file (e.g. "messages.properties" for basename "messages").

      Falling back to the system Locale is the default behavior of `java.util.ResourceBundle`. However, this is often not desirable in an application server environment, where the system Locale is not relevant to the application at all: set this flag to "false" in such a scenario.

    - #### isFallbackToSystemLocale

          protected boolean isFallbackToSystemLocale()

      Return whether to fall back to the system Locale if no files for a specific Locale have been found.
      从以下版本开始:
        4.3

    - #### setCacheSeconds

          public void setCacheSeconds(int cacheSeconds)

      Set the number of seconds to cache loaded properties files.
      - Default is "-1", indicating to cache forever (just like `java.util.ResourceBundle`).
      - A positive number will cache loaded properties files for the given number of seconds. This is essentially the interval between refresh checks. Note that a refresh attempt will first check the last-modified timestamp of the file before actually reloading it; so if files don't change, this interval can be set rather low, as refresh attempts will not actually reload.
      - A value of "0" will check the last-modified timestamp of the file on every message access. Do not use this in a production environment!

      Note that depending on your ClassLoader, expiration might not work reliably since the ClassLoader may hold on to a cached version of the bundle file. Prefer `ReloadableResourceBundleMessageSource` over `ResourceBundleMessageSource` in such a scenario, in combination with a non-classpath location.

    - #### setCacheMillis

          public void setCacheMillis(long cacheMillis)

      Set the number of milliseconds to cache loaded properties files. Note that it is common to set seconds instead: `setCacheSeconds(int)`.
      - Default is "-1", indicating to cache forever (just like `java.util.ResourceBundle`).
      - A positive number will cache loaded properties files for the given number of milliseconds. This is essentially the interval between refresh checks. Note that a refresh attempt will first check the last-modified timestamp of the file before actually reloading it; so if files don't change, this interval can be set rather low, as refresh attempts will not actually reload.
      - A value of "0" will check the last-modified timestamp of the file on every message access. Do not use this in a production environment!
      从以下版本开始:
        4.3
      另请参阅:
        `setCacheSeconds(int)`

    - #### getCacheMillis

          protected long getCacheMillis()

      Return the number of milliseconds to cache loaded properties files.
      从以下版本开始:
        4.3