public abstract class MessageSupport extends Object implements Message
Message
body handling features but letting the derived class deal
with headers.
Unless a specific provider wishes to do something particularly clever with
headers you probably want to just derive from DefaultMessage
Constructor and Description |
---|
MessageSupport() |
Modifier and Type | Method and Description |
---|---|
Message |
copy()
Creates a copy of this message so that it can be used and possibly
modified further in another exchange
|
void |
copyAttachments(Message that)
Copies the attachments of the other message into this message
|
void |
copyFrom(Message that)
Copies the contents of the other message into this message
|
protected Object |
createBody()
A factory method to allow a provider to lazily create the message body
for inbound messages from other sources
|
protected String |
createMessageId()
Allow implementations to auto-create a messageId
|
Object |
getBody()
Returns the body of the message as a POJO
The body can be null if no body is set
|
<T> T |
getBody(Class<T> type)
Returns the body as the specified type
|
protected <T> T |
getBody(Class<T> type,
Object body) |
Exchange |
getExchange()
Returns the exchange this message is related to
|
Object |
getMandatoryBody()
Returns the body of the message as a POJO
|
<T> T |
getMandatoryBody(Class<T> type)
Returns the mandatory body as the specified type
|
String |
getMessageId()
Returns the id of the message
|
abstract Message |
newInstance()
Returns a new instance
|
void |
setBody(Object body)
Sets the body of the message
|
<T> void |
setBody(Object value,
Class<T> type)
Sets the body of the message as a specific type
|
void |
setExchange(Exchange exchange) |
void |
setMessageId(String messageId)
Sets the id of the message
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addAttachment, createExchangeId, getAttachment, getAttachmentNames, getAttachments, getHeader, getHeader, getHeader, getHeader, getHeaders, hasAttachments, hasHeaders, isFault, removeAttachment, removeHeader, removeHeaders, removeHeaders, setAttachments, setFault, setHeader, setHeaders
public MessageSupport()
public Object getBody()
Message
public <T> T getBody(Class<T> type)
Message
public Object getMandatoryBody() throws InvalidPayloadException
Message
getMandatoryBody
in interface Message
InvalidPayloadException
- Is thrown if the body being null or wrong class typepublic <T> T getMandatoryBody(Class<T> type) throws InvalidPayloadException
Message
getMandatoryBody
in interface Message
type
- the type that the bodyInvalidPayloadException
- Is thrown if the body being null or wrong class typepublic void setBody(Object body)
Message
public <T> void setBody(Object value, Class<T> type)
Message
public Message copy()
Message
public void copyFrom(Message that)
Message
public Exchange getExchange()
Message
getExchange
in interface Message
public void setExchange(Exchange exchange)
public void copyAttachments(Message that)
Message
copyAttachments
in interface Message
that
- the other messagepublic abstract Message newInstance()
protected Object createBody()
public String getMessageId()
Message
getMessageId
in interface Message
public void setMessageId(String messageId)
Message
setMessageId
in interface Message
messageId
- id of the messageprotected String createMessageId()
Apache Camel