org.springframework.messaging.simp

## Class 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-bound `SimpAttributes` object.

Since:
  4.1
Author:
  Rossen Stoyanchev

### Constructor Summary

Constructors
Constructor and Description
`SimpAttributesContextHolder()`

### Method Summary

All Methods Static Methods Concrete Methods
`static SimpAttributes` `currentAttributes()` Return the SimpAttributes currently bound to the thread or raise an `IllegalStateException` 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 a `SimpAttributes` instance and bind it to the current thread.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### SimpAttributesContextHolder

    public SimpAttributesContextHolder()

### Method Detail

#### 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.

Parameters:
  `attributes` - the RequestAttributes to expose

#### setAttributesFromMessage

    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` - the message to extract session attributes from

#### getAttributes

    @Nullable
    public static SimpAttributes getAttributes()

Return the SimpAttributes currently bound to the thread.

Returns:
  the attributes or `null` if not bound

#### currentAttributes

    public static SimpAttributes currentAttributes()
                                            throws IllegalStateException

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

Returns:
  the attributes, never `null`
Throws:
  `IllegalStateException` - if attributes are not bound