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

public abstract Class SimpAttributesContextHolder

extends Object
Class Inheritance
Imports
org.springframework.core.NamedThreadLocal, org.springframework.lang.Nullable, org.springframework.messaging.Message

Holder class to expose SiMP attributes associated with a session (e.g. WebSocket) in the form of a thread-bound SimpAttributes object.
Author
Rossen Stoyanchev
Since
4.1

Field Summary

Modifier and TypeField and Description
private static final ThreadLocal<SimpAttributes>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static SimpAttributes

Returns:

the attributes, never null
currentAttributes
()

Return the SimpAttributes currently bound to the thread or raise an java.lang.IllegalStateException if none are bound.

public static SimpAttributes

Returns:

the attributes or null if not bound
getAttributes
()

Return the SimpAttributes currently bound to the thread.

public static void
resetAttributes()

Reset the SimpAttributes for the current thread.

public static void
setAttributes(SimpAttributes
the RequestAttributes to expose
attributes
)

Bind the given SimpAttributes to the current thread.

public static void
setAttributesFromMessage(Message<?>
the message to extract session attributes from
message
)

Extract the SiMP session attributes from the given message, wrap them in a SimpAttributes instance and bind it to the current thread.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributesHolderback to summary
private static final ThreadLocal<SimpAttributes> attributesHolder

Constructor Detail

SimpAttributesContextHolderback to summary
public SimpAttributesContextHolder()

Method Detail

currentAttributesback to summary
public static SimpAttributes currentAttributes() throws IllegalStateException

Return the SimpAttributes currently bound to the thread or raise an java.lang.IllegalStateException if none are bound.

Returns:SimpAttributes

the attributes, never null

Exceptions
IllegalStateException:
if attributes are not bound
getAttributesback to summary
public static SimpAttributes getAttributes()

Return the SimpAttributes currently bound to the thread.

Returns:SimpAttributes

the attributes or null if not bound

Annotations
@Nullable
resetAttributesback to summary
public static void resetAttributes()

Reset the SimpAttributes for the current thread.

setAttributesback to summary
public static void setAttributes(SimpAttributes attributes)

Bind the given SimpAttributes to the current thread.

Parameters
attributes:SimpAttributes

the RequestAttributes to expose

setAttributesFromMessageback to summary
public static void setAttributesFromMessage(Message<?> message)

Extract the SiMP session attributes from the given message, wrap them in a SimpAttributes instance and bind it to the current thread.

Parameters
message:Message<?>

the message to extract session attributes from