public class ResourceBundleMessageSource extends AbstractMessageSource implements BeanClassLoaderAware
Title: ResourceBundleMessageSource.java
Description:
bboss workgroup
Copyright (c) 2007
logger| 构造器和说明 |
|---|
ResourceBundleMessageSource() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected java.util.ResourceBundle |
doGetBundle(java.lang.String basename,
java.util.Locale locale)
Obtain the resource bundle for the given basename and Locale.
|
protected java.util.ResourceBundle |
doGetDefaultBundle(java.lang.String filename)
Refresh the PropertiesHolder for the given bundle filename.
|
protected java.lang.ClassLoader |
getBundleClassLoader()
Return the ClassLoader to load resource bundles with.
|
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.util.ResourceBundle |
getResourceBundle(java.lang.String basename,
java.util.Locale locale)
Return a ResourceBundle for the given basename and code,
fetching already generated MessageFormats from the cache.
|
protected java.util.ResourceBundle |
loadProperties(org.frameworkset.util.io.Resource resource,
java.lang.String filename)
Load the properties from the given resource.
|
protected java.text.MessageFormat |
resolveCode(java.lang.String code,
java.util.Locale locale)
Resolves the given message code as key in the registered resource bundles,
using a cached MessageFormat instance per message code.
|
protected java.lang.String |
resolveCodeWithoutArguments(java.lang.String code,
java.util.Locale locale)
Resolves the given message code as key in the registered resource bundles,
returning the value found in the bundle as-is (without MessageFormat parsing).
|
void |
setBasename(java.lang.String basename)
Set a single basename, following
ResourceBundle conventions:
essentially, a fully-qualified classpath location. |
void |
setBasenames(java.lang.String[] basenames)
Set an array of basenames, each following
ResourceBundle
conventions: essentially, a fully-qualified classpath location. |
void |
setBeanClassLoader(java.lang.ClassLoader classLoader)
Callback that supplies the bean
class loader to
a bean instance. |
void |
setBundleClassLoader(java.lang.ClassLoader classLoader)
Set the ClassLoader to load resource bundles with.
|
java.lang.String |
toString()
Show the configuration of this MessageSource.
|
destroy, getDefaultMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessageFromParent, getMessageInternal, getParentMessageSource, isUseCodeAsDefaultMessage, renderDefaultMessage, resolveArguments, setParentMessageSource, setUseCodeAsDefaultMessagecreateMessageFormat, formatMessage, isAlwaysUseMessageFormat, setAlwaysUseMessageFormatpublic void setBasename(java.lang.String basename)
ResourceBundle conventions:
essentially, a fully-qualified classpath location. 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 web application's WAR structure. They can also be held in jar files on the class path.
Note that ResourceBundle names are effectively classpath locations: As a
consequence, the JDK's standard ResourceBundle treats dots as package separators.
This means that "test.theme" is effectively equivalent to "test/theme",
just like it is for programmatic java.util.ResourceBundle usage.
setBasenames(java.lang.String[]),
ResourceBundle.getBundle(String)public void setBasenames(java.lang.String[] basenames)
ResourceBundle
conventions: essentially, a fully-qualified classpath location. If it
doesn't contain a package qualifier (such as org.mypackage),
it will be resolved from the classpath root.
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.
Note that ResourceBundle names are effectively classpath locations: As a
consequence, the JDK's standard ResourceBundle treats dots as package separators.
This means that "test.theme" is effectively equivalent to "test/theme",
just like it is for programmatic java.util.ResourceBundle usage.
setBasename(java.lang.String),
ResourceBundle.getBundle(String)public void setBundleClassLoader(java.lang.ClassLoader classLoader)
Default is the containing BeanFactory's
or the default ClassLoader determined by
ClassUtils.getDefaultClassLoader()
if not running within a BeanFactory.
protected java.lang.ClassLoader getBundleClassLoader()
Default is the containing BeanFactory's bean ClassLoader.
public void setBeanClassLoader(java.lang.ClassLoader classLoader)
BeanClassLoaderAwareclass loader to
a bean instance.
Invoked after the population of normal bean properties but
before an initialization callback such as
InitializingBean's
InitializingBean.afterPropertiesSet()
method or a custom init-method.
setBeanClassLoader 在接口中 BeanClassLoaderAwareclassLoader - the owning class loader; may be null in
which case a default ClassLoader must be used, for example
the ClassLoader obtained via
ClassUtils.getDefaultClassLoader()protected java.lang.String resolveCodeWithoutArguments(java.lang.String code,
java.util.Locale locale)
resolveCodeWithoutArguments 在类中 AbstractMessageSourcecode - the code of the message to resolvelocale - the Locale to resolve the code for
(subclasses are encouraged to support internationalization)null if not foundAbstractMessageSource.resolveCode(java.lang.String, java.util.Locale),
MessageFormatprotected java.text.MessageFormat resolveCode(java.lang.String code,
java.util.Locale locale)
resolveCode 在类中 AbstractMessageSourcecode - the code of the message to resolvelocale - the Locale to resolve the code for
(subclasses are encouraged to support internationalization)null if not foundAbstractMessageSource.resolveCodeWithoutArguments(String, java.util.Locale)protected java.util.ResourceBundle getResourceBundle(java.lang.String basename,
java.util.Locale locale)
basename - the basename of the ResourceBundlelocale - the Locale to find the ResourceBundle fornull if none
found for the given basename and Localeprotected java.util.ResourceBundle doGetBundle(java.lang.String basename,
java.util.Locale locale)
throws java.util.MissingResourceException
basename - the basename to look forlocale - the Locale to look forjava.util.MissingResourceException - if no matching bundle could be foundResourceBundle.getBundle(String, java.util.Locale, ClassLoader),
getBundleClassLoader()protected java.util.ResourceBundle doGetDefaultBundle(java.lang.String filename)
null if not cached before, or a timed-out cache entry
(potentially getting re-validated against the current last-modified timestamp).filename - the bundle filename (basename + Locale)propHolder - the current PropertiesHolder for the bundleprotected java.util.ResourceBundle loadProperties(org.frameworkset.util.io.Resource resource,
java.lang.String filename)
throws java.io.IOException
resource - the resource to load fromfilename - the original bundle filename (basename + Locale)java.io.IOException - if properties loading failedprotected 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 MessageFormatnull if no message
defined for the given codejava.util.MissingResourceException - if thrown by the ResourceBundlepublic java.lang.String toString()
toString 在类中 java.lang.Object