Package org.apache.mina.filter.util
Class SessionAttributeInitializingFilter
- java.lang.Object
-
- org.apache.mina.core.filterchain.IoFilterAdapter
-
- org.apache.mina.filter.util.SessionAttributeInitializingFilter
-
- All Implemented Interfaces:
IoFilter
public class SessionAttributeInitializingFilter extends IoFilterAdapter
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.mina.core.filterchain.IoFilter
IoFilter.NextFilter
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.lang.Object>attributes
-
Constructor Summary
Constructors Constructor Description SessionAttributeInitializingFilter()Creates a new instance with no default attributes.SessionAttributeInitializingFilter(java.util.Map<java.lang.String,? extends java.lang.Object> attributes)Creates a new instance with the specified default attributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) booleancontainsAttribute(java.lang.String key)java.lang.ObjectgetAttribute(java.lang.String key)Returns the value of user-defined attribute.java.util.Set<java.lang.String>getAttributeKeys()java.lang.ObjectremoveAttribute(java.lang.String key)Removes a user-defined attribute with the specified key.voidsessionCreated(IoFilter.NextFilter nextFilter, IoSession session)Puts all pre-configured attributes into the actual session attribute map and forward the event to the next filter.java.lang.ObjectsetAttribute(java.lang.String key)Sets a user defined attribute without a value.java.lang.ObjectsetAttribute(java.lang.String key, java.lang.Object value)Sets a user-defined attribute.voidsetAttributes(java.util.Map<java.lang.String,? extends java.lang.Object> attributes)Sets the attribute map.-
Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter
destroy, event, exceptionCaught, filterClose, filterWrite, init, inputClosed, messageReceived, messageSent, onPostAdd, onPostRemove, onPreAdd, onPreRemove, sessionClosed, sessionIdle, sessionOpened, toString
-
-
-
-
Constructor Detail
-
SessionAttributeInitializingFilter
public SessionAttributeInitializingFilter()
Creates a new instance with no default attributes. You can set the additional attributes by calling methods such assetAttribute(String, Object)andsetAttributes(Map).
-
SessionAttributeInitializingFilter
public SessionAttributeInitializingFilter(java.util.Map<java.lang.String,? extends java.lang.Object> attributes)
Creates a new instance with the specified default attributes. You can set the additional attributes by calling methods such assetAttribute(String, Object)andsetAttributes(Map).- Parameters:
attributes- The Attribute's Map to set
-
-
Method Detail
-
getAttribute
public java.lang.Object getAttribute(java.lang.String key)
Returns the value of user-defined attribute.- Parameters:
key- the key of the attribute- Returns:
nullif there is no attribute with the specified key
-
setAttribute
public java.lang.Object setAttribute(java.lang.String key, java.lang.Object value)Sets a user-defined attribute.- Parameters:
key- the key of the attributevalue- the value of the attribute- Returns:
- The old value of the attribute.
nullif it is new.
-
setAttribute
public java.lang.Object setAttribute(java.lang.String key)
Sets a user defined attribute without a value. This is useful when you just want to put a 'mark' attribute. Its value is set toBoolean.TRUE.- Parameters:
key- the key of the attribute- Returns:
- The old value of the attribute.
nullif it is new.
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.String key)
Removes a user-defined attribute with the specified key.- Parameters:
key- The attribut's key we want to removee- Returns:
- The old value of the attribute.
nullif not found.
-
containsAttribute
boolean containsAttribute(java.lang.String key)
- Returns:
trueif this session contains the attribute with the specifiedkey.
-
getAttributeKeys
public java.util.Set<java.lang.String> getAttributeKeys()
- Returns:
- the set of keys of all user-defined attributes.
-
setAttributes
public void setAttributes(java.util.Map<java.lang.String,? extends java.lang.Object> attributes)
Sets the attribute map. The specified attributes are copied into the underlying map, so modifying the specified attributes parameter after the call won't change the internal state.- Parameters:
attributes- The attributes Map to set
-
sessionCreated
public void sessionCreated(IoFilter.NextFilter nextFilter, IoSession session) throws java.lang.Exception
Puts all pre-configured attributes into the actual session attribute map and forward the event to the next filter.- Specified by:
sessionCreatedin interfaceIoFilter- Overrides:
sessionCreatedin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this event- Throws:
java.lang.Exception- If an error occurred while processing the event
-
-