Generated by
JDiff

org.springframework.context.support Documentation Differences

This file contains all the changes in documentation in the package org.springframework.context.support as colored differences. Deletions are shown like this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

Class ReloadableResourceBundleMessageSource

Spring-specific org.springframework.context.MessageSource implementation that implementation that accesses resource bundles using specified basenames, participating in the Spring org.springframework.context.ApplicationContext's resource loading. This

In contrast to the JDK-based ResourceBundleMessageSource, this class uses java.util.Properties instances as its custom data structure for for messages, loading them via a org.springframework.util.PropertiesPersister strategy:strategy from TheSpring defaultResource handles. This strategy is not only capable of reloading files based on timestamp changes, but also of loading properties files with a specific character encoding,. ifIt will detect XML property files as desiredwell.

In contrast to ResourceBundleMessageSource, this class supports reloading of properties files through the "cacheSeconds" setting, and also through programmatically clearing the properties cache. Since application servers typically 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 will not be reflected in the application.

Note that the base names set as "basenames" property are treated in a slightly different fashion than the "basenames" property of ResourceBundleMessageSource. 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.

This MessageSource implementation is usually slightly faster than ResourceBundleMessageSource, which builds on java.util.ResourceBundle - in the default mode, i.e. when caching forever. With "cacheSeconds" set to 1, message lookup takes about twice as long - with the benefit that changes in individual properties files are detected with a maximum delay of 1 second. Higher "cacheSeconds" values usually do not make a significant difference.

This MessageSource can easily be used outside of an org.springframework.context.ApplicationContext: It will use a org.springframework.core.io.DefaultResourceLoader as default, simply getting overridden with the ApplicationContext's resource loader if running in a context. It does not have any other specific dependencies.

Thanks to Thomas Achleitner for providing the initial implementation of this message source! @author Juergen Hoeller @see #setCacheSeconds @see #setBasenames @see #setDefaultEncoding @see #setFileEncodings @see #setPropertiesPersister @see #setResourceLoader @see org.springframework.util.DefaultPropertiesPersister @see org.springframework.core.io.DefaultResourceLoader @see ResourceBundleMessageSource @see java.util.ResourceBundle

Class ReloadableResourceBundleMessageSource, void setDefaultEncoding(String)

Set the default charset to use for parsing properties files. Used if no file-specific charset is specified for a file.

Default is none, using the java.util.Properties default encoding: ISO-8859-1.

Only applies to classic properties files, not to XML files. @param defaultEncoding the default charset @see #setFileEncodings @see org.springframework.util.PropertiesPersister#load

Class ReloadableResourceBundleMessageSource, void setFallbackToSystemLocale(boolean)

Set whether to fall back to the system Locale if no files for a specific Locale have been found. Default is "true"; if this is turned off, the only fallback will be the default file (e.g. "messages.properties" for basename "messages").

Falling back to the system Locale is the default behavior of java.util.ResourceBundle. However, this is often not desirablenot desirable in an application server environment, where the system Locale Locale is not relevantrelevant to the application at all: Set this flag to "false" in such a scenario.