public class SimpAttributes
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DESTRUCTION_CALLBACK_NAME_PREFIX
Prefix for the name of session attributes used to store destruction callbacks.
|
static java.lang.String |
SESSION_COMPLETED_NAME
Key set after the session is completed.
|
static java.lang.String |
SESSION_MUTEX_NAME
Key for the mutex session attribute.
|
Constructor and Description |
---|
SimpAttributes(java.lang.String sessionId,
java.util.Map<java.lang.String,java.lang.Object> attributes)
Constructor wrapping the given session attributes map.
|
Modifier and Type | Method and Description |
---|---|
static SimpAttributes |
fromMessage(Message<?> message)
Extract the SiMP session attributes from the given message and
wrap them in a
SimpAttributes instance. |
java.lang.Object |
getAttribute(java.lang.String name)
Return the value for the attribute of the given name, if any.
|
java.lang.String[] |
getAttributeNames()
Retrieve the names of all attributes.
|
java.lang.String |
getSessionId()
Return an id for the associated session.
|
java.lang.Object |
getSessionMutex()
Expose the object to synchronize on for the underlying session.
|
boolean |
isSessionCompleted()
Whether the
sessionCompleted() was already invoked. |
void |
registerDestructionCallback(java.lang.String name,
java.lang.Runnable callback)
Register a callback to execute on destruction of the specified attribute.
|
void |
removeAttribute(java.lang.String name)
Remove the attribute of the given name, if it exists.
|
void |
sessionCompleted()
Invoked when the session is completed.
|
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Set the value with the given name replacing an existing value (if any).
|
public static final java.lang.String SESSION_MUTEX_NAME
public static final java.lang.String SESSION_COMPLETED_NAME
public static final java.lang.String DESTRUCTION_CALLBACK_NAME_PREFIX
public SimpAttributes(java.lang.String sessionId, java.util.Map<java.lang.String,java.lang.Object> attributes)
sessionId
- the id of the associated sessionattributes
- the attributes@Nullable public java.lang.Object getAttribute(java.lang.String name)
name
- the name of the attributenull
if not foundpublic void setAttribute(java.lang.String name, java.lang.Object value)
name
- the name of the attributevalue
- the value for the attributepublic void removeAttribute(java.lang.String name)
Also removes the registered destruction callback for the specified attribute, if any. However it does not execute the callback. It is assumed the removed object will continue to be used and destroyed independently at the appropriate time.
name
- the name of the attributepublic java.lang.String[] getAttributeNames()
null
public void registerDestructionCallback(java.lang.String name, java.lang.Runnable callback)
name
- the name of the attribute to register the callback forcallback
- the destruction callback to be executedpublic java.lang.String getSessionId()
null
)public java.lang.Object getSessionMutex()
null
)public boolean isSessionCompleted()
sessionCompleted()
was already invoked.public void sessionCompleted()
public static SimpAttributes fromMessage(Message<?> message)
SimpAttributes
instance.message
- the message to extract session attributes from