Class StorefrontResourceBundleSource
java.lang.Object
de.hybris.platform.yacceleratorstorefront.web.theme.StorefrontResourceBundleSource
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.MessageSource,org.springframework.context.ResourceLoaderAware,org.springframework.ui.context.ThemeSource
public class StorefrontResourceBundleSource
extends Object
implements org.springframework.ui.context.ThemeSource, org.springframework.context.ResourceLoaderAware, org.springframework.context.MessageSource
CustomResourceBundleThemeSource. Supports site and theme specific resource bundles. Uses a
ReloadableResourceBundleMessageSource to load the theme file. Delegates to a message source if the theme specific
file cannot be found.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.springframework.ui.context.ThemecomputeThemeForGivenKey(String themeName) protected org.springframework.context.MessageSourcecreateAddOnMessageSource(List<String> addOnNames, org.springframework.context.MessageSource parentMessageSource, String... nameParts) protected org.springframework.context.support.AbstractMessageSourcecreateMessageSource(String basename) protected org.springframework.context.MessageSourcecreateMessageSource(String basename, org.springframework.context.MessageSource parentMessageSource) protected Stringintprotected StringgetMessage(String code, Object[] args, String defaultMessage, Locale locale) getMessage(String code, Object[] args, Locale locale) getMessage(org.springframework.context.MessageSourceResolvable resolvable, Locale locale) protected org.springframework.context.MessageSourceorg.springframework.core.io.ResourceLoaderprotected SiteThemeResolverUtilsorg.springframework.ui.context.ThemeThis implementation returns a SimpleTheme instance, holding a ResourceBundle-based MessageSource whose basename corresponds to the given site name (prefixed by the configured "siteBasenamePrefix") which then delegates to a ResourceBundle-based MessageSource whose basename corresponds to the theme name (prefixed by the configured "themeBasenamePrefix") which in turn delegates to thegetParentMessageSource().voidsetBasenamePrefix(String basenamePrefix) voidsetBasePrefix(String basePrefix) voidsetCacheSeconds(int cacheSeconds) voidsetDefaultEncoding(String defaultEncoding) voidsetFallbackToSystemLocale(boolean fallbackToSystemLocale) voidsetParentMessageSource(org.springframework.context.MessageSource parentMessageSource) voidsetRequiredAddOnsNameProvider(RequiredAddOnsNameProvider requiredAddOnsNameProvider) voidsetResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader) voidsetSitePrefix(String sitePrefix) voidsetSiteThemeResolverUtils(SiteThemeResolverUtils siteThemeResolverUtils) voidsetThemePrefix(String themePrefix) protected String[]splitThemeName(String themeName)
-
Constructor Details
-
StorefrontResourceBundleSource
public StorefrontResourceBundleSource()
-
-
Method Details
-
getTheme
This implementation returns a SimpleTheme instance, holding a ResourceBundle-based MessageSource whose basename corresponds to the given site name (prefixed by the configured "siteBasenamePrefix") which then delegates to a ResourceBundle-based MessageSource whose basename corresponds to the theme name (prefixed by the configured "themeBasenamePrefix") which in turn delegates to thegetParentMessageSource().SimpleTheme instances are cached per theme name.
Uses reloadable MessageSources to reflect changes to the underlying files. Set the
setCacheSeconds(int)to control how long the files should be cached for.- Specified by:
getThemein interfaceorg.springframework.ui.context.ThemeSource- Parameters:
themeName- the theme name- See Also:
-
computeThemeForGivenKey
-
createAddOnMessageSource
-
splitThemeName
-
createMessageSource
protected org.springframework.context.MessageSource createMessageSource(String basename, org.springframework.context.MessageSource parentMessageSource) -
createMessageSource
protected org.springframework.context.support.AbstractMessageSource createMessageSource(String basename) -
getMessage
- Specified by:
getMessagein interfaceorg.springframework.context.MessageSource
-
getMessage
public String getMessage(String code, Object[] args, Locale locale) throws org.springframework.context.NoSuchMessageException - Specified by:
getMessagein interfaceorg.springframework.context.MessageSource- Throws:
org.springframework.context.NoSuchMessageException
-
getMessage
public String getMessage(org.springframework.context.MessageSourceResolvable resolvable, Locale locale) throws org.springframework.context.NoSuchMessageException - Specified by:
getMessagein interfaceorg.springframework.context.MessageSource- Throws:
org.springframework.context.NoSuchMessageException
-
determineDefaultThemeName
-
getParentMessageSource
protected org.springframework.context.MessageSource getParentMessageSource() -
setParentMessageSource
public void setParentMessageSource(org.springframework.context.MessageSource parentMessageSource) -
getDefaultEncoding
-
setDefaultEncoding
-
getCacheSeconds
public int getCacheSeconds() -
setCacheSeconds
public void setCacheSeconds(int cacheSeconds) -
getResourceLoader
public org.springframework.core.io.ResourceLoader getResourceLoader() -
getSitePrefix
-
setSitePrefix
-
getThemePrefix
-
setThemePrefix
-
setResourceLoader
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader) - Specified by:
setResourceLoaderin interfaceorg.springframework.context.ResourceLoaderAware
-
getRequiredAddOnsNameProvider
-
setRequiredAddOnsNameProvider
-
setFallbackToSystemLocale
public void setFallbackToSystemLocale(boolean fallbackToSystemLocale) - Parameters:
fallbackToSystemLocale- the fallbackToSystemLocale to set
-
getBasenamePrefix
-
setBasenamePrefix
-
getBasePrefix
-
setBasePrefix
-
getSiteThemeResolverUtils
-
setSiteThemeResolverUtils
-