public class PluginAwareResourceBundleMessageSource extends ReloadableResourceBundleMessageSource implements GrailsApplicationAware, PluginManagerAware, org.springframework.beans.factory.InitializingBean
ReloadableResourceBundleMessageSource.PropertiesHolder, ReloadableResourceBundleMessageSource.PropertiesHolderCacheEntry| Modifier and Type | Field and Description |
|---|---|
protected GrailsApplication |
application |
protected java.util.List<java.lang.String> |
pluginBaseNames |
protected GrailsPluginManager |
pluginManager |
cacheMillis, fileCacheMillis| Constructor and Description |
|---|
PluginAwareResourceBundleMessageSource() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected java.lang.String |
getInlinePluginPath(GrailsPlugin grailsPlugin)
Returns the absolute path to the provided Grails plugin if it is being used "inline" or
null
if the plugin is not being used "inline". |
protected ReloadableResourceBundleMessageSource.PropertiesHolder |
getMergedBinaryPluginProperties(java.util.Locale locale) |
protected ReloadableResourceBundleMessageSource.PropertiesHolder |
getMergedPluginProperties(java.util.Locale locale)
Get a PropertiesHolder that contains the actually visible properties
for a Locale, after merging all specified resource bundles.
|
java.util.List<java.lang.String> |
getPluginBaseNames() |
protected org.springframework.core.io.Resource[] |
getPluginBundles(GrailsPlugin grailsPlugin)
Returns the i18n message bundles for the provided plugin or an empty
array if the plugin does not contain any .properties files in its
grails-app/i18n folder.
|
protected boolean |
isInlinePlugin(GrailsPlugin grailsPlugin)
Tests whether or not the Grails plugin is currently being run "inline".
|
protected void |
mergeBinaryPluginProperties(java.util.Locale locale,
java.util.Properties mergedProps) |
protected java.text.MessageFormat |
resolveCode(java.lang.String code,
java.util.Locale locale)
Resolves the given message code as key in the retrieved bundle files,
using a cached MessageFormat instance per message code.
|
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)
Resolves the given message code as key in the retrieved bundle files,
returning the value found in the bundle as-is (without MessageFormat parsing).
|
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
|
void |
setGrailsApplication(GrailsApplication grailsApplication)
This method is called by the
ApplicationContext that
loads the Grails application. |
void |
setPluginBaseNames(java.util.List<java.lang.String> pluginBaseNames) |
void |
setPluginCacheSeconds(int pluginCacheSeconds)
Set the number of seconds to cache the list of matching properties files loaded from plugin.
|
void |
setPluginManager(GrailsPluginManager pluginManager)
Sets the plug-in manager on this instance
|
void |
setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
Set the ResourceLoader to use for loading bundle properties files.
|
void |
setResourceResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver resourceResolver) |
calculateAllFilenames, calculateFilenamesForLocale, clearCache, clearCacheIncludingAncestors, getMergedProperties, getProperties, loadProperties, locateResource, locateResourceWithoutCache, setBasename, setBasenames, setCacheSeconds, setDefaultEncoding, setFallbackToSystemLocale, setFileCacheSeconds, setFileEncodings, setPropertiesPersister, toStringgetCommonMessages, getDefaultMessage, getMessage, getMessage, getMessage, getMessageFromParent, getMessageInternal, getParentMessageSource, isUseCodeAsDefaultMessage, resolveArguments, setCommonMessages, setParentMessageSource, setUseCodeAsDefaultMessageprotected GrailsApplication application
protected GrailsPluginManager pluginManager
protected java.util.List<java.lang.String> pluginBaseNames
public PluginAwareResourceBundleMessageSource()
public java.util.List<java.lang.String> getPluginBaseNames()
public void setPluginBaseNames(java.util.List<java.lang.String> pluginBaseNames)
public void setGrailsApplication(GrailsApplication grailsApplication)
GrailsApplicationAwareThis method is called by the ApplicationContext that
loads the Grails application. The GrailsApplication instance that represents
the loaded Grails application is injected.
setGrailsApplication in interface GrailsApplicationAwaregrailsApplication - the GrailsApplication object that represents this Grails applicationpublic void setPluginManager(GrailsPluginManager pluginManager)
PluginManagerAwaresetPluginManager in interface PluginManagerAwarepluginManager - The PluginManagerpublic void setResourceResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver resourceResolver)
public void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.Exceptionprotected org.springframework.core.io.Resource[] getPluginBundles(GrailsPlugin grailsPlugin)
grailsPlugin - The grails plugin that may or may not contain i18n internationalization files.Resource objects representing the internationalization files or
an empty array if no files are found.protected boolean isInlinePlugin(GrailsPlugin grailsPlugin)
grailsPlugin - The Grails plugin to test.true if the plugin is being used "inline" or false if the
plugin is not being used "inline".protected java.lang.String getInlinePluginPath(GrailsPlugin grailsPlugin)
null
if the plugin is not being used "inline".grailsPlugin - The Grails plugin.null if the plugin is not being used "inline".protected java.lang.String resolveCodeWithoutArguments(java.lang.String code,
java.util.Locale locale)
ReloadableResourceBundleMessageSourceresolveCodeWithoutArguments in class ReloadableResourceBundleMessageSourceprotected java.text.MessageFormat resolveCode(java.lang.String code,
java.util.Locale locale)
ReloadableResourceBundleMessageSourceresolveCode in class ReloadableResourceBundleMessageSourceprotected ReloadableResourceBundleMessageSource.PropertiesHolder getMergedPluginProperties(java.util.Locale locale)
Only used when caching resource bundle contents forever, i.e. with cacheSeconds < 0. Therefore, merged properties are always cached forever.
protected java.lang.String resolveCodeWithoutArgumentsFromPlugins(java.lang.String code,
java.util.Locale locale)
code - The codelocale - The localeprotected ReloadableResourceBundleMessageSource.PropertiesHolder getMergedBinaryPluginProperties(java.util.Locale locale)
protected void mergeBinaryPluginProperties(java.util.Locale locale,
java.util.Properties mergedProps)
protected java.text.MessageFormat resolveCodeFromPlugins(java.lang.String code,
java.util.Locale locale)
code - The codelocale - The localepublic void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
ReloadableResourceBundleMessageSourceThe default is a DefaultResourceLoader. Will get overridden by the ApplicationContext if running in a context, as it implements the ResourceLoaderAware interface. Can be manually overridden when running outside of an ApplicationContext.
setResourceLoader in interface org.springframework.context.ResourceLoaderAwaresetResourceLoader in class ReloadableResourceBundleMessageSourceDefaultResourceLoader,
ResourceLoaderAwarepublic void setPluginCacheSeconds(int pluginCacheSeconds)