|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.integration.expression.ReloadableResourceBundleExpressionSource
public class ReloadableResourceBundleExpressionSource
ExpressionSource
implementation that accesses resource bundles using specified basenames.
This class uses Properties
instances as its custom data structure for expressions,
loading them via a PropertiesPersister
strategy: The default
strategy is capable of loading properties files with a specific character encoding, if desired.
setCacheSeconds(int)
,
setBasenames(java.lang.String[])
,
setDefaultEncoding(java.lang.String)
,
setFileEncodings(java.util.Properties)
,
setPropertiesPersister(org.springframework.util.PropertiesPersister)
,
setResourceLoader(org.springframework.core.io.ResourceLoader)
,
DefaultPropertiesPersister
,
DefaultResourceLoader
,
ResourceBundle
Constructor Summary | |
---|---|
ReloadableResourceBundleExpressionSource()
|
Method Summary | |
---|---|
void |
clearCache()
Clear the resource bundle cache. |
Expression |
getExpression(java.lang.String key,
java.util.Locale locale)
Resolves the given key in the retrieved bundle files to an Expression. |
void |
setBasename(java.lang.String basename)
Set a single basename, following the basic ResourceBundle convention of not specifying file extension or language codes, but referring to a Spring 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 referring to a Spring resource location: e.g. |
void |
setCacheSeconds(int cacheSeconds)
Set the number of seconds to cache loaded properties files. |
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(PropertiesPersister propertiesPersister)
Set the PropertiesPersister to use for parsing properties files. |
void |
setResourceLoader(ResourceLoader resourceLoader)
Set the ResourceLoader to use for loading bundle properties files. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ReloadableResourceBundleExpressionSource()
Method Detail |
---|
public void setBasename(java.lang.String basename)
XML properties files are also supported: .g. "META-INF/expressions" will find and load "META-INF/expressions.xml", "META-INF/expressions_en.xml", etc as well.
basename
- the single basenamesetBasenames(java.lang.String[])
,
ResourceEditor
,
ResourceBundle
public void setBasenames(java.lang.String[] basenames)
XML properties files are also supported: .g. "META-INF/expressions" will find and load "META-INF/expressions.xml", "META-INF/expressions_en.xml", etc as well.
The associated resource bundles will be checked sequentially when resolving an expression key. Note that expression 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
public 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)
,
PropertiesPersister.load(java.util.Properties, java.io.InputStream)
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. "META-INF/expressions"
or "META-INF/expressions_en".setBasenames(java.lang.String[])
,
PropertiesPersister.load(java.util.Properties, java.io.InputStream)
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 setCacheSeconds(int cacheSeconds)
java.util.ResourceBundle
).
public void setPropertiesPersister(PropertiesPersister propertiesPersister)
The default is a DefaultPropertiesPersister.
DefaultPropertiesPersister
public void setResourceLoader(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
in interface ResourceLoaderAware
DefaultResourceLoader
,
ResourceLoaderAware
public Expression getExpression(java.lang.String key, java.util.Locale locale)
getExpression
in interface ExpressionSource
public void clearCache()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |