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 Details

    • StorefrontResourceBundleSource

      public StorefrontResourceBundleSource()
  • Method Details

    • getTheme

      public org.springframework.ui.context.Theme getTheme(String themeName)
      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 the getParentMessageSource().

      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:
      getTheme in interface org.springframework.ui.context.ThemeSource
      Parameters:
      themeName - the theme name
      See Also:
    • computeThemeForGivenKey

      protected org.springframework.ui.context.Theme computeThemeForGivenKey(String themeName)
    • createAddOnMessageSource

      protected org.springframework.context.MessageSource createAddOnMessageSource(List<String> addOnNames, org.springframework.context.MessageSource parentMessageSource, String... nameParts)
    • splitThemeName

      protected String[] splitThemeName(String themeName)
    • 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

      public String getMessage(String code, Object[] args, String defaultMessage, Locale locale)
      Specified by:
      getMessage in interface org.springframework.context.MessageSource
    • getMessage

      public String getMessage(String code, Object[] args, Locale locale) throws org.springframework.context.NoSuchMessageException
      Specified by:
      getMessage in interface org.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:
      getMessage in interface org.springframework.context.MessageSource
      Throws:
      org.springframework.context.NoSuchMessageException
    • determineDefaultThemeName

      protected String determineDefaultThemeName()
    • getParentMessageSource

      protected org.springframework.context.MessageSource getParentMessageSource()
    • setParentMessageSource

      public void setParentMessageSource(org.springframework.context.MessageSource parentMessageSource)
    • getDefaultEncoding

      protected String getDefaultEncoding()
    • setDefaultEncoding

      public void setDefaultEncoding(String defaultEncoding)
    • getCacheSeconds

      public int getCacheSeconds()
    • setCacheSeconds

      public void setCacheSeconds(int cacheSeconds)
    • getResourceLoader

      public org.springframework.core.io.ResourceLoader getResourceLoader()
    • getSitePrefix

      public String getSitePrefix()
    • setSitePrefix

      public void setSitePrefix(String sitePrefix)
    • getThemePrefix

      public String getThemePrefix()
    • setThemePrefix

      public void setThemePrefix(String themePrefix)
    • setResourceLoader

      public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
      Specified by:
      setResourceLoader in interface org.springframework.context.ResourceLoaderAware
    • getRequiredAddOnsNameProvider

      public RequiredAddOnsNameProvider getRequiredAddOnsNameProvider()
    • setRequiredAddOnsNameProvider

      public void setRequiredAddOnsNameProvider(RequiredAddOnsNameProvider requiredAddOnsNameProvider)
    • setFallbackToSystemLocale

      public void setFallbackToSystemLocale(boolean fallbackToSystemLocale)
      Parameters:
      fallbackToSystemLocale - the fallbackToSystemLocale to set
    • getBasenamePrefix

      public String getBasenamePrefix()
    • setBasenamePrefix

      public void setBasenamePrefix(String basenamePrefix)
    • getBasePrefix

      public String getBasePrefix()
    • setBasePrefix

      public void setBasePrefix(String basePrefix)
    • getSiteThemeResolverUtils

      protected SiteThemeResolverUtils getSiteThemeResolverUtils()
    • setSiteThemeResolverUtils

      public void setSiteThemeResolverUtils(SiteThemeResolverUtils siteThemeResolverUtils)