Class PluginAwareResourceBundleMessageSource
- java.lang.Object
-
- org.springframework.context.support.MessageSourceSupport
-
- org.springframework.context.support.AbstractMessageSource
-
- org.grails.spring.context.support.ReloadableResourceBundleMessageSource
-
- org.grails.spring.context.support.PluginAwareResourceBundleMessageSource
-
- All Implemented Interfaces:
GrailsApplicationAware,PluginManagerAware,org.springframework.beans.factory.Aware,org.springframework.beans.factory.InitializingBean,org.springframework.context.HierarchicalMessageSource,org.springframework.context.MessageSource,org.springframework.context.ResourceLoaderAware
public class PluginAwareResourceBundleMessageSource extends ReloadableResourceBundleMessageSource implements GrailsApplicationAware, PluginManagerAware, org.springframework.beans.factory.InitializingBean
A ReloadableResourceBundleMessageSource that is capable of loading message sources from plugins.- Since:
- 1.1
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.grails.spring.context.support.ReloadableResourceBundleMessageSource
ReloadableResourceBundleMessageSource.PropertiesHolder, ReloadableResourceBundleMessageSource.PropertiesHolderCacheEntry
-
-
Field Summary
Fields Modifier and Type Field Description protected GrailsApplicationapplicationprotected java.util.List<java.lang.String>pluginBaseNamesprotected GrailsPluginManagerpluginManager-
Fields inherited from class org.grails.spring.context.support.ReloadableResourceBundleMessageSource
cacheMillis, fileCacheMillis
-
-
Constructor Summary
Constructors Constructor Description PluginAwareResourceBundleMessageSource()PluginAwareResourceBundleMessageSource(GrailsApplication application, GrailsPluginManager pluginManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()protected ReloadableResourceBundleMessageSource.PropertiesHoldergetMergedBinaryPluginProperties(java.util.Locale locale)protected ReloadableResourceBundleMessageSource.PropertiesHoldergetMergedPluginProperties(java.util.Locale locale)Get a PropertiesHolder that contains the actually visible properties for a Locale, after merging all specified resource bundles.protected voidmergeBinaryPluginProperties(java.util.Locale locale, java.util.Properties mergedProps)protected java.text.MessageFormatresolveCode(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.MessageFormatresolveCodeFromPlugins(java.lang.String code, java.util.Locale locale)Attempts to resolve a MessageFormat for the code from the list of plugin base namesprotected java.lang.StringresolveCodeWithoutArguments(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.StringresolveCodeWithoutArgumentsFromPlugins(java.lang.String code, java.util.Locale locale)Attempts to resolve a String for the code from the list of plugin base namesvoidsetGrailsApplication(GrailsApplication grailsApplication)This method is called by theApplicationContextthat loads the Grails application.voidsetMessageBundleLocationPattern(java.lang.String messageBundleLocationPattern)The location pattern for message bundlesvoidsetPluginCacheSeconds(int pluginCacheSeconds)Set the number of seconds to cache the list of matching properties files loaded from plugin.voidsetPluginManager(GrailsPluginManager pluginManager)Sets the plug-in manager on this instancevoidsetResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)Set the ResourceLoader to use for loading bundle properties files.voidsetResourceResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver resourceResolver)voidsetSearchClasspath(boolean searchClasspath)Whether to search the full classpath for message bundles.-
Methods inherited from class org.grails.spring.context.support.ReloadableResourceBundleMessageSource
calculateAllFilenames, calculateFilenamesForLocale, clearCache, clearCacheIncludingAncestors, getBundleCodes, getMergedProperties, getProperties, getValidBasenames, loadProperties, locateResource, locateResourceWithoutCache, setBasename, setBasenames, setCacheSeconds, setDefaultEncoding, setFallbackToSystemLocale, setFileCacheSeconds, setFileEncodings, setPropertiesPersister, toString
-
Methods inherited from class org.springframework.context.support.AbstractMessageSource
getCommonMessages, getDefaultMessage, getDefaultMessage, getMessage, getMessage, getMessage, getMessageFromParent, getMessageInternal, getParentMessageSource, isUseCodeAsDefaultMessage, resolveArguments, setCommonMessages, setParentMessageSource, setUseCodeAsDefaultMessage
-
-
-
-
Field Detail
-
application
protected GrailsApplication application
-
pluginManager
protected GrailsPluginManager pluginManager
-
pluginBaseNames
protected java.util.List<java.lang.String> pluginBaseNames
-
-
Constructor Detail
-
PluginAwareResourceBundleMessageSource
public PluginAwareResourceBundleMessageSource()
-
PluginAwareResourceBundleMessageSource
public PluginAwareResourceBundleMessageSource(GrailsApplication application, GrailsPluginManager pluginManager)
-
-
Method Detail
-
setGrailsApplication
public void setGrailsApplication(GrailsApplication grailsApplication)
Description copied from interface:GrailsApplicationAwareThis method is called by the
ApplicationContextthat loads the Grails application. TheGrailsApplicationinstance that represents the loaded Grails application is injected.- Specified by:
setGrailsApplicationin interfaceGrailsApplicationAware- Parameters:
grailsApplication- theGrailsApplicationobject that represents this Grails application
-
setPluginManager
public void setPluginManager(GrailsPluginManager pluginManager)
Description copied from interface:PluginManagerAwareSets the plug-in manager on this instance- Specified by:
setPluginManagerin interfacePluginManagerAware- Parameters:
pluginManager- The PluginManager
-
setResourceResolver
public void setResourceResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver resourceResolver)
-
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
java.lang.Exception
-
resolveCodeWithoutArguments
protected java.lang.String resolveCodeWithoutArguments(java.lang.String code, java.util.Locale locale)Description copied from class:ReloadableResourceBundleMessageSourceResolves the given message code as key in the retrieved bundle files, returning the value found in the bundle as-is (without MessageFormat parsing).- Overrides:
resolveCodeWithoutArgumentsin classReloadableResourceBundleMessageSource
-
resolveCode
protected java.text.MessageFormat resolveCode(java.lang.String code, java.util.Locale locale)Description copied from class:ReloadableResourceBundleMessageSourceResolves the given message code as key in the retrieved bundle files, using a cached MessageFormat instance per message code.- Overrides:
resolveCodein classReloadableResourceBundleMessageSource
-
getMergedPluginProperties
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. 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.
-
resolveCodeWithoutArgumentsFromPlugins
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 codelocale- The locale- Returns:
- a MessageFormat
-
getMergedBinaryPluginProperties
protected ReloadableResourceBundleMessageSource.PropertiesHolder getMergedBinaryPluginProperties(java.util.Locale locale)
-
mergeBinaryPluginProperties
protected void mergeBinaryPluginProperties(java.util.Locale locale, java.util.Properties mergedProps)
-
resolveCodeFromPlugins
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 codelocale- The locale- Returns:
- a MessageFormat
-
setResourceLoader
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
Description copied from class:ReloadableResourceBundleMessageSourceSet the ResourceLoader to use for loading bundle properties files.The 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.
- Specified by:
setResourceLoaderin interfaceorg.springframework.context.ResourceLoaderAware- Overrides:
setResourceLoaderin classReloadableResourceBundleMessageSource- See Also:
DefaultResourceLoader,ResourceLoaderAware
-
setPluginCacheSeconds
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
-
setSearchClasspath
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
-
setMessageBundleLocationPattern
public void setMessageBundleLocationPattern(java.lang.String messageBundleLocationPattern)
The location pattern for message bundles- Parameters:
messageBundleLocationPattern- The message bundle location pattern
-
-