Class AbstractMessageSource

java.lang.Object
org.springframework.context.support.MessageSourceSupport
org.springframework.context.support.AbstractMessageSource
All Implemented Interfaces:
HierarchicalMessageSource, MessageSource
Direct Known Subclasses:
AbstractResourceBasedMessageSource, StaticMessageSource

public abstract class AbstractMessageSource extends MessageSourceSupport implements HierarchicalMessageSource
Abstract implementation of the HierarchicalMessageSource interface, implementing common handling of message variants, making it easy to implement a specific strategy for a concrete MessageSource.

Subclasses must implement the abstract resolveCode(String, Locale) method. For efficient resolution of messages without arguments, the resolveCodeWithoutArguments(String, Locale) method should be overridden as well, resolving messages without a MessageFormat being involved.

Note: By default, message texts are only parsed through MessageFormat if arguments have been passed in for the message. In case of no arguments, message texts will be returned as-is. As a consequence, you should only use MessageFormat escaping for messages with actual arguments, and keep all other messages unescaped. If you prefer to escape all messages, set the "alwaysUseMessageFormat" flag to "true".

Supports not only MessageSourceResolvables as primary messages but also resolution of message arguments that are in turn MessageSourceResolvables themselves.

This class does not implement caching of messages per code, thus subclasses can dynamically change messages over time. Subclasses are encouraged to cache their messages in a modification-aware fashion, allowing for hot deployment of updated messages.

Author:
Juergen Hoeller, Rod Johnson
See Also:
  • Field Summary

    Fields inherited from class MessageSourceSupport

    logger
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected