org.kuali.rice.krad.messages
Class MessageServiceImpl

java.lang.Object
  extended by 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)

Field Summary
 
Fields inherited from interface org.kuali.rice.krad.messages.MessageService
DEFAULT_COMPONENT_CODE, DEFAULT_NAMESPACE_CODE
 
Constructor Summary
MessageServiceImpl()
           
 
Method Summary
 Collection<Message> getAllMessagesForComponent(String namespace, String component)
          Gets all message objects for the given namespace and component using the default locale
 Collection<Message> getAllMessagesForComponent(String namespace, String component, String locale)
          Gets all message objects for the given namespace, component, and locale
protected  String getDefaultLocaleCode()
          Retrieves the default locale code configured through a system parameter
 Message getMessage(String namespace, String component, String key)
          Gets the Message object that has the given namespace, component, key, and the default system locale
 Message getMessage(String namespace, String component, String key, String locale)
          Gets the Message object that has the given namespace, component, key, and locale
protected  List<MessageProvider> getMessageProviders()
          Retrieves the collection of message providers configured with the message service
 String getMessageText(String key)
          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)
 String getMessageText(String key, String locale)
          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)
 String getMessageText(String namespace, String component, String key)
          Gets the text for the message that has the given namespace, component, key, and the default system locale
 String getMessageText(String namespace, String component, String key, String locale)
          Gets the text for the message that has the given namespace, component, key, and locale
protected  void mergeMessages(Collection<Message> messages, Collection<Message> messagesToMerge)
          Merges the second collection into the first collection
 void setMessageProviders(List<MessageProvider> messageProviders)
          Setter for the collection of message providers that should be used by the message service implementation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageServiceImpl

public MessageServiceImpl()
Method Detail

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:
MessageService.getMessage(java.lang.String, java.lang.String, java.lang.String)

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:
MessageService.getMessage(java.lang.String, java.lang.String, java.lang.String)

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:
MessageService.getMessageText(java.lang.String, java.lang.String, java.lang.String)

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:
MessageService.getMessageText(java.lang.String, java.lang.String, java.lang.String)

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:
MessageService.getMessageText(java.lang.String, java.lang.String, java.lang.String)

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:
MessageService.getMessageText(java.lang.String, java.lang.String, java.lang.String)

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 collection of messages that match, or empty collection if no messages are found
See Also:
MessageService.getAllMessagesForComponent(java.lang.String, java.lang.String)

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 collection of messages that match, or empty collection if no messages are found
See Also:
MessageService.getAllMessagesForComponent(java.lang.String, java.lang.String)

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 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

Parameters:
messageProviders -


Copyright © 2005–2014 The Kuali Foundation. All rights reserved.