public class Message extends Object implements XMessage
Constructor and Description |
---|
Message(XMessageFormat payload) |
Modifier and Type | Method and Description |
---|---|
<P> void |
addMessageProperty(String key,
P value)
Add a message property - i.e.
|
void |
addPayloadToRelease(XMessageFormat payload)
Associate
XMessageFormat (i.e : payload ) with XMessage in order to GC with
XMessage resulting any XMessageFormat s obtained from File Store to release with it. |
<H> void |
addTransportHeader(String key,
H value)
Add a transport header to this message
|
XMessage |
cloneFullMessage()
Creates a clone of the message including the clone of payload as well as clones of attachments if any
|
XMessage |
cloneMessageWithoutPayload()
Creates a clone of the message without the payload and attachments.
|
void |
close() |
Optional<XAttachment> |
getAttachment(String key)
Retrieves the XAttachment with the given key
|
Map<String,XAttachment> |
getAttachments()
Return current attachments as an unmodifiable map
|
String |
getContentType()
Get the content type of the message if set.
|
String |
getDestinationURI()
Get the current destination URI for this message.
|
Map<String,List<String>> |
getDuplicateStringTransportHeaders()
Get the map of current transport header duplicate values
|
Map<String,List<Object>> |
getDuplicateTransportHeaders()
Get the map of current transport header duplicate values
|
<H> Map<String,List<H>> |
getDuplicateTransportHeaders(Class<H> type)
Get the map of current transport header duplicate values
|
Optional<String> |
getFirstStringTransportHeader(String key) |
Optional<String> |
getFirstStringTransportHeaderIgnoreCase(String key) |
<H> Optional<H> |
getFirstTransportHeader(String key,
Class<H> type)
Get the first transport header with the given key as as a typed object of type H
|
<H> Optional<H> |
getFirstTransportHeaderIgnoreCase(String key,
Class<H> type)
This will perform a case insensitive lookup for the first occurrence of the given transport header and retrieve
it as as a typed object of type H
|
UUID |
getMessageId() |
Map<String,Object> |
getMessageProperties()
Return current message properties as an unmodifiable map
|
<P> Optional<P> |
getMessageProperty(String key,
Class<P> cls)
Get the message property associated with the specified key as a typed object of type P
|
XMessageFormat |
getPayload()
Get the current payload of the message
|
String |
getRequestContentType()
Return the content type of the original request.
|
int |
getResponseCode()
Gets the response code of the message
|
Optional<String> |
getStringMessageProperty(String key)
Get the String message property associated with the specified key
|
Map<String,String> |
getStringTransportHeaders()
Get the map of current transport header values ignoring duplicates
|
List<String> |
getStringTransportHeaders(String key)
Get a List of transport header values for the given key
|
Map<String,Object> |
getTransportHeaders()
Get the map of current transport header values ignoring duplicates
|
<H> Map<String,H> |
getTransportHeaders(Class<H> type)
Get the map of current transport header values ignoring duplicates
|
List<Object> |
getTransportHeaders(String key)
Get a List of transport header values for the given key
|
<H> List<H> |
getTransportHeaders(String key,
Class<H> type)
Get a List of transport header values for the given key
|
boolean |
hasAttachment(String key)
Checks if there is an attachment by the given key
|
boolean |
hasAttachments()
Checks whether this xMessageContext contains attachments
|
boolean |
hasMessageProperty(String key)
Checks whether the given property is present in the message properties map
|
boolean |
hasTransportHeader(String key)
Checks whether the give header is present in the message headers
|
void |
removeAllTransportHeaders()
Remove all transport headers
|
void |
removeAttachment(String key)
Removes
XAttachment with the given key |
void |
removeMessageProperty(String key)
Remove the message property associated with the specified key
|
void |
removeTransportHeader(String key)
Remove all occurrences of the specified transport header
|
void |
removeTransportHeaders(String... headers)
Remove transport headers specified in the comma separated list
|
<H> void |
replaceTransportHeader(String key,
H value)
Replace the first occurrence of the transport header with the given value
|
void |
retainOnlyTransportHeaders(String... headers)
Retain only transport headers specified in the comma separated list
|
void |
setAttachment(String key,
XAttachment value)
Sets a new attachment by adding it to the map of attachments
|
void |
setContentType(String contentType)
Set the content type of the message
|
void |
setDestinationURI(String destinationURI)
Set the destination URI for this message
|
void |
setPayload(XMessageFormat currentPayload) |
void |
setRequestContentType(String requestContentType) |
void |
setResponseCode(int responseCode)
Sets the response code of the message
|
String |
toString() |
public Message(XMessageFormat payload)
public UUID getMessageId()
getMessageId
in interface XMessage
public XMessageFormat getPayload()
XMessage
getPayload
in interface XMessage
public void setPayload(XMessageFormat currentPayload)
setPayload
in interface XMessage
public boolean hasTransportHeader(String key)
XMessage
hasTransportHeader
in interface XMessage
key
- the key to be checked for existencepublic <H> Optional<H> getFirstTransportHeader(String key, Class<H> type)
XMessage
getFirstTransportHeader
in interface XMessage
H
- the type of the headerkey
- the header nametype
- the class of the header typepublic Optional<String> getFirstStringTransportHeader(String key)
getFirstStringTransportHeader
in interface XMessage
public <H> Optional<H> getFirstTransportHeaderIgnoreCase(String key, Class<H> type)
XMessage
getFirstTransportHeaderIgnoreCase
in interface XMessage
H
- the type of the headerkey
- the case insensitive header nametype
- the class of the header typepublic Optional<String> getFirstStringTransportHeaderIgnoreCase(String key)
getFirstStringTransportHeaderIgnoreCase
in interface XMessage
public <H> void addTransportHeader(String key, H value)
XMessage
addTransportHeader
in interface XMessage
H
- the type of the header valuekey
- name of the header to be addedvalue
- header value to be setpublic void removeTransportHeader(String key)
XMessage
removeTransportHeader
in interface XMessage
key
- header name to removepublic void removeAllTransportHeaders()
XMessage
removeAllTransportHeaders
in interface XMessage
public void removeTransportHeaders(String... headers)
XMessage
removeTransportHeaders
in interface XMessage
headers
- a list of transport headers to removepublic void retainOnlyTransportHeaders(String... headers)
XMessage
retainOnlyTransportHeaders
in interface XMessage
headers
- a list of transport headers to retainpublic <H> void replaceTransportHeader(String key, H value)
XMessage
replaceTransportHeader
in interface XMessage
H
- the type of the new header valuekey
- the name of the header to be replacedvalue
- the new value to be setpublic <H> List<H> getTransportHeaders(String key, Class<H> type)
XMessage
getTransportHeaders
in interface XMessage
H
- the type of the header valuekey
- the name of the transport header to be retrievedtype
- the class of the type of the expected header value listpublic <H> Map<String,H> getTransportHeaders(Class<H> type)
XMessage
getTransportHeaders
in interface XMessage
H
- the type of the header values to be returnedtype
- the class of the type of the header valuespublic <H> Map<String,List<H>> getDuplicateTransportHeaders(Class<H> type)
XMessage
getDuplicateTransportHeaders
in interface XMessage
H
- the type of the header values to be returnedtype
- the class of the type of the headers to be retrievedpublic List<Object> getTransportHeaders(String key)
XMessage
getTransportHeaders
in interface XMessage
key
- the name of the transport header to retrieve the header valuespublic Map<String,Object> getTransportHeaders()
XMessage
getTransportHeaders
in interface XMessage
public Map<String,List<Object>> getDuplicateTransportHeaders()
XMessage
getDuplicateTransportHeaders
in interface XMessage
public List<String> getStringTransportHeaders(String key)
XMessage
getStringTransportHeaders
in interface XMessage
key
- the name of the transport header to retrieve the String
header valuespublic Map<String,String> getStringTransportHeaders()
XMessage
getStringTransportHeaders
in interface XMessage
public Map<String,List<String>> getDuplicateStringTransportHeaders()
XMessage
getDuplicateStringTransportHeaders
in interface XMessage
public <P> void addMessageProperty(String key, P value)
XMessage
addMessageProperty
in interface XMessage
P
- the type of the value of the property to be addedkey
- property keyvalue
- property valuepublic <P> Optional<P> getMessageProperty(String key, Class<P> cls)
XMessage
getMessageProperty
in interface XMessage
P
- the type of the propertykey
- the property keycls
- the class of the property typepublic Optional<String> getStringMessageProperty(String key)
XMessage
getStringMessageProperty
in interface XMessage
key
- property keypublic void removeMessageProperty(String key)
XMessage
removeMessageProperty
in interface XMessage
key
- property keypublic boolean hasMessageProperty(String key)
XMessage
hasMessageProperty
in interface XMessage
key
- the key to be checked for existencepublic Map<String,Object> getMessageProperties()
XMessage
getMessageProperties
in interface XMessage
public String getDestinationURI()
XMessage
getDestinationURI
in interface XMessage
public void setDestinationURI(String destinationURI)
XMessage
setDestinationURI
in interface XMessage
destinationURI
- the new destination URIpublic String getContentType()
XMessage
getContentType
in interface XMessage
public String getRequestContentType()
XMessage
getRequestContentType
in interface XMessage
public void setRequestContentType(String requestContentType)
public void setContentType(String contentType)
XMessage
setContentType
in interface XMessage
contentType
- the content type string to be setpublic int getResponseCode()
XMessage
getResponseCode
in interface XMessage
public void setResponseCode(int responseCode)
XMessage
setResponseCode
in interface XMessage
responseCode
- the integer
response code to be setpublic XMessage cloneFullMessage()
XMessage
cloneFullMessage
in interface XMessage
XMessage
public XMessage cloneMessageWithoutPayload()
XMessage
cloneMessageWithoutPayload
in interface XMessage
XMessage
public Map<String,XAttachment> getAttachments()
XMessage
getAttachments
in interface XMessage
public void setAttachment(String key, XAttachment value)
XMessage
setAttachment
in interface XMessage
key
- String
key for an attachmentvalue
- XAttachment
an attachmentpublic void removeAttachment(String key)
XMessage
XAttachment
with the given keyremoveAttachment
in interface XMessage
key
- String
key of the attachment to be removedpublic Optional<XAttachment> getAttachment(String key)
XMessage
getAttachment
in interface XMessage
key
- String
keyOptional
containing the XAttachment
if exists and Optional.EMPTY
otherwisepublic boolean hasAttachments()
XMessage
hasAttachments
in interface XMessage
public boolean hasAttachment(String key)
XMessage
hasAttachment
in interface XMessage
key
- String
keypublic void addPayloadToRelease(XMessageFormat payload)
XMessage
XMessageFormat
(i.e : payload ) with XMessage
in order to GC with
XMessage
resulting any XMessageFormat
s obtained from File Store to release with it.addPayloadToRelease
in interface XMessage
payload
- XMessageFormat
instance to be releasedpublic void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2016–2019 AdroitLogic. All rights reserved.