| org.apache.mina.common.IoSessionAttributeMap
IoSessionAttributeMap | public interface IoSessionAttributeMap (Code) | | Stores the user-defined attributes which is provided per
IoSession .
All user-defined attribute accesses in
IoSession are forwarded to
the instance of
IoSessionAttributeMap .
author: The Apache MINA Project (dev@mina.apache.org) version: $Rev: 601679 $, $Date: 2007-12-06 03:13:21 -0700 (Thu, 06 Dec 2007) $ |
Method Summary | |
boolean | containsAttribute(IoSession session, Object key) Returns true if this session contains the attribute with
the specified key. | void | dispose(IoSession session) Disposes any releases associated with the specified session. | Object | getAttribute(IoSession session, Object key, Object defaultValue) Returns the value of user defined attribute associated with the
specified key. | Set<Object> | getAttributeKeys(IoSession session) Returns the set of keys of all user-defined attributes. | Object | removeAttribute(IoSession session, Object key) Removes a user-defined attribute with the specified key.
The old value of the attribute. | boolean | removeAttribute(IoSession session, Object key, Object value) Removes a user defined attribute with the specified key if the current
attribute value is equal to the specified value. | boolean | replaceAttribute(IoSession session, Object key, Object oldValue, Object newValue) Replaces a user defined attribute with the specified key if the
value of the attribute is equals to the specified old value. | Object | setAttribute(IoSession session, Object key, Object value) Sets a user-defined attribute.
Parameters: key - the key of the attribute Parameters: value - the value of the attribute The old value of the attribute. | Object | setAttributeIfAbsent(IoSession session, Object key, Object value) Sets a user defined attribute if the attribute with the specified key
is not set yet. |
containsAttribute | boolean containsAttribute(IoSession session, Object key)(Code) | | Returns true if this session contains the attribute with
the specified key.
|
dispose | void dispose(IoSession session) throws Exception(Code) | | Disposes any releases associated with the specified session.
This method is invoked on disconnection.
|
getAttribute | Object getAttribute(IoSession session, Object key, Object defaultValue)(Code) | | Returns the value of user defined attribute associated with the
specified key. If there's no such attribute, the specified default
value is associated with the specified key, and the default value is
returned. This method is same with the following code except that the
operation is performed atomically.
if (containsAttribute(key)) {
return getAttribute(key);
} else {
setAttribute(key, defaultValue);
return defaultValue;
}
|
getAttributeKeys | Set<Object> getAttributeKeys(IoSession session)(Code) | | Returns the set of keys of all user-defined attributes.
|
removeAttribute | Object removeAttribute(IoSession session, Object key)(Code) | | Removes a user-defined attribute with the specified key.
The old value of the attribute. null if not found. |
removeAttribute | boolean removeAttribute(IoSession session, Object key, Object value)(Code) | | Removes a user defined attribute with the specified key if the current
attribute value is equal to the specified value. This method is same
with the following code except that the operation is performed
atomically.
if (containsAttribute(key) && getAttribute(key).equals(value)) {
removeAttribute(key);
return true;
} else {
return false;
}
|
replaceAttribute | boolean replaceAttribute(IoSession session, Object key, Object oldValue, Object newValue)(Code) | | Replaces a user defined attribute with the specified key if the
value of the attribute is equals to the specified old value.
This method is same with the following code except that the operation
is performed atomically.
if (containsAttribute(key) && getAttribute(key).equals(oldValue)) {
setAttribute(key, newValue);
return true;
} else {
return false;
}
|
setAttribute | Object setAttribute(IoSession session, Object key, Object value)(Code) | | Sets a user-defined attribute.
Parameters: key - the key of the attribute Parameters: value - the value of the attribute The old value of the attribute. null if it is new. |
setAttributeIfAbsent | Object setAttributeIfAbsent(IoSession session, Object key, Object value)(Code) | | Sets a user defined attribute if the attribute with the specified key
is not set yet. This method is same with the following code except
that the operation is performed atomically.
if (containsAttribute(key)) {
return getAttribute(key);
} else {
return setAttribute(key, value);
}
|
|
|