public class HotDeployResourceBundleMessageSource extends AbstractMessageSource implements ResourceLoaderAware
Title: HotDeployResourceBundleMessageSource.java
Description:
bboss workgroup
Copyright (c) 2007
| 限定符和类型 | 类和说明 |
|---|---|
protected static class |
HotDeployResourceBundleMessageSource.PropertiesHolder
PropertiesHolder for caching.
|
| 限定符和类型 | 字段和说明 |
|---|---|
protected static org.slf4j.Logger |
log
Logger available to subclasses
|
logger| 构造器和说明 |
|---|
HotDeployResourceBundleMessageSource() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected java.util.List |
calculateAllFilenames(java.lang.String basename,
java.util.Locale locale)
Calculate all filenames for the given bundle basename and Locale.
|
protected java.util.List |
calculateFilenamesForLocale(java.lang.String basename,
java.util.Locale locale)
Calculate the filenames for the given bundle basename and Locale,
appending language code, country code, and variant code.
|
void |
clearCache()
Clear the resource bundle cache.
|
void |
clearCacheIncludingAncestors()
Clear the resource bundle caches of this MessageSource and all its
ancestors.
|
void |
destroy()
注销国际化资源
|
protected HotDeployResourceBundleMessageSource.PropertiesHolder |
firstLoadProperties(java.lang.String filename) |
java.lang.ClassLoader |
getBundleClassLoader() |
protected HotDeployResourceBundleMessageSource.PropertiesHolder |
getMergedProperties(java.util.Locale locale)
Get a PropertiesHolder that contains the actually visible properties for
a Locale, after merging all specified resource bundles.
|
protected HotDeployResourceBundleMessageSource.PropertiesHolder |
getProperties(java.lang.String filename)
Get a PropertiesHolder for the given filename, either from the cache or
freshly loaded.
|
boolean |
isChangemonitor() |
protected java.util.Properties |
loadProperties(org.frameworkset.util.io.Resource resource,
java.lang.String filename)
Load the properties from the given resource.
|
protected HotDeployResourceBundleMessageSource.PropertiesHolder |
refreshProperties(java.io.File filepath,
java.lang.String basename,
java.lang.String relativefile)
Refresh the PropertiesHolder for the given bundle filename.
|
protected java.text.MessageFormat |
resolveCode(java.lang.String code,
java.util.Locale locale)
Resolves the given message code as key in the retrieved bundle files,
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 retrieved bundle files,
returning the value found in the bundle as-is (without MessageFormat
parsing).
|
void |
setBasename(java.lang.String basename)
Set a single basename, following the basic ResourceBundle convention of
not specifying file extension or language codes, but in contrast to
{ResourceBundleMessageSource} referring to a Bboss resource
location: e.g.
|
void |
setBasenames(java.lang.String[] basenames)
Set an array of basenames, each following the basic ResourceBundle
convention of not specifying file extension or language codes, but in
contrast to { ResourceBundleMessageSource} referring to a Bboss
resource location: e.g.
|
void |
setBundleClassLoader(java.lang.ClassLoader bundleClassLoader) |
void |
setChangemonitor(boolean changemonitor) |
void |
setDefaultEncoding(java.lang.String defaultEncoding)
Set the default charset to use for parsing properties files.
|
void |
setFallbackToSystemLocale(boolean fallbackToSystemLocale)
Set whether to fall back to the system Locale if no files for a specific
Locale have been found.
|
void |
setFileEncodings(java.util.Properties fileEncodings)
Set per-file charsets to use for parsing properties files.
|
void |
setPropertiesPersister(org.frameworkset.util.PropertiesPersister propertiesPersister)
Set the PropertiesPersister to use for parsing properties files.
|
void |
setResourceLoader(org.frameworkset.util.io.ResourceLoader resourceLoader)
Set the ResourceLoader to use for loading bundle properties files.
|
static void |
stopmonitor() |
java.lang.String |
toString() |
getDefaultMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessageFromParent, getMessageInternal, getParentMessageSource, isUseCodeAsDefaultMessage, renderDefaultMessage, resolveArguments, setParentMessageSource, setUseCodeAsDefaultMessagecreateMessageFormat, formatMessage, isAlwaysUseMessageFormat, setAlwaysUseMessageFormatpublic void setBasename(java.lang.String basename)
As of Bboss 1.2.2, XML properties files are also supported: e.g. "WEB-INF/messages" will find and load "WEB-INF/messages.xml", "WEB-INF/messages_en.xml", etc as well. Note that this will only work on JDK 1.5+.
basename - the single basenamesetBasenames(java.lang.String[]),
ResourceEditor,
ResourceBundlepublic void setBasenames(java.lang.String[] basenames)
As of Bboss 1.2.2, XML properties files are also supported: e.g. "WEB-INF/messages" will find and load "WEB-INF/messages.xml", "WEB-INF/messages_en.xml", etc as well. Note that this will only work on JDK 1.5+.
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.
basenames - an array of basenamessetBasename(java.lang.String),
ResourceBundlepublic void setDefaultEncoding(java.lang.String defaultEncoding)
Default is none, using the java.util.Properties default
encoding.
Only applies to classic properties files, not to XML files.
defaultEncoding - the default charsetsetFileEncodings(java.util.Properties)public void setFileEncodings(java.util.Properties fileEncodings)
Only applies to classic properties files, not to XML files.
fileEncodings - Properties with filenames as keys and charset names as values.
Filenames have to match the basename syntax, with optional
locale-specific appendices: e.g. "WEB-INF/messages" or
"WEB-INF/messages_en".setBasenames(java.lang.String[])public void setFallbackToSystemLocale(boolean fallbackToSystemLocale)
Falling back to the system Locale is the default behavior of
java.util.ResourceBundle. However, this is often not
desirable in an application server environment, where the system Locale
is not relevant to the application at all: Set this flag to "false" in
such a scenario.
public void setPropertiesPersister(org.frameworkset.util.PropertiesPersister propertiesPersister)
The default is a DefaultPropertiesPersister.
public void setResourceLoader(org.frameworkset.util.io.ResourceLoader resourceLoader)
The default is a DefaultResourceLoader. Will get overridden by the ApplicationContext if running in a context, as it implements the ResourceLoaderAware interface. Can be manually overridden when running outside of an ApplicationContext.
setResourceLoader 在接口中 ResourceLoaderAwareresourceLoader - ResourceLoader object to be used by this objectDefaultResourceLoader,
ResourceLoaderAwareprotected 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 HotDeployResourceBundleMessageSource.PropertiesHolder getMergedProperties(java.util.Locale locale)
Only used when caching resource bundle contents forever, i.e. with cacheSeconds < 0. Therefore, merged properties are always cached forever.
protected java.util.List calculateAllFilenames(java.lang.String basename,
java.util.Locale locale)
basename - the basename of the bundlelocale - the localesetFallbackToSystemLocale(boolean),
calculateFilenamesForLocale(java.lang.String, java.util.Locale)protected HotDeployResourceBundleMessageSource.PropertiesHolder getProperties(java.lang.String filename)
filename - the bundle filename (basename + Locale)protected HotDeployResourceBundleMessageSource.PropertiesHolder refreshProperties(java.io.File filepath, java.lang.String basename, java.lang.String relativefile)
null if not cached before, or a timed-out cache entry
(potentially getting re-validated against the current last-modified
timestamp).
relativefile = "org/frameworkset/spi/support/messages_en_US.properties";
basename = "org/frameworkset/spi/support/messages_en_US";
filepath = "d:/workspace/org/frameworkset/spi/support/messages_en_US.properties";filepath - basename - relativefile - protected HotDeployResourceBundleMessageSource.PropertiesHolder firstLoadProperties(java.lang.String filename)
protected java.util.Properties 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 failedpublic void clearCache()
public void clearCacheIncludingAncestors()
clearCache()public java.lang.String toString()
toString 在类中 java.lang.Objectprotected java.util.List calculateFilenamesForLocale(java.lang.String basename,
java.util.Locale locale)
basename - the basename of the bundlelocale - the localepublic static void stopmonitor()
public java.lang.ClassLoader getBundleClassLoader()
public void setBundleClassLoader(java.lang.ClassLoader bundleClassLoader)
public boolean isChangemonitor()
public void setChangemonitor(boolean changemonitor)
public void destroy()
destroy 在类中 AbstractMessageSource