Errai 3.0.1-SNAPSHOT

org.jboss.errai.bus.client.api
Interface QueueSession

All Known Implementing Classes:
IntrabusQueueSession

public interface QueueSession

The combination of a communication channel (identified by an HTTPSession or other communication session, such as an open WebSocket channel) with an Errai Bus queue ID. An instance of QueueSession identifies a physical communication link with a specific subject on a remote bus. A single communication link typically has many QueueSession instances (one per bus subject).

Note on scope of attributes

QueueSession provides a map-like facility for storing and retrieving arbitrary object ("attributes") by name. These attributes are shared among all QueueSession instances that are associated with the same communication channel (for example, an HTTPSession or a WebSocketChannel).


Method Summary
 void addSessionEndListener(SessionEndListener listener)
          Registers a listener that will notified when this session ends.
 boolean endSession()
          Closes this session and notifies the SessionEndListeners (optional operation; not all QueueSession implementations are closeable).
<T> T
getAttribute(Class<T> type, String attribute)
          Returns the value associated with the given key.
 Collection<String> getAttributeNames()
          Returns the names of all attributes within this session.
 String getParentSessionId()
          Returns the ID of the session this QueueSession wraps.
 String getSessionId()
          Returns the ID of this session, which uniquely identifies it within the scope of this client (or server for a server side session).
 boolean hasAttribute(String attribute)
          Returns true if the specified attribute exists.
 boolean isValid()
           
 Object removeAttribute(String attribute)
          Removes the specified attribute from this session.
 void setAttribute(String attribute, Object value)
          Associates the given value with the given key, replacing the existing value, if any, for the key.
 

Method Detail

getSessionId

String getSessionId()
Returns the ID of this session, which uniquely identifies it within the scope of this client (or server for a server side session). This is not the ID of the underlying wrapped session (for example, it is not a Servlet Session ID).

Returns:
the session id, which is unique within the confines of the present client (or server). Never null.

getParentSessionId

String getParentSessionId()
Returns the ID of the session this QueueSession wraps. In the case of a wrapper around an HTTP Session, this method would return the HTTP Session ID.

Returns:
the session ID from the underlying communication layer, or a unique ID synthesized by the framework for communication layers that don't have unique session ID's of their own. Never null.

endSession

boolean endSession()
Closes this session and notifies the SessionEndListeners (optional operation; not all QueueSession implementations are closeable).

Returns:
true, if this session was closed and listeners have been notified. In the case of a QueueSession that does not implement this operation, listeners are not notified and this method returns false.

setAttribute

void setAttribute(String attribute,
                  Object value)
Associates the given value with the given key, replacing the existing value, if any, for the key.

See the class-level documentation for a note on the scope of these attributes.

Parameters:
attribute - the name (key) of the attribute. Not null.
value - new value for attribute. Null is permitted.

getAttribute

<T> T getAttribute(Class<T> type,
                   String attribute)
Returns the value associated with the given key.

See the class-level documentation for a note on the scope of these attributes.

Type Parameters:
T - the type
Parameters:
type - the type to attempt to cast the attribute's value to
attribute - the name (key) of the attribute. Not null.
Returns:
the value of the attribute, as the specified type. Returns null if the attribute's value is null, or if no such attribute exists. Use hasAttribute(String) to test for the existence of a null-valued attribute.

getAttributeNames

Collection<String> getAttributeNames()
Returns the names of all attributes within this session.

See the class-level documentation for a note on the scope of these attributes.

Returns:
collection of attribute names.

hasAttribute

boolean hasAttribute(String attribute)
Returns true if the specified attribute exists.

See the class-level documentation for a note on the scope of these attributes.

Parameters:
attribute - the attribute name to search for.
Returns:
true if it exists, otherwise false

removeAttribute

Object removeAttribute(String attribute)
Removes the specified attribute from this session.

See the class-level documentation for a note on the scope of these attributes.

Parameters:
attribute - the name of the attribute to remove.
Returns:
the attribute value previously associated with the given name (which may be null). Returns null in case the attribute did not exist.

addSessionEndListener

void addSessionEndListener(SessionEndListener listener)
Registers a listener that will notified when this session ends.

Parameters:
listener - the listener to be notified at session end.

isValid

boolean isValid()

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.