|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Message
The Message represents the content of a request, a response or a fault.
Messages are part of Exchanges are created using
Exchange.getIn(), Exchange.getOut() and Exchange.getFault().
If the Exchange has to go to a remote ServiceMix instance to be processed
(if the instance is part of a cluster), all headers, attachments and content
have to be Serializable.
TODO: security
| Method Summary | ||
|---|---|---|
void |
addAttachment(java.lang.String id,
java.lang.Object value)
Add an attachment to this message |
|
Message |
copy()
Creates a copy of this message so that it can be used and possibly modified further in another exchange |
|
void |
copyFrom(Message msg)
Copies the contents of the other message into this message |
|
java.lang.String |
display(boolean displayContent)
Returns a string representation of this message. |
|
void |
ensureReReadable()
Make sure that all streams contained in the content and in attachments are transformed to re-readable sources. |
|
java.lang.Object |
getAttachment(java.lang.String id)
Retrieve an attachment given its id. |
|
java.util.Map<java.lang.String,java.lang.Object> |
getAttachments()
Retrieve a map of all attachments |
|
java.lang.Object |
getBody()
Returns the body of the message in its default format. |
|
|
getBody(java.lang.Class<T> type)
Returns the body as the specified type. |
|
java.lang.String |
getContentEncoding()
Get the encoding of the message |
|
java.lang.String |
getContentType()
Get the mime content type describing the content of the message |
|
|
getHeader(java.lang.Class<T> type)
Get a typed header. |
|
java.lang.Object |
getHeader(java.lang.String name)
Get a header on this message. |
|
|
getHeader(java.lang.String name,
java.lang.Class<T> type)
Get a header, converting it to the desired type |
|
java.util.Map<java.lang.String,java.lang.Object> |
getHeaders()
Get a map of all the headers for this message |
|
javax.security.auth.Subject |
getSecuritySubject()
Get the security subject for this message |
|
void |
removeAttachment(java.lang.String id)
Remove an attachment on this message |
|
|
removeHeader(java.lang.Class<T> type)
Remove the header of the specified type |
|
java.lang.Object |
removeHeader(java.lang.String name)
Remove the given header and returns its value. |
|
void |
setBody(java.lang.Object body)
Set the body of the message. |
|
|
setBody(java.lang.Object body,
java.lang.Class<T> type)
Set the body of the message. |
|
void |
setContentEncoding(java.lang.String encoding)
Set the encoding of the message |
|
void |
setContentType(java.lang.String type)
Set the mime content type describing the content of the message |
|
|
setHeader(java.lang.Class<T> type,
T value)
Set a typed header for this message. |
|
void |
setHeader(java.lang.String name,
java.lang.Object value)
Set a header for this message |
|
void |
setHeaders(java.util.Map<java.lang.String,java.lang.Object> headers)
Set all the headers |
|
void |
setSecuritySubject(javax.security.auth.Subject securitySubject)
Set the security subject for this message |
|
| Method Detail |
|---|
java.lang.Object getHeader(java.lang.String name)
name - the name of the header
null if none has been set<T> T getHeader(java.lang.Class<T> type)
exchange.getHeader(type.getName())
type - the type of the header
<T> T getHeader(java.lang.String name,
java.lang.Class<T> type)
name - the name of the headertype - the desired type
null if
no header has been set or if it can not be transformed
to the desired type
void setHeader(java.lang.String name,
java.lang.Object value)
name - the name of the headervalue - the value of the header
<T> void setHeader(java.lang.Class<T> type,
T value)
exchange.setHeader(type.getName(), value)
type - the type of the headervalue - the value of the headerjava.lang.Object removeHeader(java.lang.String name)
name - the name of the header
<T> T removeHeader(java.lang.Class<T> type)
type - the type of the header
java.util.Map<java.lang.String,java.lang.Object> getHeaders()
void setHeaders(java.util.Map<java.lang.String,java.lang.Object> headers)
headers - the new map of headersjava.lang.Object getAttachment(java.lang.String id)
id - the id of the attachment to retrieve
null if none exists
void addAttachment(java.lang.String id,
java.lang.Object value)
id - the id of the attachmentvalue - the attachment to addvoid removeAttachment(java.lang.String id)
id - the id of the attachment to removejava.util.Map<java.lang.String,java.lang.Object> getAttachments()
java.lang.Object getBody()
<T> T getBody(java.lang.Class<T> type)
type - the type in which the body is to be transformed
void setBody(java.lang.Object body)
body - the body of the message
<T> void setBody(java.lang.Object body,
java.lang.Class<T> type)
body - the body of the messagejava.lang.String getContentType()
void setContentType(java.lang.String type)
type - the mime content typejava.lang.String getContentEncoding()
void setContentEncoding(java.lang.String encoding)
encoding - the encodingjavax.security.auth.Subject getSecuritySubject()
void setSecuritySubject(javax.security.auth.Subject securitySubject)
securitySubject - the security subjectvoid copyFrom(Message msg)
msg - the message to copy fromMessage copy()
void ensureReReadable()
java.lang.String display(boolean displayContent)
displayContent property can be specified to
control wether the content should be displayed or not.
If set to true, the content and attachments will
be converted into re-readable objects (for java.io.InputStream
and javax.xml.transform.Source objects) and printed.
displayContent - if the content and attachments of the exchange
should be transformed if needed and displayed
or left unmodified
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||