类 ResourceBundleThemeSource
- java.lang.Object
- org.springframework.ui.context.support.ResourceBundleThemeSource
- 所有已实现的接口:
Aware
,BeanClassLoaderAware
,HierarchicalThemeSource
,ThemeSource
public class ResourceBundleThemeSource extends Object implements HierarchicalThemeSource, BeanClassLoaderAware
ThemeSource
implementation that looks up an individualResourceBundle
per theme. The theme name gets interpreted as ResourceBundle basename, supporting a common basename prefix for all themes.- 作者:
- Jean-Pierre Pawlak, Juergen Hoeller
- 另请参阅:
setBasenamePrefix(java.lang.String)
,ResourceBundle
,ResourceBundleMessageSource
构造器概要
构造器 构造器 说明 ResourceBundleThemeSource()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected MessageSource
createMessageSource(String basename)
Create a MessageSource for the given basename, to be used as MessageSource for the corresponding theme.ThemeSource
getParentThemeSource()
Return the parent of this ThemeSource, ornull
if none.Theme
getTheme(String themeName)
This implementation returns a SimpleTheme instance, holding a ResourceBundle-based MessageSource whose basename corresponds to the given theme name (prefixed by the configured "basenamePrefix").protected void
initParent(Theme theme)
Initialize the MessageSource of the given theme with the one from the corresponding parent of this ThemeSource.void
setBasenamePrefix(String basenamePrefix)
Set the prefix that gets applied to the ResourceBundle basenames, i.e. the theme names.void
setBeanClassLoader(ClassLoader beanClassLoader)
Callback that supplies the beanclass loader
to a bean instance.void
setDefaultEncoding(String defaultEncoding)
Set the default charset to use for parsing resource bundle 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
setParentThemeSource(ThemeSource parent)
Set the parent that will be used to try to resolve theme messages that this object can't resolve.
构造器详细资料
ResourceBundleThemeSource
public ResourceBundleThemeSource()
方法详细资料
setParentThemeSource
public void setParentThemeSource(ThemeSource parent)
从接口复制的说明:HierarchicalThemeSource
Set the parent that will be used to try to resolve theme messages that this object can't resolve.- 指定者:
setParentThemeSource
在接口中HierarchicalThemeSource
- 参数:
parent
- the parent ThemeSource that will be used to resolve messages that this object can't resolve. May benull
, in which case no further resolution is possible.
getParentThemeSource
public ThemeSource getParentThemeSource()
从接口复制的说明:HierarchicalThemeSource
Return the parent of this ThemeSource, ornull
if none.
setBasenamePrefix
public void setBasenamePrefix(String basenamePrefix)
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.
setDefaultEncoding
public void setDefaultEncoding(String defaultEncoding)
Set the default charset to use for parsing resource bundle files.ResourceBundleMessageSource
's default is thejava.util.ResourceBundle
default encoding: ISO-8859-1.
setFallbackToSystemLocale
public void setFallbackToSystemLocale(boolean fallbackToSystemLocale)
Set whether to fall back to the system Locale if no files for a specific Locale have been found.ResourceBundleMessageSource
's default is "true".
setBeanClassLoader
public void setBeanClassLoader(ClassLoader beanClassLoader)
从接口复制的说明:BeanClassLoaderAware
Callback that supplies the beanclass loader
to a bean instance.Invoked after the population of normal bean properties but before an initialization callback such as
InitializingBean's
InitializingBean.afterPropertiesSet()
method or a custom init-method.- 指定者:
setBeanClassLoader
在接口中BeanClassLoaderAware
- 参数:
beanClassLoader
- the owning class loader; may benull
in which case a defaultClassLoader
must be used, for example theClassLoader
obtained viaClassUtils.getDefaultClassLoader()
getTheme
public Theme getTheme(String themeName)
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.
- 指定者:
getTheme
在接口中ThemeSource
- 参数:
themeName
- the name of the theme- 返回:
- the corresponding Theme, or
null
if none defined. Note that, by convention, a ThemeSource should at least be able to return a default Theme for the default theme name "theme" but may also return default Themes for other theme names. - 另请参阅:
setBasenamePrefix(java.lang.String)
,createMessageSource(java.lang.String)
createMessageSource
protected MessageSource createMessageSource(String basename)
Create a MessageSource for the given basename, to be used as MessageSource for the corresponding theme.Default implementation creates a ResourceBundleMessageSource. for the given basename. A subclass could create a specifically configured ReloadableResourceBundleMessageSource, for example.
- 参数:
basename
- the basename to create a MessageSource for- 返回:
- the MessageSource
- 另请参阅:
ResourceBundleMessageSource
,ReloadableResourceBundleMessageSource
initParent
protected void initParent(Theme theme)
Initialize the MessageSource of the given theme with the one from the corresponding parent of this ThemeSource.- 参数:
theme
- the Theme to (re-)initialize