spring-framework / org.springframework.ui.context.support / ResourceBundleThemeSource

ResourceBundleThemeSource

open class ResourceBundleThemeSource : HierarchicalThemeSource, BeanClassLoaderAware

ThemeSource implementation that looks up an individual java.util.ResourceBundle per theme. The theme name gets interpreted as ResourceBundle basename, supporting a common basename prefix for all themes.

Author
Jean-Pierre Pawlak

Author
Juergen Hoeller

See Also
#setBasenamePrefixjava.util.ResourceBundleorg.springframework.context.support.ResourceBundleMessageSource

Constructors

<init>

ResourceBundleThemeSource()

ThemeSource implementation that looks up an individual java.util.ResourceBundle per theme. The theme name gets interpreted as ResourceBundle basename, supporting a common basename prefix for all themes.

Functions

getParentThemeSource

open fun getParentThemeSource(): ThemeSource

getTheme

open fun getTheme(themeName: String): Theme

This implementation returns a SimpleTheme instance, holding a ResourceBundle-based MessageSource whose basename corresponds to the given theme name (prefixed by the configured "basenamePrefix").

SimpleTheme instances are cached per theme name. Use a reloadable MessageSource if themes should reflect changes to the underlying files.

setBasenamePrefix

open fun setBasenamePrefix(basenamePrefix: String): Unit

Set the prefix that gets applied to the ResourceBundle basenames, i.e. the theme names. E.g.: basenamePrefix="test.", themeName="theme" -> basename="test.theme".

Note that ResourceBundle names are effectively classpath locations: As a consequence, the JDK's standard ResourceBundle treats dots as package separators. This means that "test.theme" is effectively equivalent to "test/theme", just like it is for programmatic java.util.ResourceBundle usage.

setBeanClassLoader

open fun setBeanClassLoader(beanClassLoader: ClassLoader): Unit

setDefaultEncoding

open fun setDefaultEncoding(defaultEncoding: String): Unit

Set the default charset to use for parsing resource bundle files.

ResourceBundleMessageSource's default is the java.util.ResourceBundle default encoding: ISO-8859-1.

setFallbackToSystemLocale

open fun setFallbackToSystemLocale(fallbackToSystemLocale: Boolean): Unit

Set whether to fall back to the system Locale if no files for a specific Locale have been found.

ResourceBundleMessageSource's default is "true".

setParentThemeSource

open fun setParentThemeSource(parent: ThemeSource): Unit