类 SimpAttributesContextHolder
- java.lang.Object
- org.springframework.messaging.simp.SimpAttributesContextHolder
public abstract class SimpAttributesContextHolder extends Object
Holder class to expose SiMP attributes associated with a session (e.g. WebSocket) in the form of a thread-boundSimpAttributes
object.- 从以下版本开始:
- 4.1
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 构造器 说明 SimpAttributesContextHolder()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static SimpAttributes
currentAttributes()
Return the SimpAttributes currently bound to the thread or raise anIllegalStateException
if none are bound.static SimpAttributes
getAttributes()
Return the SimpAttributes currently bound to the thread.static void
resetAttributes()
Reset the SimpAttributes for the current thread.static void
setAttributes(SimpAttributes attributes)
Bind the given SimpAttributes to the current thread.static void
setAttributesFromMessage(Message<?> message)
Extract the SiMP session attributes from the given message, wrap them in aSimpAttributes
instance and bind it to the current thread.
构造器详细资料
SimpAttributesContextHolder
public SimpAttributesContextHolder()
方法详细资料
resetAttributes
public static void resetAttributes()
Reset the SimpAttributes for the current thread.
setAttributes
public static void setAttributes(@Nullable SimpAttributes attributes)
Bind the given SimpAttributes to the current thread.- 参数:
attributes
- the RequestAttributes to expose
setAttributesFromMessage
public static void setAttributesFromMessage(Message<?> message)
Extract the SiMP session attributes from the given message, wrap them in aSimpAttributes
instance and bind it to the current thread.- 参数:
message
- the message to extract session attributes from
getAttributes
@Nullable public static SimpAttributes getAttributes()
Return the SimpAttributes currently bound to the thread.- 返回:
- the attributes or
null
if not bound
currentAttributes
public static SimpAttributes currentAttributes() throws IllegalStateException
Return the SimpAttributes currently bound to the thread or raise anIllegalStateException
if none are bound.- 返回:
- the attributes, never
null
- 抛出:
IllegalStateException
- if attributes are not bound