public class SimpMessageHeaderAccessor extends NativeMessageHeaderAccessor
Use one of the static factory method in this class, then call getters and setters,
and at the end if necessary call MessageHeaderAccessor.toMap()
to obtain the updated headers.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CONNECT_MESSAGE_HEADER |
static java.lang.String |
DESTINATION_HEADER |
static java.lang.String |
MESSAGE_TYPE_HEADER |
static java.lang.String |
ORIGINAL_DESTINATION
For internal use.
|
static java.lang.String |
SESSION_ATTRIBUTES |
static java.lang.String |
SESSION_ID_HEADER |
static java.lang.String |
SUBSCRIPTION_ID_HEADER |
static java.lang.String |
USER_HEADER |
NATIVE_HEADERS
DEFAULT_CHARSET, logger
Modifier | Constructor and Description |
---|---|
protected |
SimpMessageHeaderAccessor(Message<?> message)
A constructor for accessing and modifying existing message headers.
|
protected |
SimpMessageHeaderAccessor(SimpMessageType messageType,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> externalSourceHeaders)
A constructor for creating new message headers.
|
Modifier and Type | Method and Description |
---|---|
static SimpMessageHeaderAccessor |
create()
Create an instance with
SimpMessageType MESSAGE . |
static SimpMessageHeaderAccessor |
create(SimpMessageType messageType)
Create an instance with the given
SimpMessageType . |
protected MessageHeaderAccessor |
createAccessor(Message<?> message)
Build a 'nested' accessor for the given message.
|
java.lang.String |
getDestination() |
static java.lang.String |
getDestination(java.util.Map<java.lang.String,java.lang.Object> headers) |
java.lang.String |
getDetailedLogMessage(java.lang.Object payload)
Return a more detailed message for logging purposes.
|
SimpMessageType |
getMessageType() |
static SimpMessageType |
getMessageType(java.util.Map<java.lang.String,java.lang.Object> headers) |
java.util.Map<java.lang.String,java.lang.Object> |
getSessionAttributes()
Return the attributes associated with the current session.
|
static java.util.Map<java.lang.String,java.lang.Object> |
getSessionAttributes(java.util.Map<java.lang.String,java.lang.Object> headers) |
java.lang.String |
getSessionId() |
static java.lang.String |
getSessionId(java.util.Map<java.lang.String,java.lang.Object> headers) |
java.lang.String |
getShortLogMessage(java.lang.Object payload)
Return a concise message for logging purposes.
|
java.lang.String |
getSubscriptionId() |
static java.lang.String |
getSubscriptionId(java.util.Map<java.lang.String,java.lang.Object> headers) |
java.security.Principal |
getUser()
Return the user associated with the current session.
|
static java.security.Principal |
getUser(java.util.Map<java.lang.String,java.lang.Object> headers) |
void |
setDestination(java.lang.String destination) |
void |
setMessageTypeIfNotSet(SimpMessageType messageType) |
void |
setSessionAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes)
A static alternative for access to the session attributes header.
|
void |
setSessionId(java.lang.String sessionId) |
void |
setSubscriptionId(java.lang.String subscriptionId) |
void |
setUser(java.security.Principal principal) |
static SimpMessageHeaderAccessor |
wrap(Message<?> message)
Create an instance from the payload and headers of the given Message.
|
addNativeHeader, containsNativeHeader, getFirstNativeHeader, getNativeHeader, removeNativeHeader, setImmutable, setNativeHeader, toNativeHeaderMap
copyHeaders, copyHeadersIfAbsent, getAccessor, getAccessor, getContentType, getDetailedPayloadLogMessage, getErrorChannel, getHeader, getId, getMessageHeaders, getMutableAccessor, getReplyChannel, 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 CONNECT_MESSAGE_HEADER
public static final java.lang.String DESTINATION_HEADER
public static final java.lang.String MESSAGE_TYPE_HEADER
public static final java.lang.String SESSION_ID_HEADER
public static final java.lang.String SESSION_ATTRIBUTES
public static final java.lang.String SUBSCRIPTION_ID_HEADER
public static final java.lang.String USER_HEADER
public static final java.lang.String ORIGINAL_DESTINATION
The original destination used by a client when subscribing. Such a destination may have been modified (e.g. user destinations) on the server side. This header provides a hint so messages sent to clients may have a destination matching to their original subscription.
protected SimpMessageHeaderAccessor(SimpMessageType messageType, java.util.Map<java.lang.String,java.util.List<java.lang.String>> externalSourceHeaders)
protected SimpMessageHeaderAccessor(Message<?> message)
protected MessageHeaderAccessor createAccessor(Message<?> message)
MessageHeaderAccessor
createAccessor
in class MessageHeaderAccessor
message
- the message to build a new accessor forpublic void setMessageTypeIfNotSet(SimpMessageType messageType)
public SimpMessageType getMessageType()
public void setDestination(java.lang.String destination)
public java.lang.String getDestination()
public void setSubscriptionId(java.lang.String subscriptionId)
public java.lang.String getSubscriptionId()
public void setSessionId(java.lang.String sessionId)
public java.lang.String getSessionId()
public void setSessionAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes)
public java.util.Map<java.lang.String,java.lang.Object> getSessionAttributes()
public void setUser(java.security.Principal principal)
public java.security.Principal getUser()
public java.lang.String getShortLogMessage(java.lang.Object payload)
MessageHeaderAccessor
getShortLogMessage
in class MessageHeaderAccessor
payload
- the payload that corresponds to the headers.public java.lang.String getDetailedLogMessage(java.lang.Object payload)
MessageHeaderAccessor
getDetailedLogMessage
in class MessageHeaderAccessor
payload
- the payload that corresponds to the headers.public static SimpMessageHeaderAccessor create()
SimpMessageType
MESSAGE
.public static SimpMessageHeaderAccessor create(SimpMessageType messageType)
SimpMessageType
.public static SimpMessageHeaderAccessor wrap(Message<?> message)
public static SimpMessageType getMessageType(java.util.Map<java.lang.String,java.lang.Object> headers)
public static java.lang.String getDestination(java.util.Map<java.lang.String,java.lang.Object> headers)
public static java.lang.String getSubscriptionId(java.util.Map<java.lang.String,java.lang.Object> headers)
public static java.lang.String getSessionId(java.util.Map<java.lang.String,java.lang.Object> headers)
public static java.util.Map<java.lang.String,java.lang.Object> getSessionAttributes(java.util.Map<java.lang.String,java.lang.Object> headers)
public static java.security.Principal getUser(java.util.Map<java.lang.String,java.lang.Object> headers)