org.broadleafcommerce.common.util
Class BroadleafMergeResourceBundleMessageSource

java.lang.Object
  extended by org.springframework.context.support.MessageSourceSupport
      extended by org.springframework.context.support.AbstractMessageSource
          extended by org.springframework.context.support.ReloadableResourceBundleMessageSource
              extended by org.broadleafcommerce.common.util.BroadleafMergeResourceBundleMessageSource
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.HierarchicalMessageSource, org.springframework.context.MessageSource, org.springframework.context.ResourceLoaderAware

public class BroadleafMergeResourceBundleMessageSource
extends org.springframework.context.support.ReloadableResourceBundleMessageSource

Replaces the deprecated 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 ReloadableResourceBundleMessageSource.setBasenames(String...) for more information.

Author:
Phillip Verheyden
See Also:
ReloadableResourceBundleMessageSource}, ResourceLoader#getResource(String)}, #setBasenames(String...)}

Nested Class Summary
 
Nested classes/interfaces inherited from class org.springframework.context.support.ReloadableResourceBundleMessageSource
org.springframework.context.support.ReloadableResourceBundleMessageSource.PropertiesHolder
 
Field Summary
 
Fields inherited from class org.springframework.context.support.MessageSourceSupport
logger
 
Constructor Summary
BroadleafMergeResourceBundleMessageSource()
           
 
Method Summary
 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, getMergedProperties, getProperties, loadProperties, refreshProperties, resolveCode, resolveCodeWithoutArguments, setBasename, setCacheSeconds, setDefaultEncoding, setFallbackToSystemLocale, setFileEncodings, setPropertiesPersister, setResourceLoader, toString
 
Methods inherited from class org.springframework.context.support.AbstractMessageSource
getCommonMessages, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BroadleafMergeResourceBundleMessageSource

public BroadleafMergeResourceBundleMessageSource()
Method Detail

setBasenames

public void setBasenames(String... basenames)
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 class org.springframework.context.support.ReloadableResourceBundleMessageSource
Parameters:
basenames -
resourceBundleExtensionPoint -
See Also:
ReloadableResourceBundleMessageSource#setBasenames(String...)}


Copyright © 2013. All Rights Reserved.