类 ResourceBundleThemeSource
- java.lang.Object
- org.springframework.ui.context.support.ResourceBundleThemeSource
- 所有已实现的接口:
Aware,BeanClassLoaderAware,HierarchicalThemeSource,ThemeSource
public class ResourceBundleThemeSource extends Object implements HierarchicalThemeSource, BeanClassLoaderAware
ThemeSourceimplementation that looks up an individualResourceBundleper 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 MessageSourcecreateMessageSource(String basename)Create a MessageSource for the given basename, to be used as MessageSource for the corresponding theme.ThemeSourcegetParentThemeSource()Return the parent of this ThemeSource, ornullif none.ThemegetTheme(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 voidinitParent(Theme theme)Initialize the MessageSource of the given theme with the one from the corresponding parent of this ThemeSource.voidsetBasenamePrefix(String basenamePrefix)Set the prefix that gets applied to the ResourceBundle basenames, i.e. the theme names.voidsetBeanClassLoader(ClassLoader beanClassLoader)Callback that supplies the beanclass loaderto a bean instance.voidsetDefaultEncoding(String defaultEncoding)Set the default charset to use for parsing resource bundle files.voidsetFallbackToSystemLocale(boolean fallbackToSystemLocale)Set whether to fall back to the system Locale if no files for a specific Locale have been found.voidsetParentThemeSource(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(@Nullable ThemeSource parent)
从接口复制的说明:HierarchicalThemeSourceSet 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
@Nullable public ThemeSource getParentThemeSource()
从接口复制的说明:HierarchicalThemeSourceReturn the parent of this ThemeSource, ornullif none.
setBasenamePrefix
public void setBasenamePrefix(@Nullable 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.ResourceBundleusage.
setDefaultEncoding
public void setDefaultEncoding(@Nullable String defaultEncoding)
Set the default charset to use for parsing resource bundle files.ResourceBundleMessageSource's default is thejava.util.ResourceBundledefault 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(@Nullable ClassLoader beanClassLoader)
从接口复制的说明:BeanClassLoaderAwareCallback that supplies the beanclass loaderto a bean instance.Invoked after the population of normal bean properties but before an initialization callback such as
InitializingBean'sInitializingBean.afterPropertiesSet()method or a custom init-method.- 指定者:
setBeanClassLoader在接口中BeanClassLoaderAware- 参数:
beanClassLoader- the owning class loader
getTheme
@Nullable 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
nullif 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