public class NativeMessageHeaderAccessor extends MessageHeaderAccessor
MessageHeaderAccessor
that also stores and provides read/write
access to message headers from an external source -- e.g. a Spring Message
created to represent a STOMP message received from a STOMP client or message broker.
Native message headers are kept in a Map<String, List<String>>
under the key
NATIVE_HEADERS
.
This class is not intended for direct use but is rather expected to be used
indirectly through protocol-specific sub-classes such as
StompHeaderAccessor
.
Such sub-classes may provide factory methods to translate message headers from
an external messaging source (e.g. STOMP) to Spring Message
headers and
reversely to translate Spring Message
headers to a message to send to an
external source.
Modifier and Type | Field and Description |
---|---|
static String |
NATIVE_HEADERS |
DEFAULT_CHARSET
Modifier | Constructor and Description |
---|---|
protected |
NativeMessageHeaderAccessor()
A protected constructor to create new headers.
|
protected |
NativeMessageHeaderAccessor(Map<String,List<String>> nativeHeaders)
A protected constructor to create new headers.
|
protected |
NativeMessageHeaderAccessor(Message<?> message)
A protected constructor accepting the headers of an existing message to copy.
|
Modifier and Type | Method and Description |
---|---|
void |
addNativeHeader(String name,
String value)
Add the specified native header value to existing values.
|
void |
addNativeHeaders(MultiValueMap<String,String> headers) |
boolean |
containsNativeHeader(String headerName)
Whether the native header map contains the give header name.
|
String |
getFirstNativeHeader(String headerName) |
static String |
getFirstNativeHeader(String headerName,
Map<String,Object> headers) |
List<String> |
getNativeHeader(String headerName) |
List<String> |
removeNativeHeader(String name) |
void |
setImmutable()
By default when
MessageHeaderAccessor.getMessageHeaders() is called, "this"
MessageHeaderAccessor instance can no longer be used to modify the
underlying message headers. |
void |
setNativeHeader(String name,
String value)
Set the specified native header value replacing existing values.
|
Map<String,List<String>> |
toNativeHeaderMap()
Return a copy of the native header values or an empty map.
|
copyHeaders, copyHeadersIfAbsent, createAccessor, getAccessor, getAccessor, getContentType, getDetailedLogMessage, getDetailedPayloadLogMessage, getErrorChannel, getHeader, getId, getMessageHeaders, getMutableAccessor, getReplyChannel, getShortLogMessage, getShortPayloadLogMessage, getTimestamp, isModified, isMutable, isReadableContentType, isReadOnly, removeHeader, removeHeaders, setContentType, setErrorChannel, setErrorChannelName, setHeader, setHeaderIfAbsent, setLeaveMutable, setModified, setReplyChannel, setReplyChannelName, toMap, toMessageHeaders, toString, verifyType
public static final String NATIVE_HEADERS
protected NativeMessageHeaderAccessor()
protected NativeMessageHeaderAccessor(Map<String,List<String>> nativeHeaders)
nativeHeaders
- native headers to create the message with (may be null
)protected NativeMessageHeaderAccessor(Message<?> message)
public Map<String,List<String>> toNativeHeaderMap()
public void setImmutable()
MessageHeaderAccessor
MessageHeaderAccessor.getMessageHeaders()
is called, "this"
MessageHeaderAccessor
instance can no longer be used to modify the
underlying message headers. However if MessageHeaderAccessor.setLeaveMutable(boolean)
is used, this method is necessary to indicate explicitly when the
MessageHeaders
instance should no longer be modified.setImmutable
in class MessageHeaderAccessor
public boolean containsNativeHeader(String headerName)
public List<String> getNativeHeader(String headerName)
null
.public String getFirstNativeHeader(String headerName)
null
.public void setNativeHeader(String name, String value)
public void addNativeHeader(String name, String value)
public void addNativeHeaders(MultiValueMap<String,String> headers)