spring-framework / org.springframework.context.support / ResourceBundleMessageSource

ResourceBundleMessageSource

open class ResourceBundleMessageSource : AbstractResourceBasedMessageSource, BeanClassLoaderAware

org.springframework.context.MessageSource implementation that accesses resource bundles using specified basenames. This class relies on the underlying JDK's java.util.ResourceBundle implementation, in combination with the JDK's standard message parsing provided by java.text.MessageFormat.

This MessageSource caches both the accessed ResourceBundle instances and the generated MessageFormats for each message. It also implements rendering of no-arg messages without MessageFormat, as supported by the AbstractMessageSource base class. The caching provided by this MessageSource is significantly faster than the built-in caching of the java.util.ResourceBundle class.

The basenames follow java.util.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. Note that the JDK's standard ResourceBundle treats dots as package separators: This means that "test.theme" is effectively equivalent to "test/theme".

Author
Rod Johnson

Author
Juergen Hoeller

See Also
#setBasenamesReloadableResourceBundleMessageSourcejava.util.ResourceBundlejava.text.MessageFormat

Constructors

<init>

ResourceBundleMessageSource()

org.springframework.context.MessageSource implementation that accesses resource bundles using specified basenames. This class relies on the underlying JDK's java.util.ResourceBundle implementation, in combination with the JDK's standard message parsing provided by java.text.MessageFormat.

This MessageSource caches both the accessed ResourceBundle instances and the generated MessageFormats for each message. It also implements rendering of no-arg messages without MessageFormat, as supported by the AbstractMessageSource base class. The caching provided by this MessageSource is significantly faster than the built-in caching of the java.util.ResourceBundle class.

The basenames follow java.util.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. Note that the JDK's standard ResourceBundle treats dots as package separators: This means that "test.theme" is effectively equivalent to "test/theme".

Functions

setBeanClassLoader

open fun setBeanClassLoader(classLoader: ClassLoader): Unit

setBundleClassLoader

open fun setBundleClassLoader(classLoader: ClassLoader): Unit

Set the ClassLoader to load resource bundles with.

Default is the containing BeanFactory's org.springframework.beans.factory.BeanClassLoaderAware, or the default ClassLoader determined by org.springframework.util.ClassUtils#getDefaultClassLoader() if not running within a BeanFactory.

toString

open fun toString(): String

Show the configuration of this MessageSource.