Class BroadleafMergeResourceBundleMessageSource
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.context.HierarchicalMessageSource
,org.springframework.context.MessageSource
,org.springframework.context.ResourceLoaderAware
Replaces the older BLResourceBundleMessageSource by using a ReloadableResourceBundleMessageSource
instead. The main advantage of using this is the out-of-the-box ability to merge multiple property files together. There
is one important difference: When there is a conflict for a property (declared in multiple files) this implementation
assumes that the later one in the list takes precedence. This follows with normal Broadleaf assumptions that bean
definitions declared later in the merge process win.
While this theoretically supports caching via the features provided in ReloadableResourceBundleMessageSource, this should not be used and instead should have cacheMillis always set to -1 (which is the default implementation). This ensures that codes are always obtained from a merged property list.
The basenames in this implementation are Spring path resources so if you need to refer to a resource on the classpath,
these should be prefixed with classpath:. This is slightly different from the ResourceBundleMessageSource
; see
AbstractResourceBasedMessageSource.setBasenames(String...)
for more information.
The BroadleafMergeResourceExtensionManager
will get invoked first and return any
resolved message from an implementing module.
- Author:
- Phillip Verheyden
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.context.support.ReloadableResourceBundleMessageSource
org.springframework.context.support.ReloadableResourceBundleMessageSource.PropertiesHolder
-
Field Summary
FieldsFields inherited from class org.springframework.context.support.MessageSourceSupport
logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected MessageFormat
resolveCode
(String code, Locale locale) protected String
resolveCodeWithoutArguments
(String code, Locale locale) void
setBasenames
(String... basenames) The super implementation ensures the basenames defined at the beginning take precedence.Methods inherited from class org.springframework.context.support.ReloadableResourceBundleMessageSource
calculateAllFilenames, calculateFilenamesForLocale, clearCache, clearCacheIncludingAncestors, collectPropertiesToMerge, getMergedProperties, getProperties, loadProperties, mergeProperties, newProperties, refreshProperties, resolveResource, setConcurrentRefresh, setFileEncodings, setFileExtensions, setPropertiesPersister, setResourceLoader, toString
Methods inherited from class org.springframework.context.support.AbstractResourceBasedMessageSource
addBasenames, getBasenameSet, getCacheMillis, getDefaultEncoding, getDefaultLocale, isFallbackToSystemLocale, setBasename, setCacheMillis, setCacheSeconds, setDefaultEncoding, setDefaultLocale, setFallbackToSystemLocale
Methods inherited from class org.springframework.context.support.AbstractMessageSource
getCommonMessages, getDefaultMessage, getDefaultMessage, getMessage, getMessage, getMessage, getMessageFromParent, getMessageInternal, getParentMessageSource, isUseCodeAsDefaultMessage, resolveArguments, setCommonMessages, setParentMessageSource, setUseCodeAsDefaultMessage
Methods inherited from class org.springframework.context.support.MessageSourceSupport
createMessageFormat, formatMessage, isAlwaysUseMessageFormat, renderDefaultMessage, setAlwaysUseMessageFormat
-
Field Details
-
extensionManager
-
-
Constructor Details
-
BroadleafMergeResourceBundleMessageSource
public BroadleafMergeResourceBundleMessageSource()
-
-
Method Details
-
setBasenames
The super implementation ensures the basenames defined at the beginning take precedence. We require the opposite in order to be in line with previous assumptions about the applicationContext merge process (meaning, beans defined in later applicationContexts take precedence). Thus, this reverses basenames before passing it up to the super implementation.- Overrides:
setBasenames
in classorg.springframework.context.support.AbstractResourceBasedMessageSource
- Parameters:
basenames
-
-
resolveCode
- Overrides:
resolveCode
in classorg.springframework.context.support.ReloadableResourceBundleMessageSource
-
resolveCodeWithoutArguments
- Overrides:
resolveCodeWithoutArguments
in classorg.springframework.context.support.ReloadableResourceBundleMessageSource
-