Top Description Inners Fields Constructors Methods
org.springframework.messaging.simp.stomp

public Class StompHeaderAccessor

extends SimpMessageHeaderAccessor
Class Inheritance
Imports
java.nio.charset.Charset, .StandardCharsets, java.security.Principal, java.util.Arrays, .Collections, .List, .Map, .Set, java.util.concurrent.atomic.AtomicLong, org.springframework.lang.Nullable, org.springframework.messaging.Message, org.springframework.messaging.simp.SimpMessageHeaderAccessor, .SimpMessageType, org.springframework.messaging.support.MessageHeaderAccessor, org.springframework.util.ClassUtils, .CollectionUtils, .MimeType, .MimeTypeUtils, .StringUtils

A MessageHeaderAccessor to use when creating a Message from a decoded STOMP frame, or when encoding a Message to a STOMP frame.

When created from STOMP frame content, the actual STOMP headers are stored in the native header sub-map managed by the parent class org.springframework.messaging.support.NativeMessageHeaderAccessor while the parent class SimpMessageHeaderAccessor manages common processing headers some of which are based on STOMP headers (e.g. destination, content-type, etc).

An instance of this class can also be created by wrapping an existing Message. That message may have been created with the more generic org.springframework.messaging.simp.SimpMessageHeaderAccessor in which case STOMP headers are created from common processing headers. In this case it is also necessary to invoke either updateStompCommandAsClientMessage() or updateStompCommandAsServerMessage() if sending a message and depending on whether a message is sent to a client or the message broker.

Author
Rossen Stoyanchev
Since
4.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static final long[]
private static final AtomicLong
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
Inherited from org.springframework.messaging.simp.SimpMessageHeaderAccessor:
CONNECT_MESSAGE_HEADERDESTINATION_HEADERDISCONNECT_MESSAGE_HEADERHEART_BEAT_HEADERIGNORE_ERRORMESSAGE_TYPE_HEADERORIGINAL_DESTINATIONSESSION_ATTRIBUTESSESSION_ID_HEADERSUBSCRIPTION_ID_HEADERUSER_HEADER

Constructor Summary

AccessConstructor and Description
pack-priv
StompHeaderAccessor(StompCommand command, Map<String, List<String>> externalSourceHeaders)

A constructor for creating message headers from a parsed STOMP frame.

pack-priv
StompHeaderAccessor(Message<?> message)

A constructor for accessing and modifying existing message headers.

pack-priv

Method Summary

Modifier and TypeMethod and Description
private String
private String
public static StompHeaderAccessor
create(StompCommand command)

Create an instance for the given STOMP command.

public static StompHeaderAccessor
create(StompCommand command, Map<String, List<String>> headers)

Create an instance for the given STOMP command and headers.

protected MessageHeaderAccessor
createAccessor(Message<?>
the message to build a new accessor for
message
)

Overrides org.springframework.messaging.simp.SimpMessageHeaderAccessor.createAccessor.

Build a 'nested' accessor for the given message.
public static StompHeaderAccessor
createForHeartbeat()

Create headers for a heartbeat.

public Set<String>
public String
public StompCommand
getCommand()

Return the STOMP command, or null if not yet set.

public static StompCommand
getCommand(Map<String, Object> headers)

Return the STOMP command from the given headers, or null if not set.

public Integer
public static Integer
public String
getDetailedLogMessage(Object
the payload that corresponds to the headers.
payload
)

Overrides org.springframework.messaging.simp.SimpMessageHeaderAccessor.getDetailedLogMessage.

Return a more detailed message for logging purposes.
public long[]
public String
public String
public String
public String
public String
protected Map<String, List<String>>
getNativeHeaders()

Overrides org.springframework.messaging.support.NativeMessageHeaderAccessor.getNativeHeaders.

Subclasses can use this method to access the "native" headers sub-map.
public String
getPasscode()

Return the passcode header value, or null if not set.

public static String
getPasscode(Map<String, Object> headers)

Return the passcode header value, or null if not set.

public String
public String
public String
getShortLogMessage(Object
the payload that corresponds to the headers.
payload
)

Overrides org.springframework.messaging.simp.SimpMessageHeaderAccessor.getShortLogMessage.

Return a concise message for logging purposes.
public String
public boolean
private void
public void
setAcceptVersion(String acceptVersion)

public void
public void
setContentLength(int contentLength)

public void
public void
public void
setHeartbeat(long cx, long cy)

public void
public void
public void
setMessage(String content)

public void
public void
public void
setPasscode(String passcode)

public void
setReceipt(String receiptId)

public void
setReceiptId(String receiptId)

public void
public void
setVersion(String version)

private void
pack-priv void
public StompCommand
public void
pack-priv void
public static StompHeaderAccessor
wrap(Message<?> message)

Hides org.springframework.messaging.simp.SimpMessageHeaderAccessor.wrap.

Create an instance from the payload and headers of the given Message.
Inherited from org.springframework.messaging.simp.SimpMessageHeaderAccessor:
createcreategetDestinationgetDestinationgetHeartbeatgetMessageTypegetMessageTypegetSessionAttributesgetSessionAttributesgetSessionIdgetSessionIdgetSubscriptionIdgetSubscriptionIdgetUsergetUsersetMessageTypeIfNotSetsetSessionAttributessetSessionIdsetUsersetUserChangeCallback

Field Detail

COMMAND_HEADERback to summary
private static final String COMMAND_HEADER
CREDENTIALS_HEADERback to summary
private static final String CREDENTIALS_HEADER
DEFAULT_HEARTBEATback to summary
private static final long[] DEFAULT_HEARTBEAT
messageIdCounterback to summary
private static final AtomicLong messageIdCounter
STOMP_ACCEPT_VERSION_HEADERback to summary
public static final String STOMP_ACCEPT_VERSION_HEADER
STOMP_ACK_HEADERback to summary
public static final String STOMP_ACK_HEADER
STOMP_CONTENT_LENGTH_HEADERback to summary
public static final String STOMP_CONTENT_LENGTH_HEADER
STOMP_CONTENT_TYPE_HEADERback to summary
public static final String STOMP_CONTENT_TYPE_HEADER
STOMP_DESTINATION_HEADERback to summary
public static final String STOMP_DESTINATION_HEADER
STOMP_HEARTBEAT_HEADERback to summary
public static final String STOMP_HEARTBEAT_HEADER
STOMP_HOST_HEADERback to summary
public static final String STOMP_HOST_HEADER
STOMP_ID_HEADERback to summary
public static final String STOMP_ID_HEADER
STOMP_LOGIN_HEADERback to summary
public static final String STOMP_LOGIN_HEADER
STOMP_MESSAGE_HEADERback to summary
public static final String STOMP_MESSAGE_HEADER
STOMP_MESSAGE_ID_HEADERback to summary
public static final String STOMP_MESSAGE_ID_HEADER
STOMP_NACK_HEADERback to summary
public static final String STOMP_NACK_HEADER
STOMP_PASSCODE_HEADERback to summary
public static final String STOMP_PASSCODE_HEADER
STOMP_RECEIPT_HEADERback to summary
public static final String STOMP_RECEIPT_HEADER
STOMP_RECEIPT_ID_HEADERback to summary
public static final String STOMP_RECEIPT_ID_HEADER
STOMP_SUBSCRIPTION_HEADERback to summary
public static final String STOMP_SUBSCRIPTION_HEADER
STOMP_VERSION_HEADERback to summary
public static final String STOMP_VERSION_HEADER

Constructor Detail

StompHeaderAccessorback to summary
pack-priv StompHeaderAccessor(StompCommand command, Map<String, List<String>> externalSourceHeaders)

A constructor for creating message headers from a parsed STOMP frame.

StompHeaderAccessorback to summary
pack-priv StompHeaderAccessor(Message<?> message)

A constructor for accessing and modifying existing message headers. Note that the message headers may not have been created from a STOMP frame but may have rather originated from using the more generic org.springframework.messaging.simp.SimpMessageHeaderAccessor.

StompHeaderAccessorback to summary
pack-priv StompHeaderAccessor()

Method Detail

appendPayloadback to summary
private String appendPayload(Object payload)
appendSessionback to summary
private String appendSession()
createback to summary
public static StompHeaderAccessor create(StompCommand command)

Create an instance for the given STOMP command.

createback to summary
public static StompHeaderAccessor create(StompCommand command, Map<String, List<String>> headers)

Create an instance for the given STOMP command and headers.

createAccessorback to summary
protected MessageHeaderAccessor createAccessor(Message<?> message)

Overrides org.springframework.messaging.simp.SimpMessageHeaderAccessor.createAccessor.

Doc from org.springframework.messaging.support.MessageHeaderAccessor.createAccessor.

Build a 'nested' accessor for the given message.

Parameters
message:Message<?>

the message to build a new accessor for

Returns:MessageHeaderAccessor

the nested accessor (typically a specific subclass)

Annotations
@Override
createForHeartbeatback to summary
public static StompHeaderAccessor createForHeartbeat()

Create headers for a heartbeat. While a STOMP heartbeat frame does not have headers, a session id is needed for processing purposes at a minimum.

getAcceptVersionback to summary
public Set<String> getAcceptVersion()
getAckback to summary
public String getAck()
Annotations
@Nullable
getCommandback to summary
public StompCommand getCommand()

Return the STOMP command, or null if not yet set.

Annotations
@Nullable
getCommandback to summary
public static StompCommand getCommand(Map<String, Object> headers)

Return the STOMP command from the given headers, or null if not set.

Annotations
@Nullable
getContentLengthback to summary
public Integer getContentLength()
Annotations
@Nullable
getContentLengthback to summary
public static Integer getContentLength(Map<String, List<String>> nativeHeaders)
Annotations
@Nullable
getDetailedLogMessageback to summary
public String getDetailedLogMessage(Object payload)

Overrides org.springframework.messaging.simp.SimpMessageHeaderAccessor.getDetailedLogMessage.

Doc from org.springframework.messaging.support.MessageHeaderAccessor.getDetailedLogMessage.

Return a more detailed message for logging purposes.

Parameters
payload:Object

the payload that corresponds to the headers.

Returns:String

the message

Annotations
@Override
getHeartbeatback to summary
public long[] getHeartbeat()
getHostback to summary
public String getHost()
Annotations
@Nullable
getLoginback to summary
public String getLogin()
Annotations
@Nullable
getMessageback to summary
public String getMessage()
Annotations
@Nullable
getMessageIdback to summary
public String getMessageId()
Annotations
@Nullable
getNackback to summary
public String getNack()
Annotations
@Nullable
getNativeHeadersback to summary
protected Map<String, List<String>> getNativeHeaders()

Overrides org.springframework.messaging.support.NativeMessageHeaderAccessor.getNativeHeaders.

Doc from org.springframework.messaging.support.NativeMessageHeaderAccessor.getNativeHeaders.

Subclasses can use this method to access the "native" headers sub-map.

Annotations
@Override
@Nullable
getPasscodeback to summary
public String getPasscode()

Return the passcode header value, or null if not set.

Annotations
@Nullable
getPasscodeback to summary
public static String getPasscode(Map<String, Object> headers)

Return the passcode header value, or null if not set.

Annotations
@Nullable
getReceiptback to summary
public String getReceipt()
Annotations
@Nullable
getReceiptIdback to summary
public String getReceiptId()
Annotations
@Nullable
getShortLogMessageback to summary
public String getShortLogMessage(Object payload)

Overrides org.springframework.messaging.simp.SimpMessageHeaderAccessor.getShortLogMessage.

Doc from org.springframework.messaging.support.MessageHeaderAccessor.getShortLogMessage.

Return a concise message for logging purposes.

Parameters
payload:Object

the payload that corresponds to the headers.

Returns:String

the message

Annotations
@Override
getVersionback to summary
public String getVersion()
Annotations
@Nullable
isHeartbeatback to summary
public boolean isHeartbeat()
protectPasscodeback to summary
private void protectPasscode()
setAcceptVersionback to summary
public void setAcceptVersion(String acceptVersion)
setAckback to summary
public void setAck(String ack)
setContentLengthback to summary
public void setContentLength(int contentLength)
setContentTypeback to summary
public void setContentType(MimeType contentType)

Overrides org.springframework.messaging.support.MessageHeaderAccessor.setContentType.

Annotations
@Override
setDestinationback to summary
public void setDestination(String destination)

Overrides org.springframework.messaging.simp.SimpMessageHeaderAccessor.setDestination.

Annotations
@Override
setHeartbeatback to summary
public void setHeartbeat(long cx, long cy)
setHostback to summary
public void setHost(String host)
setLoginback to summary
public void setLogin(String login)
setMessageback to summary
public void setMessage(String content)
setMessageIdback to summary
public void setMessageId(String id)
setNackback to summary
public void setNack(String nack)
setPasscodeback to summary
public void setPasscode(String passcode)
setReceiptback to summary
public void setReceipt(String receiptId)
setReceiptIdback to summary
public void setReceiptId(String receiptId)
setSubscriptionIdback to summary
public void setSubscriptionId(String subscriptionId)

Overrides org.springframework.messaging.simp.SimpMessageHeaderAccessor.setSubscriptionId.

Annotations
@Override
setVersionback to summary
public void setVersion(String version)
trySetStompHeaderForSubscriptionIdback to summary
private void trySetStompHeaderForSubscriptionId()
updateSimpMessageHeadersFromStompHeadersback to summary
pack-priv void updateSimpMessageHeadersFromStompHeaders()
updateStompCommandAsClientMessageback to summary
public StompCommand updateStompCommandAsClientMessage()
updateStompCommandAsServerMessageback to summary
public void updateStompCommandAsServerMessage()
updateStompHeadersFromSimpMessageHeadersback to summary
pack-priv void updateStompHeadersFromSimpMessageHeaders()
wrapback to summary
public static StompHeaderAccessor wrap(Message<?> message)

Hides org.springframework.messaging.simp.SimpMessageHeaderAccessor.wrap.

Create an instance from the payload and headers of the given Message.

org.springframework.messaging.simp.stomp back to summary

private Class StompHeaderAccessor.StompPasscode

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.messaging.simp.stomp.StompHeaderAccessor.StompPasscode

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

passcodeback to summary
private final String passcode

Constructor Detail

StompPasscodeback to summary
public StompPasscode(String passcode)

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override