| |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
org.springframework.context.support.AbstractNestingMessageSource | +--org.springframework.context.support.ReloadableResourceBundleMessageSource
MessageSource that accesses the ResourceBundles with the specified basenames. This class uses java.util.Properties instances as its internal data structure for messages.
In contrast to ResourceBundleMessageSoruce, this class supports reloading of properties files through the "cacheSeconds" setting, and also through programmatically clearing the properties cache. Since application servers do typcially cache all files loaded from the classpath, it is necessary to store resources somewhere else (for example, in the "WEB-INF" directory of a web app). Otherwise changes of files in the classpath are not reflected in the application.
Note that the "basename" respectively "basenames" property has a different convention here: It follows the basic ResourceBundle rule of not specifying file extension or language codes, but can refer to any Spring resource location (instead of being restricted to classpath resources). With a "classpath:" prefix, resources can still be loaded from the classpath, but "cacheSeconds" values other than "-1" (caching forever) will not work in this case.
Field Summary | |
final static String | PROPERTIES_SUFFIX |
Method Summary | |
synchronized void | clearCache() Clear the resource bundle cache. |
void | setApplicationContext(ApplicationContext context) |
void | setBasename(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 Spring resource location: e.g. |
void | setBasenames(String[] basenames) Set an array of basenames, each following the above-mentioned special convention. |
void | setCacheSeconds(int cacheSeconds) Set the number of seconds to cache loaded 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. |
String | toString() |
Methods inherited from class org.springframework.context.support.AbstractNestingMessageSource |
getMessage, getMessage, getMessage, setParent, setUseCodeAsDefaultMessage |
Field Detail |
public final static String PROPERTIES_SUFFIX
Method Detail |
public synchronized void clearCache()
public void setApplicationContext(ApplicationContext context)
public void setBasename(String basename)
public void setBasenames(String[] basenames)
Note that message definitions in a previous resource bundle will override ones in a later bundle, due to the sequential lookup.
public void setCacheSeconds(int cacheSeconds)
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 String toString()
Association Links |
to Class org.springframework.context.ApplicationContext
to Class java.lang.String
to Class java.util.Map
to Class java.util.Map
| |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |