Save This Page
Home » spring-framework-2.5.4 » org.springframework » context » [javadoc | source]
org.springframework.context
public interface: MessageSource [javadoc | source]

All Known Implementing Classes:
    FileSystemXmlApplicationContext, AbstractRefreshableApplicationContext, WebApplicationContext, ClassPathXmlApplicationContext, AbstractRefreshablePortletApplicationContext, ReloadableResourceBundleMessageSource, XmlPortletApplicationContext, ConfigurableApplicationContext, XmlWebApplicationContext, GenericWebApplicationContext, AbstractMessageSource, AbstractRefreshableWebApplicationContext, GenericApplicationContext, AbstractRefreshableConfigApplicationContext, AbstractXmlApplicationContext, StaticApplicationContext, ApplicationContext, StaticMessageSource, ResourceAdapterApplicationContext, StaticWebApplicationContext, ResourceBundleMessageSource, ConfigurablePortletApplicationContext, HierarchicalMessageSource, DelegatingMessageSource, AbstractApplicationContext, StaticPortletApplicationContext, ConfigurableWebApplicationContext

Strategy interface for resolving messages, with support for the parameterization and internationalization of such messages.

Spring provides two out-of-the-box implementations for production:

Method from org.springframework.context.MessageSource Summary:
getMessage,   getMessage,   getMessage
Method from org.springframework.context.MessageSource Detail:
 public String getMessage(MessageSourceResolvable resolvable,
    Locale locale) throws NoSuchMessageException
    Try to resolve the message using all the attributes contained within the MessageSourceResolvable argument that was passed in.

    NOTE: We must throw a NoSuchMessageException on this method since at the time of calling this method we aren't able to determine if the defaultMessage property of the resolvable is null or not.

 public String getMessage(String code,
    Object[] args,
    Locale locale) throws NoSuchMessageException
    Try to resolve the message. Treat as an error if the message can't be found.
 public String getMessage(String code,
    Object[] args,
    String defaultMessage,
    Locale locale)
    Try to resolve the message. Return default message if no message was found.