Class MessageServiceImpl
- All Implemented Interfaces:
MessageService
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAllMessagesForComponent(String namespace, String component) Gets all message objects for the given namespace and component using the default localegetAllMessagesForComponent(String namespace, String component, String locale) Gets all message objects for the given namespace, component, and localeprotected StringRetrieves the default locale code configured through a system parametergetMessage(String namespace, String component, String key) Gets theMessageobject that has the given namespace, component, key, and the default system localegetMessage(String namespace, String component, String key, String locale) Gets theMessageobject that has the given namespace, component, key, and localeprotected List<MessageProvider> Retrieves the collection of message providers configured with the message servicegetMessageText(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)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)getMessageText(String namespace, String component, String key) Gets the text for the message that has the given namespace, component, key, and the default system localegetMessageText(String namespace, String component, String key, String locale) Gets the text for the message that has the given namespace, component, key, and localeprotected voidmergeMessages(Collection<Message> messages, Collection<Message> messagesToMerge) Merges the second collection into the first collectionvoidsetMessageProviders(List<MessageProvider> messageProviders) Setter for the collection of message providers that should be used by the message service implementation
-
Constructor Details
-
MessageServiceImpl
public MessageServiceImpl()
-
-
Method Details
-
getMessage
Description copied from interface:MessageServiceGets theMessageobject that has the given namespace, component, key, and the default system locale- Specified by:
getMessagein interfaceMessageService- Parameters:
namespace- namespace code the message belongs to, if null the default namespace should be usedcomponent- component code the namespace is associated with, if null the default component should be usedkey- 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
Description copied from interface:MessageServiceGets theMessageobject that has the given namespace, component, key, and locale- Specified by:
getMessagein interfaceMessageService- Parameters:
namespace- namespace code the message belongs to, if null the default namespace should be usedcomponent- component code the namespace is associated with, if null the default component should be usedkey- key that identifies the message within the namespace and componentlocale- locale code for the message to return- Returns:
- Message matching message object, or null if a message was not found
- See Also:
-
getMessageText
Description copied from interface:MessageServiceGets the text for the message that has the given namespace, component, key, and the default system locale- Specified by:
getMessageTextin interfaceMessageService- Parameters:
namespace- namespace code the message belongs to, if null the default namespace should be usedcomponent- component code the namespace is associated with, if null the default component should be usedkey- 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
Description copied from interface:MessageServiceGets the text for the message that has the given namespace, component, key, and locale- Specified by:
getMessageTextin interfaceMessageService- Parameters:
namespace- namespace code the message belongs to, if null the default namespace should be usedcomponent- component code the namespace is associated with, if null the default component should be usedkey- key that identifies the message within the namespace and componentlocale- locale code for the message to return- Returns:
- String text for the matched message, or null if no message was found
- See Also:
-
getMessageText
Description copied from interface:MessageServiceGets 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:
getMessageTextin interfaceMessageService- 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
Description copied from interface:MessageServiceGets 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:
getMessageTextin interfaceMessageService- Parameters:
key- key that identifies the message within the default namespace and componentlocale- locale code for the message to return- Returns:
- String text for the matched message, or null if no message was found
- See Also:
-
getAllMessagesForComponent
Description copied from interface:MessageServiceGets all message objects for the given namespace and component using the default locale- Specified by:
getAllMessagesForComponentin interfaceMessageService- Parameters:
namespace- namespace code the message belongs tocomponent- 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:MessageServiceGets all message objects for the given namespace, component, and locale- Specified by:
getAllMessagesForComponentin interfaceMessageService- Parameters:
namespace- namespace code the message belongs tocomponent- component code the namespace is associated withlocale- 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
Merges the second collection into the first collectionIf 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 intomessagesToMerge- collection that will be merged with first
-
getDefaultLocaleCode
Retrieves the default locale code configured through a system parameter- Returns:
- String configured default locale
-
getMessageProviders
Retrieves the collection of message providers configured with the message service- Returns:
- List<MessageProvider> message provider implementations
-
setMessageProviders
Setter for the collection of message providers that should be used by the message service implementation
-