Class AddonAwareMessageSource

java.lang.Object
org.springframework.context.support.MessageSourceSupport
org.springframework.context.support.AbstractMessageSource
org.springframework.context.support.AbstractResourceBasedMessageSource
org.springframework.context.support.ReloadableResourceBundleMessageSource
de.hybris.platform.ycommercewebservices.util.ws.impl.AddonAwareMessageSource
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.context.HierarchicalMessageSource, org.springframework.context.MessageSource, org.springframework.context.ResourceLoaderAware

public class AddonAwareMessageSource extends org.springframework.context.support.ReloadableResourceBundleMessageSource implements org.springframework.context.ApplicationContextAware
MessageSource which can be aware of installed addons and extract message bundles from them.
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.springframework.context.support.ReloadableResourceBundleMessageSource

    org.springframework.context.support.ReloadableResourceBundleMessageSource.PropertiesHolder
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.springframework.core.io.ContextResource
     
    protected List<String>
     
    protected Predicate<String>
     
    protected Predicate<String>
     
    protected boolean
     

    Fields inherited from class org.springframework.context.support.MessageSourceSupport

    logger
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
    formatPath(String path, String basePath)
    Formats absolute file path using basePath to format acceptable by @link ReloadableResourceBundleMessageSource} Basename property
    protected Collection<String>
    Searches for files defined by fileFilter under directories defined by dirFilter.
    org.springframework.core.io.ContextResource
     
     
     
    boolean
     
    protected Collection<String>
    mapAddonLocation(Collection<String> addonsPath, String basePath)
    Maps each element of addonsPath to valid message bundle path.
    void
    setApplicationContext(org.springframework.context.ApplicationContext arg0)
     
    void
    setBaseAddonDir(org.springframework.core.io.ContextResource baseAddonDir)
     
    void
    setBasename(String basename)
     
    void
    setBasenames(String... basenames)
     
    void
     
    void
     
    void
    setScanForAddons(boolean scanForAddons)
     
    void
    Searches for messages in installed addons and adds them to basenames
    protected boolean
     
    protected boolean
     

    Methods inherited from class org.springframework.context.support.ReloadableResourceBundleMessageSource

    calculateAllFilenames, calculateFilenamesForLocale, clearCache, clearCacheIncludingAncestors, getMergedProperties, getProperties, loadProperties, newProperties, refreshProperties, resolveCode, resolveCodeWithoutArguments, setConcurrentRefresh, setFileEncodings, setPropertiesPersister, setResourceLoader, toString

    Methods inherited from class org.springframework.context.support.AbstractResourceBasedMessageSource

    addBasenames, getBasenameSet, getCacheMillis, getDefaultEncoding, getDefaultLocale, isFallbackToSystemLocale, setCacheMillis, setCacheSeconds, setDefaultEncoding, setDefaultLocale, setFallbackToSystemLocale

    Methods inherited from class org.springframework.context.support.AbstractMessageSource

    getCommonMessages, getDefaultMessage, getDefaultMessage, getMessage, getMessage, getMessage, getMessageFromParent, getMessageInternal, getParentMessageSource, isUseCodeAsDefaultMessage, resolveArguments, setCommonMessages, setParentMessageSource, setUseCodeAsDefaultMessage

    Methods inherited from class org.springframework.context.support.MessageSourceSupport

    createMessageFormat, formatMessage, isAlwaysUseMessageFormat, renderDefaultMessage, setAlwaysUseMessageFormat

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • scanForAddons

      protected boolean scanForAddons
    • baseAddonDir

      protected org.springframework.core.io.ContextResource baseAddonDir
    • fileFilter

      protected Predicate<String> fileFilter
    • dirFilter

      protected Predicate<String> dirFilter
    • basenames

      protected List<String> basenames
  • Constructor Details

    • AddonAwareMessageSource

      public AddonAwareMessageSource()
  • Method Details

    • setupAddonMessages

      @PostConstruct public void setupAddonMessages()
      Searches for messages in installed addons and adds them to basenames
    • getAddonsMessages

      protected Collection<String> getAddonsMessages() throws IOException
      Searches for files defined by fileFilter under directories defined by dirFilter.
      Returns:
      Collection of paths to message bundle files
      Throws:
      IOException
    • validatePath

      protected boolean validatePath(String path)
    • validateFilename

      protected boolean validateFilename(String path)
    • mapAddonLocation

      protected Collection<String> mapAddonLocation(Collection<String> addonsPath, String basePath)
      Maps each element of addonsPath to valid message bundle path. Result collection is also filtered to remove empty, invalid and duplicated entries.
      Parameters:
      addonsPath - paths to transform
      basePath - from where result path should start
      Returns:
      collection of paths to message bundles
    • formatPath

      protected String formatPath(String path, String basePath)
      Formats absolute file path using basePath to format acceptable by @link ReloadableResourceBundleMessageSource} Basename property
    • setBasename

      public void setBasename(String basename)
      Overrides:
      setBasename in class org.springframework.context.support.AbstractResourceBasedMessageSource
    • setBasenames

      public void setBasenames(String... basenames)
      Overrides:
      setBasenames in class org.springframework.context.support.AbstractResourceBasedMessageSource
    • isScanForAddons

      public boolean isScanForAddons()
      Returns:
      the scanForAddons
    • setScanForAddons

      public void setScanForAddons(boolean scanForAddons)
      Parameters:
      scanForAddons - the scanForAddons to set
    • getBaseAddonDir

      public org.springframework.core.io.ContextResource getBaseAddonDir()
      Returns:
      the baseAddonDir
    • setBaseAddonDir

      public void setBaseAddonDir(org.springframework.core.io.ContextResource baseAddonDir)
      Parameters:
      baseAddonDir - the baseAddonDir to set
    • getFileFilter

      public Predicate<String> getFileFilter()
      Returns:
      the fileFilter
    • setFileFilter

      public void setFileFilter(Predicate<String> fileFilter)
      Parameters:
      fileFilter - the fileFilter to set
    • getDirFilter

      public Predicate<String> getDirFilter()
      Returns:
      the dirFilter
    • setDirFilter

      public void setDirFilter(Predicate<String> dirFilter)
      Parameters:
      dirFilter - the dirFilter to set
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext arg0)
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware