|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.context.support.AbstractMessageSource
org.springframework.context.support.ResourceBundleMessageSource
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.
setBasenames(java.lang.String[])
,
ReloadableResourceBundleMessageSource
,
ResourceBundle
Field Summary |
Fields inherited from class org.springframework.context.support.AbstractMessageSource |
logger |
Constructor Summary | |
ResourceBundleMessageSource()
|
Method Summary | |
protected java.text.MessageFormat |
getMessageFormat(java.util.ResourceBundle bundle,
java.lang.String code,
java.util.Locale locale)
Return a MessageFormat for the given bundle and code, fetching already generated MessageFormats from the cache. |
protected java.text.MessageFormat |
resolve(java.lang.String basename,
java.lang.String code,
java.util.Locale locale)
Return a MessageFormat for the given bundle basename, message code, and Locale. |
protected java.text.MessageFormat |
resolveCode(java.lang.String code,
java.util.Locale locale)
Subclasses must implement this method to resolve a message. |
void |
setBasename(java.lang.String basename)
Set a single basename, following ResourceBundle conventions: It is a fully-qualified classname. |
void |
setBasenames(java.lang.String[] basenames)
Set an array of basenames, each following ResourceBundle conventions. |
java.lang.String |
toString()
Show the configuration of this MessageSource. |
Methods inherited from class org.springframework.context.support.AbstractMessageSource |
createMessageFormat, getMessage, getMessage, getMessage, getMessageInternal, getParentMessageSource, resolveArguments, setParentMessageSource, setUseCodeAsDefaultMessage |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ResourceBundleMessageSource()
Method Detail |
public void setBasename(java.lang.String basename)
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.
basename
- the single basenamesetBasenames(java.lang.String[])
,
ResourceBundle
public void setBasenames(java.lang.String[] basenames)
Note that message definitions in a previous resource bundle will override ones in a later bundle, due to the sequential lookup.
basenames
- an array of basenamessetBasename(java.lang.String)
,
ResourceBundle
protected final java.text.MessageFormat resolveCode(java.lang.String code, java.util.Locale locale)
AbstractMessageSource
Returns a MessageFormat instance rather than a message String, to allow for appropriate caching of MessageFormats in subclasses.
resolveCode
in class AbstractMessageSource
code
- the code of the message to resolvelocale
- the Locale to resolve the code for
(subclasses are encouraged to support internationalization)
protected java.text.MessageFormat resolve(java.lang.String basename, java.lang.String code, java.util.Locale locale)
basename
- the basename of the bundlecode
- the message code to retrievelocale
- the Locale to resolve for
protected java.text.MessageFormat getMessageFormat(java.util.ResourceBundle bundle, java.lang.String code, java.util.Locale locale) throws java.util.MissingResourceException
bundle
- the ResourceBundle to work oncode
- the message code to retrievelocale
- the Locale to use to build the MessageFormat
java.util.MissingResourceException
public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |