Class DefaultMessageContext
java.lang.Object
org.springframework.binding.message.DefaultMessageContext
- All Implemented Interfaces:
MessageContext,StateManageableMessageContext
The default message context implementation. Uses a
MessageSource to resolve messages that are added by
callers.- Author:
- Keith Donald
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new default message context.DefaultMessageContext(org.springframework.context.MessageSource messageSource) Creates a new default message context. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMessage(MessageResolver messageResolver) Add a new message to this context.voidClear all messages added to this context.Create a serializable memento, or token representing a snapshot of the internal state of this message context.Message[]Get all messages in this context.Message[]getMessagesByCriteria(MessageCriteria criteria) Get all messages that meet the given result criteria.Message[]getMessagesBySource(Object source) Get all messages in this context for the source provided.org.springframework.context.MessageSourcebooleanReturns true if there are error messages in this context.voidrestoreMessages(Serializable messagesMemento) Set the state of this context from the memento provided.voidsetMessageSource(org.springframework.context.MessageSource messageSource) Configure the message source used to resolve messages added to this context.toString()
-
Constructor Details
-
DefaultMessageContext
public DefaultMessageContext()Creates a new default message context. Defaults to a message source that simply resolves default text and cannot resolve localized message codes. -
DefaultMessageContext
public DefaultMessageContext(org.springframework.context.MessageSource messageSource) Creates a new default message context.- Parameters:
messageSource- the message source to resolve messages added to this context
-
-
Method Details
-
getMessageSource
public org.springframework.context.MessageSource getMessageSource() -
getAllMessages
Description copied from interface:MessageContextGet all messages in this context. The messages returned should be suitable for display as-is.- Specified by:
getAllMessagesin interfaceMessageContext- Returns:
- the messages
-
getMessagesBySource
Description copied from interface:MessageContextGet all messages in this context for the source provided.- Specified by:
getMessagesBySourcein interfaceMessageContext- Parameters:
source- the source associated with messages, or null for global messages- Returns:
- the source's messages
-
getMessagesByCriteria
Description copied from interface:MessageContextGet all messages that meet the given result criteria.- Specified by:
getMessagesByCriteriain interfaceMessageContext- Parameters:
criteria- the message criteria
-
hasErrorMessages
public boolean hasErrorMessages()Description copied from interface:MessageContextReturns true if there are error messages in this context.- Specified by:
hasErrorMessagesin interfaceMessageContext- Returns:
- error messages
-
addMessage
Description copied from interface:MessageContextAdd a new message to this context.- Specified by:
addMessagein interfaceMessageContext- Parameters:
messageResolver- the resolver that will resolve the message to be added
-
clearMessages
public void clearMessages()Description copied from interface:MessageContextClear all messages added to this context.- Specified by:
clearMessagesin interfaceMessageContext
-
createMessagesMemento
Description copied from interface:StateManageableMessageContextCreate a serializable memento, or token representing a snapshot of the internal state of this message context.- Specified by:
createMessagesMementoin interfaceStateManageableMessageContext- Returns:
- the messages memento
-
restoreMessages
Description copied from interface:StateManageableMessageContextSet the state of this context from the memento provided. After this call, the messages in this context will match what is encapsulated inside the memento. Any previous state will be overridden.- Specified by:
restoreMessagesin interfaceStateManageableMessageContext- Parameters:
messagesMemento- the messages memento
-
setMessageSource
public void setMessageSource(org.springframework.context.MessageSource messageSource) Description copied from interface:StateManageableMessageContextConfigure the message source used to resolve messages added to this context. May be set at any time to change how coded messages are resolved.- Specified by:
setMessageSourcein interfaceStateManageableMessageContext- Parameters:
messageSource- the message source- See Also:
-
toString
-