Class ThreadLocalMessageSource

  • All Implemented Interfaces:
    org.springframework.beans.factory.Aware, org.springframework.context.MessageSource, org.springframework.context.ResourceLoaderAware

    public class ThreadLocalMessageSource
    extends Object
    implements org.springframework.context.MessageSource, org.springframework.context.ResourceLoaderAware
    This class is a wrapper for the messageSource as used in WebManager. It produces a ReloadableResourceBundleMessageSource that is saved in a threadsafe way to prevent mix-up with threads that use the messageSource bean simultaneously.
    Since:
    WebManager 9.13.1
    Author:
    wouterr
    • Constructor Detail

      • ThreadLocalMessageSource

        public ThreadLocalMessageSource()
    • Method Detail

      • 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
      • 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​(String code,
                                 Object[] args,
                                 String defaultMessage,
                                 Locale locale)
        Specified by:
        getMessage in interface org.springframework.context.MessageSource
      • setBasename

        public void setBasename​(String basename)
        Sets the basename.
        Parameters:
        the - basename to set
      • getBasename

        public String getBasename()
        Retrieves the basename.
        Returns:
        the basename
      • setBasenames

        public void setBasenames​(String[] basenames)
        Sets the basenames of the ReloadableResourceBundleMessageSource.
        Parameters:
        basenames - Array of strings
      • clearCache

        public void clearCache()
        Cleares the cached ReloadableResourceBundleMessageSource by calling the clearCahce method on the instantiated bean or creates a new ReloadableResourceBundleMessageSource when no bean is available.
      • initialize

        public void initialize()
        Initializes the bean. Creates a new ReloadableResourceBundleMessageSource with a basename and ResourceLoader.
      • cleanUp

        public void cleanUp()
        Destroys the existing instance of the ReloadableResourceBundleMessageSource on the current ThreadLocal
      • setResourceLoader

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