PluginAwareResourceBundleMessageSource (Grails 6.0.0)

Package: org.grails.spring.context.support

## [Java] Class PluginAwareResourceBundleMessageSource

- org.grails.spring.context.support.PluginAwareResourceBundleMessageSource

- All Implemented Interfaces and Traits:
    GrailsApplicationAware, PluginManagerAware, org.springframework.beans.factory.InitializingBean

      public class PluginAwareResourceBundleMessageSource
      extends ReloadableResourceBundleMessageSource
      implements GrailsApplicationAware, PluginManagerAware, org.springframework.beans.factory.InitializingBean

  A ReloadableResourceBundleMessageSource that is capable of loading message sources from plugins.

  Authors:
    Graeme Rocher
  Since:
    1.1

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `private static java.lang.String` | `GRAILS_APP_I18N_PATH_COMPONENT` |
    `protected GrailsApplication` | `application` |
    `private java.util.concurrent.ConcurrentMap<java.util.Locale, CacheEntry<PropertiesHolder>>` | `cachedMergedBinaryPluginProperties` |
    `private java.util.concurrent.ConcurrentMap<java.util.Locale, CacheEntry<PropertiesHolder>>` | `cachedMergedPluginProperties` |
    `private org.springframework.core.io.ResourceLoader` | `localResourceLoader` |
    `private java.lang.String` | `messageBundleLocationPattern` |
    `protected java.util.List<java.lang.String>` | `pluginBaseNames` |
    `private long` | `pluginCacheMillis` |
    `protected GrailsPluginManager` | `pluginManager` |
    `private org.springframework.core.io.support.PathMatchingResourcePatternResolver` | `resourceResolver` |
    `private boolean` | `searchClasspath` |

  - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class ReloadableResourceBundleMessageSource` | `PROPERTIES_SUFFIX, XML_SUFFIX, basenames, cacheMillis, cachedFilenames, cachedMergedProperties, cachedProperties, cachedResources, defaultEncoding, fallbackToSystemLocale, fileCacheMillis, fileEncodings, propertiesPersister, resourceLoader`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `PluginAwareResourceBundleMessageSource ()`
    `PluginAwareResourceBundleMessageSource (GrailsApplication application, GrailsPluginManager pluginManager)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public boolean` | `accept(java.io.File dir, java.lang.String name)`
    `` | `public void` | `afterPropertiesSet()`
    `` | `public PropertiesHolder` | `call()`
    `` | `public PropertiesHolder` | `call()`
    `` | `private java.lang.String` | `findCodeInBinaryPlugins(java.lang.String code, java.util.Locale locale)`
    `` | `private java.text.MessageFormat` | `findMessageFormatInBinaryPlugins(java.lang.String code, java.util.Locale locale)`
    `` | `protected PropertiesHolder` | `getMergedBinaryPluginProperties(java.util.Locale locale)`
    `` | `protected PropertiesHolder` | `getMergedPluginProperties(java.util.Locale locale)` Get a PropertiesHolder that contains the actually visible properties for a Locale, after merging all specified resource bundles.
    `` | `protected void` | `mergeBinaryPluginProperties(java.util.Locale locale, java.util.Properties mergedProps)`
    `` | `protected java.text.MessageFormat` | `resolveCode(java.lang.String code, java.util.Locale locale)`
    `` | `protected java.text.MessageFormat` | `resolveCodeFromPlugins(java.lang.String code, java.util.Locale locale)` Attempts to resolve a MessageFormat for the code from the list of plugin base names
    `` | `protected java.lang.String` | `resolveCodeWithoutArguments(java.lang.String code, java.util.Locale locale)`
    `` | `protected java.lang.String` | `resolveCodeWithoutArgumentsFromPlugins(java.lang.String code, java.util.Locale locale)` Attempts to resolve a String for the code from the list of plugin base names
    `` | `public void` | `setGrailsApplication(GrailsApplication grailsApplication)`
    `` | `public void` | `setMessageBundleLocationPattern(java.lang.String messageBundleLocationPattern)` The location pattern for message bundles
    `` | `public void` | `setPluginCacheSeconds(int pluginCacheSeconds)` Set the number of seconds to cache the list of matching properties files loaded from plugin.
    `` | `public void` | `setPluginManager(GrailsPluginManager pluginManager)`
    `` | `public void` | `setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)`
    `` | `public void` | `setResourceResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver resourceResolver)`
    `` | `public void` | `setSearchClasspath(boolean searchClasspath)` Whether to search the full classpath for message bundles.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class ReloadableResourceBundleMessageSource` | `calculateAllFilenames, calculateFilenamesForLocale, call, call, call, call, call, clearCache, clearCacheIncludingAncestors, getBundleCodes, getMergedProperties, getProperties, getValidBasenames, loadProperties, locateResource, locateResourceWithoutCache, resolveCode, resolveCodeWithoutArguments, setBasename, setBasenames, setCacheSeconds, setDefaultEncoding, setFallbackToSystemLocale, setFileCacheSeconds, setFileEncodings, setPropertiesPersister, setResourceLoader, toString`

- - ### Field Detail

    - #### private static final java.lang.String GRAILS_APP_I18N_PATH_COMPONENT

    - #### protected GrailsApplication application

    - #### private java.util.concurrent.ConcurrentMap<java.util.Locale, CacheEntry<PropertiesHolder>> cachedMergedBinaryPluginProperties

    - #### private java.util.concurrent.ConcurrentMap<java.util.Locale, CacheEntry<PropertiesHolder>> cachedMergedPluginProperties

    - #### private org.springframework.core.io.ResourceLoader localResourceLoader

    - #### private java.lang.String messageBundleLocationPattern

    - #### protected java.util.List<java.lang.String> pluginBaseNames

    - #### private long pluginCacheMillis

    - #### protected GrailsPluginManager pluginManager

    - #### private org.springframework.core.io.support.PathMatchingResourcePatternResolver resourceResolver

    - #### private boolean searchClasspath

  - ### Constructor Detail

    - #### public PluginAwareResourceBundleMessageSource()

    - #### public PluginAwareResourceBundleMessageSource(GrailsApplication application, GrailsPluginManager pluginManager)

  - ### Method Detail

    - #### @java.lang.Override public boolean accept(java.io.File dir, java.lang.String name)

    - #### public void afterPropertiesSet()

    - #### @java.lang.Override public PropertiesHolder call()

    - #### private java.lang.String findCodeInBinaryPlugins(java.lang.String code, java.util.Locale locale)

    - #### private java.text.MessageFormat findMessageFormatInBinaryPlugins(java.lang.String code, java.util.Locale locale)

    - #### protected PropertiesHolder getMergedBinaryPluginProperties(java.util.Locale locale)

    - #### protected PropertiesHolder getMergedPluginProperties(java.util.Locale locale)

      Get a PropertiesHolder that contains the actually visible properties for a Locale, after merging all specified resource bundles. Either fetches the holder from the cache or freshly loads it.

      Only used when caching resource bundle contents forever, i.e. with cacheSeconds < 0. Therefore, merged properties are always cached forever.

    - #### protected void mergeBinaryPluginProperties(java.util.Locale locale, java.util.Properties mergedProps)

    - #### @java.lang.Override protected java.text.MessageFormat resolveCode(java.lang.String code, java.util.Locale locale)

    - #### protected java.text.MessageFormat resolveCodeFromPlugins(java.lang.String code, java.util.Locale locale)

      Attempts to resolve a MessageFormat for the code from the list of plugin base names

      Parameters:
        `code` - The code
        `locale` - The locale
      Returns:
        a MessageFormat

    - #### @java.lang.Override protected java.lang.String resolveCodeWithoutArguments(java.lang.String code, java.util.Locale locale)

    - #### protected java.lang.String resolveCodeWithoutArgumentsFromPlugins(java.lang.String code, java.util.Locale locale)

      Attempts to resolve a String for the code from the list of plugin base names

      Parameters:
        `code` - The code
        `locale` - The locale
      Returns:
        a MessageFormat

    - #### public void setGrailsApplication(GrailsApplication grailsApplication)

    - #### public void setMessageBundleLocationPattern(java.lang.String messageBundleLocationPattern)

      The location pattern for message bundles

      Parameters:
        `messageBundleLocationPattern` - The message bundle location pattern

    - #### public void setPluginCacheSeconds(int pluginCacheSeconds)

      Set the number of seconds to cache the list of matching properties files loaded from plugin.

      - Default value is the same value as cacheSeconds

    - #### public void setPluginManager(GrailsPluginManager pluginManager)

    - #### @java.lang.Override public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)

    - #### public void setResourceResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver resourceResolver)

    - #### public void setSearchClasspath(boolean searchClasspath)

      Whether to search the full classpath for message bundles. Enabling this will degrade startup performance. The default is to only search for message bundles relative to the application classes directory.

      Parameters:
        `searchClasspath` - True if the entire classpath should be searched