public class SessionAttributeInitializingFilter extends IoFilterAdapter
IoFilter
that sets initial attributes when a new
IoSession
is created. By default, the attribute map is empty when
an IoSession
is newly created. Inserting this filter will make
the pre-configured attributes available after this filter executes the
sessionCreated event.IoFilter.NextFilter
Constructor and Description |
---|
SessionAttributeInitializingFilter()
Creates a new instance with no default attributes.
|
SessionAttributeInitializingFilter(Map<String,? extends Object> attributes)
Creates a new instance with the specified default attributes.
|
Modifier and Type | Method and Description |
---|---|
Object |
getAttribute(String key)
Returns the value of user-defined attribute.
|
Set<String> |
getAttributeKeys() |
Object |
removeAttribute(String key)
Removes a user-defined attribute with the specified key.
|
void |
sessionCreated(IoFilter.NextFilter nextFilter,
IoSession session)
Puts all pre-configured attributes into the actual session attribute
map and forward the event to the next filter.
|
Object |
setAttribute(String key)
Sets a user defined attribute without a value.
|
Object |
setAttribute(String key,
Object value)
Sets a user-defined attribute.
|
void |
setAttributes(Map<String,? extends Object> attributes)
Sets the attribute map.
|
destroy, event, exceptionCaught, filterClose, filterWrite, init, inputClosed, messageReceived, messageSent, onPostAdd, onPostRemove, onPreAdd, onPreRemove, sessionClosed, sessionIdle, sessionOpened, toString
public SessionAttributeInitializingFilter()
setAttribute(String, Object)
and setAttributes(Map)
.public SessionAttributeInitializingFilter(Map<String,? extends Object> attributes)
setAttribute(String, Object)
and setAttributes(Map)
.attributes
- The Attribute's Map to setpublic Object getAttribute(String key)
key
- the key of the attributepublic Object setAttribute(String key, Object value)
key
- the key of the attributevalue
- the value of the attributepublic Object setAttribute(String key)
Boolean.TRUE
.key
- the key of the attributepublic Object removeAttribute(String key)
key
- The attribut's key we want to removeepublic Set<String> getAttributeKeys()
public void setAttributes(Map<String,? extends Object> attributes)
attributes
- The attributes Map to setpublic void sessionCreated(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
sessionCreated
in interface IoFilter
sessionCreated
in class IoFilterAdapter
nextFilter
- the IoFilter.NextFilter
for this filter. You can reuse this
object until this filter is removed from the chain.session
- The IoSession
which has received this eventException
- If an error occurred while processing the eventCopyright © 2004–2022 Apache MINA Project. All rights reserved.