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 java.lang.String |
NATIVE_HEADERS |
DEFAULT_CHARSET
Modifier | Constructor and Description |
---|---|
protected |
NativeMessageHeaderAccessor()
A protected constructor to create new headers.
|
protected |
NativeMessageHeaderAccessor(java.util.Map<java.lang.String,java.util.List<java.lang.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(java.lang.String name,
java.lang.String value)
Add the specified native header value to existing values.
|
void |
addNativeHeaders(MultiValueMap<java.lang.String,java.lang.String> headers) |
boolean |
containsNativeHeader(java.lang.String headerName)
Whether the native header map contains the give header name.
|
java.lang.String |
getFirstNativeHeader(java.lang.String headerName)
Return the first value for the specified native header,
or
null if none. |
static java.lang.String |
getFirstNativeHeader(java.lang.String headerName,
java.util.Map<java.lang.String,java.lang.Object> headers) |
java.util.List<java.lang.String> |
getNativeHeader(java.lang.String headerName)
Return all values for the specified native header.
|
protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getNativeHeaders() |
java.util.List<java.lang.String> |
removeNativeHeader(java.lang.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(java.lang.String name,
java.lang.String value)
Set the specified native header value replacing existing values.
|
java.util.Map<java.lang.String,java.util.List<java.lang.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 java.lang.String NATIVE_HEADERS
protected NativeMessageHeaderAccessor()
protected NativeMessageHeaderAccessor(@Nullable java.util.Map<java.lang.String,java.util.List<java.lang.String>> nativeHeaders)
nativeHeaders
- native headers to create the message with (may be null
)@Nullable protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> getNativeHeaders()
public java.util.Map<java.lang.String,java.util.List<java.lang.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(java.lang.String headerName)
@Nullable public java.util.List<java.lang.String> getNativeHeader(java.lang.String headerName)
null
if none.@Nullable public java.lang.String getFirstNativeHeader(java.lang.String headerName)
null
if none.public void setNativeHeader(java.lang.String name, @Nullable java.lang.String value)
public void addNativeHeader(java.lang.String name, @Nullable java.lang.String value)
public void addNativeHeaders(@Nullable MultiValueMap<java.lang.String,java.lang.String> headers)
@Nullable public java.util.List<java.lang.String> removeNativeHeader(java.lang.String name)
@Nullable public static java.lang.String getFirstNativeHeader(java.lang.String headerName, java.util.Map<java.lang.String,java.lang.Object> headers)