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, waitaddAttachment, addAttachmentObject, createExchangeId, getAttachment, getAttachmentNames, getAttachmentObject, getAttachmentObjects, getAttachments, getHeader, getHeader, getHeader, getHeader, getHeaders, hasAttachments, hasHeaders, isFault, removeAttachment, removeHeader, removeHeaders, removeHeaders, setAttachmentObjects, setAttachments, setFault, setHeader, setHeaderspublic MessageSupport()
public Object getBody()
Messagepublic <T> T getBody(Class<T> type)
Messagepublic Object getMandatoryBody() throws InvalidPayloadException
MessagegetMandatoryBody in interface MessageInvalidPayloadException - Is thrown if the body being null or wrong class typepublic <T> T getMandatoryBody(Class<T> type) throws InvalidPayloadException
MessagegetMandatoryBody in interface Messagetype - the type that the bodyInvalidPayloadException - Is thrown if the body being null or wrong class typepublic void setBody(Object body)
Messagepublic <T> void setBody(Object value, Class<T> type)
Messagepublic Message copy()
Messagepublic void copyFrom(Message that)
Messagepublic Exchange getExchange()
MessagegetExchange in interface Messagepublic void setExchange(Exchange exchange)
public void copyAttachments(Message that)
MessagecopyAttachments in interface Messagethat - the other messagepublic abstract Message newInstance()
protected Object createBody()
public String getMessageId()
MessagegetMessageId in interface Messagepublic void setMessageId(String messageId)
MessagesetMessageId in interface MessagemessageId - id of the messageprotected String createMessageId()
Apache Camel