Class ProjectResourceMessageSource

java.lang.Object
org.springframework.context.support.MessageSourceSupport
org.springframework.context.support.AbstractMessageSource
org.springframework.context.support.AbstractResourceBasedMessageSource
org.springframework.context.support.ReloadableResourceBundleMessageSource
ru.cg.webbpm.studio.core.api.utils.ProjectResourceMessageSource
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.HierarchicalMessageSource, org.springframework.context.MessageSource, org.springframework.context.ResourceLoaderAware

public class ProjectResourceMessageSource extends org.springframework.context.support.ReloadableResourceBundleMessageSource
Message source for project resource bundles. Treats empty properties as null. Returns message as Optional instead of throwing error if message is not found. If message is not found in system locale falls back to english locale. Fallback works only with getMessage(String, Object...), all other methods are final and cannot be overridden. Also fixes bug with file based resources on windows.
Author:
Tim Urmancheev
  • Nested Class Summary

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

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

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

    logger
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    getMessage(String code, Object... args)
     
     
    void
    setBasenames(String... basenames)
     
    void
     
    tryGetMessage(String code, Object[] args, Locale locale)
     

    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, setBasename, 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
  • Constructor Details

    • ProjectResourceMessageSource

      public ProjectResourceMessageSource()
  • Method Details

    • setFileBaseName

      public void setFileBaseName(Path basename)
    • setBasenames

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

      public Optional<String> getMessage(String code, Object... args)
    • tryGetMessage

      public Optional<String> tryGetMessage(String code, Object[] args, Locale locale)
    • getMessages

      public Properties getMessages(Locale locale)