Class MessageServiceImpl

java.lang.Object
org.kuali.rice.krad.messages.MessageServiceImpl
All Implemented Interfaces:
MessageService

public class MessageServiceImpl extends Object implements MessageService
Implementation of the MessageService that allows MessageProvider implementations to be configured for exposing external message repositories

This message service implementation essentially delegates all calls down to one or more message providers. When more than one message provider is configured, providers higher up in the chain will receive priority. That is, when finding a message the first provider that has the message will be used and no others will be consulted. When finding a collection of messages, if the same message (key) exists from more than one provider, the message from the first encountered provider (in the List) will be used.

The default namespace and component are constants of the service implementation and may not be changed.

Author:
Kuali Rice Team (rice.collab@kuali.org)
  • Constructor Details

    • MessageServiceImpl

      public MessageServiceImpl()
  • Method Details

    • getMessage

      public Message getMessage(String namespace, String component, String key)
      Description copied from interface: MessageService
      Gets the Message object that has the given namespace, component, key, and the default system locale
      Specified by:
      getMessage in interface MessageService
      Parameters:
      namespace - namespace code the message belongs to, if null the default namespace should be used
      component - component code the namespace is associated with, if null the default component should be used
      key - key that identifies the message within the namespace and component
      Returns:
      Message matching message object, or null if a message was not found
      See Also:
    • getMessage

      public Message getMessage(String namespace, String component, String key, String locale)
      Description copied from interface: MessageService
      Gets the Message object that has the given namespace, component, key, and locale
      Specified by:
      getMessage in interface MessageService
      Parameters:
      namespace - namespace code the message belongs to, if null the default namespace should be used
      component - component code the namespace is associated with, if null the default component should be used
      key - key that identifies the message within the namespace and component
      locale - locale code for the message to return
      Returns:
      Message matching message object, or null if a message was not found
      See Also:
    • getMessageText

      public String getMessageText(String namespace, String component, String key)
      Description copied from interface: MessageService
      Gets the text for the message that has the given namespace, component, key, and the default system locale
      Specified by:
      getMessageText in interface MessageService
      Parameters:
      namespace - namespace code the message belongs to, if null the default namespace should be used
      component - component code the namespace is associated with, if null the default component should be used
      key - key that identifies the message within the namespace and component
      Returns:
      String text for the matched message, or null if no message was found
      See Also:
    • getMessageText

      public String getMessageText(String namespace, String component, String key, String locale)
      Description copied from interface: MessageService
      Gets the text for the message that has the given namespace, component, key, and locale
      Specified by:
      getMessageText in interface MessageService
      Parameters:
      namespace - namespace code the message belongs to, if null the default namespace should be used
      component - component code the namespace is associated with, if null the default component should be used
      key - key that identifies the message within the namespace and component
      locale - locale code for the message to return
      Returns:
      String text for the matched message, or null if no message was found
      See Also:
    • getMessageText

      public String getMessageText(String key)
      Description copied from interface: MessageService
      Gets the text for the message that has the given key within the default namespace, component, and locale (note the defaults are determined by the service implementation)
      Specified by:
      getMessageText in interface MessageService
      Parameters:
      key - key that identifies the message within the default namespace and component
      Returns:
      String text for the matched message, or null if no message was found
      See Also:
    • getMessageText

      public String getMessageText(String key, String locale)
      Description copied from interface: MessageService
      Gets the text for the message that has the given key and locale within the default namespace and component (note the defaults are determined by the service implementation)
      Specified by:
      getMessageText in interface MessageService
      Parameters:
      key - key that identifies the message within the default namespace and component
      locale - locale code for the message to return
      Returns:
      String text for the matched message, or null if no message was found
      See Also:
    • getAllMessagesForComponent

      public Collection<Message> getAllMessagesForComponent(String namespace, String component)
      Description copied from interface: MessageService
      Gets all message objects for the given namespace and component using the default locale
      Specified by:
      getAllMessagesForComponent in interface MessageService
      Parameters:
      namespace - namespace code the message belongs to
      component - component code the namespace is associated with
      Returns:
      Collection<Message> collection of messages that match, or empty collection if no messages are found
      See Also:
    • getAllMessagesForComponent

      public Collection<Message> getAllMessagesForComponent(String namespace, String component, String locale)
      Description copied from interface: MessageService
      Gets all message objects for the given namespace, component, and locale
      Specified by:
      getAllMessagesForComponent in interface MessageService
      Parameters:
      namespace - namespace code the message belongs to
      component - component code the namespace is associated with
      locale - locale code for the message to return
      Returns:
      Collection<Message> collection of messages that match, or empty collection if no messages are found
      See Also:
    • mergeMessages

      protected void mergeMessages(Collection<Message> messages, Collection<Message> messagesToMerge)
      Merges the second collection into the first collection

      If a message with the same key (namespace, component, and name) is found in both collections, the message from first collection will remain. That is, the message in the second collection will NOT override

      Parameters:
      messages - collection to be merged into
      messagesToMerge - collection that will be merged with first
    • getDefaultLocaleCode

      protected String getDefaultLocaleCode()
      Retrieves the default locale code configured through a system parameter
      Returns:
      String configured default locale
    • getMessageProviders

      protected List<MessageProvider> getMessageProviders()
      Retrieves the collection of message providers configured with the message service
      Returns:
      List<MessageProvider> message provider implementations
    • setMessageProviders

      public void setMessageProviders(List<MessageProvider> messageProviders)
      Setter for the collection of message providers that should be used by the message service implementation