org.springframework.context.support
Class ResourceBundleMessageSource

org.springframework.context.support.AbstractNestingMessageSource
  |
  +--org.springframework.context.support.ResourceBundleMessageSource

public class ResourceBundleMessageSource
extends AbstractNestingMessageSource

MessageSource that accesses the ResourceBundles with the specified basenames. This class relies on the underlying JDK's java.util.ResourceBundle implementation.

Unfortunately, java.util.ResourceBundle caches loaded bundles indefinitely. Reloading a bundle during VM execution is not possible by any means. As this MessageSource relies on ResourceBundle, it faces the same limitation. Consider ReloadableResourceBundleMessageSource for an alternative.

Author:
Rod Johnson, Juergen Hoeller
See Also: setBasenames(java.lang.String[]), ReloadableResourceBundleMessageSource, ResourceBundle

Method Summary
 voidsetBasename(String basename)
          Set a single basename, following ResourceBundle conventions: It is a fully-qualified classname.
 voidsetBasenames(String[] basenames)
          Set an array of basenames, each following ResourceBundle conventions.
 StringtoString()
          Show the configuration of this MessageSource.

Methods inherited from class org.springframework.context.support.AbstractNestingMessageSource
getMessage, getMessage, getMessage, setParent, setUseCodeAsDefaultMessage

Method Detail

setBasename

public void setBasename(String basename)
Set a single basename, following ResourceBundle conventions: It is a fully-qualified classname. If it doesn't contain a package qualifier (such as org.mypackage), it will be resolved from the classpath root.

Messages will normally be held in the /lib or /classes directory of a WAR. They can also be held in Jars on the class path. For example, a Jar in an application's manifest classpath could contain messages for the application.

Parameters:
basename - the single basename
See Also:
setBasenames(java.lang.String[]), ResourceBundle

setBasenames

public void setBasenames(String[] basenames)
Set an array of basenames, each following ResourceBundle conventions. The associated resource bundles will be checked sequentially when resolving a message code.

Note that message definitions in a previous resource bundle will override ones in a later bundle, due to the sequential lookup.

Parameters:
basenames - an array of basenames
See Also:
setBasename(java.lang.String), ResourceBundle

toString

public String toString()
Show the configuration of this MessageSource.

Association Links

to Class java.lang.String

to Class java.util.Map

Cache to hold already generated MessageFormats per message code. Note that this Map contains the actual code Map, keyed with the Locale.

see #getMessageFormat