public class MessageServiceImpl extends Object implements 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.
DEFAULT_COMPONENT_CODE, DEFAULT_NAMESPACE_CODE
Constructor and Description |
---|
MessageServiceImpl() |
Modifier and Type | Method and Description |
---|---|
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
|
public MessageServiceImpl()
public Message getMessage(String namespace, String component, String key)
MessageService
Message
object that has the given namespace, component, key, and the default
system localegetMessage
in interface MessageService
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 componentMessageService.getMessage(java.lang.String, java.lang.String, java.lang.String)
public Message getMessage(String namespace, String component, String key, String locale)
MessageService
Message
object that has the given namespace, component, key, and localegetMessage
in interface MessageService
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 returnMessageService.getMessage(java.lang.String, java.lang.String, java.lang.String)
public String getMessageText(String namespace, String component, String key)
MessageService
getMessageText
in interface MessageService
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 componentMessageService.getMessageText(java.lang.String, java.lang.String, java.lang.String)
public String getMessageText(String namespace, String component, String key, String locale)
MessageService
getMessageText
in interface MessageService
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 returnMessageService.getMessageText(java.lang.String, java.lang.String, java.lang.String)
public String getMessageText(String key)
MessageService
getMessageText
in interface MessageService
key
- key that identifies the message within the default namespace and componentMessageService.getMessageText(java.lang.String, java.lang.String, java.lang.String)
public String getMessageText(String key, String locale)
MessageService
getMessageText
in interface MessageService
key
- key that identifies the message within the default namespace and componentlocale
- locale code for the message to returnMessageService.getMessageText(java.lang.String, java.lang.String, java.lang.String)
public Collection<Message> getAllMessagesForComponent(String namespace, String component)
MessageService
getAllMessagesForComponent
in interface MessageService
namespace
- namespace code the message belongs tocomponent
- component code the namespace is associated withMessageService.getAllMessagesForComponent(java.lang.String, java.lang.String)
public Collection<Message> getAllMessagesForComponent(String namespace, String component, String locale)
MessageService
getAllMessagesForComponent
in interface MessageService
namespace
- namespace code the message belongs tocomponent
- component code the namespace is associated withlocale
- locale code for the message to returnMessageService.getAllMessagesForComponent(java.lang.String, java.lang.String)
protected void mergeMessages(Collection<Message> messages, Collection<Message> messagesToMerge)
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
messages
- collection to be merged intomessagesToMerge
- collection that will be merged with firstprotected String getDefaultLocaleCode()
protected List<MessageProvider> getMessageProviders()
public void setMessageProviders(List<MessageProvider> messageProviders)
messageProviders
- Copyright © 2005–2016 The Kuali Foundation. All rights reserved.