org.apache.mina.core.filterchain
Class DefaultIoFilterChain

java.lang.Object
  extended by org.apache.mina.core.filterchain.DefaultIoFilterChain
All Implemented Interfaces:
IoFilterChain

public class DefaultIoFilterChain
extends java.lang.Object
implements IoFilterChain

A default implementation of IoFilterChain that provides all operations for developers who want to implement their own transport layer once used with AbstractIoSession.

Author:
Apache MINA Project

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.mina.core.filterchain.IoFilterChain
IoFilterChain.Entry
 
Field Summary
static AttributeKey SESSION_CREATED_FUTURE
          A session attribute that stores an IoFuture related with the IoSession.
 
Constructor Summary
DefaultIoFilterChain(AbstractIoSession session)
          Create a new default chain, associated with a session.
 
Method Summary
 void addAfter(java.lang.String baseName, java.lang.String name, IoFilter filter)
          Adds the specified filter with the specified name just after the filter whose name is baseName in this chain.
 void addBefore(java.lang.String baseName, java.lang.String name, IoFilter filter)
          Adds the specified filter with the specified name just before the filter whose name is baseName in this chain.
 void addFirst(java.lang.String name, IoFilter filter)
          Adds the specified filter with the specified name at the beginning of this chain.
 void addLast(java.lang.String name, IoFilter filter)
          Adds the specified filter with the specified name at the end of this chain.
 void clear()
          Removes all filters added to this chain.
 boolean contains(java.lang.Class<? extends IoFilter> filterType)
           
 boolean contains(IoFilter filter)
           
 boolean contains(java.lang.String name)
           
 void fireExceptionCaught(java.lang.Throwable cause)
          Fires a IoHandler.exceptionCaught(IoSession, Throwable) event.
 void fireFilterClose()
          Fires a IoSession.close() event.
 void fireFilterWrite(WriteRequest writeRequest)
          Fires a IoSession.write(Object) event.
 void fireMessageReceived(java.lang.Object message)
          Fires a IoHandler#messageReceived(Object) event.
 void fireMessageSent(WriteRequest request)
          Fires a IoHandler#messageSent(IoSession) event.
 void fireSessionClosed()
          Fires a IoHandler.sessionClosed(IoSession) event.
 void fireSessionCreated()
          Fires a IoHandler.sessionCreated(IoSession) event.
 void fireSessionIdle(IdleStatus status)
          Fires a IoHandler.sessionIdle(IoSession, IdleStatus) event.
 void fireSessionOpened()
          Fires a IoHandler.sessionOpened(IoSession) event.
 IoFilter get(java.lang.Class<? extends IoFilter> filterType)
          Returns the IoFilter with the specified filterType in this chain.
 IoFilter get(java.lang.String name)
          Returns the IoFilter with the specified name in this chain.
 java.util.List<IoFilterChain.Entry> getAll()
           
 java.util.List<IoFilterChain.Entry> getAllReversed()
           
 IoFilterChain.Entry getEntry(java.lang.Class<? extends IoFilter> filterType)
          Returns the IoFilterChain.Entry with the specified filterType in this chain.
 IoFilterChain.Entry getEntry(IoFilter filter)
          Returns the IoFilterChain.Entry with the specified filter in this chain.
 IoFilterChain.Entry getEntry(java.lang.String name)
          Returns the IoFilterChain.Entry with the specified name in this chain.
 IoFilter.NextFilter getNextFilter(java.lang.Class<? extends IoFilter> filterType)
          Returns the IoFilter.NextFilter of the specified filterType in this chain.
 IoFilter.NextFilter getNextFilter(IoFilter filter)
          Returns the IoFilter.NextFilter of the specified IoFilter in this chain.
 IoFilter.NextFilter getNextFilter(java.lang.String name)
          Returns the IoFilter.NextFilter of the IoFilter with the specified name in this chain.
 IoSession getSession()
          Returns the parent IoSession of this chain.
 IoFilter remove(java.lang.Class<? extends IoFilter> filterType)
          Replace the filter of the specified type with the specified new filter.
 void remove(IoFilter filter)
          Replace the filter with the specified name with the specified new filter.
 IoFilter remove(java.lang.String name)
          Removes the filter with the specified name from this chain.
 IoFilter replace(java.lang.Class<? extends IoFilter> oldFilterType, IoFilter newFilter)
          Replace the filter of the specified type with the specified new filter.
 void replace(IoFilter oldFilter, IoFilter newFilter)
          Replace the filter with the specified name with the specified new filter.
 IoFilter replace(java.lang.String name, IoFilter newFilter)
          Replace the filter with the specified name with the specified new filter.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SESSION_CREATED_FUTURE

public static final AttributeKey SESSION_CREATED_FUTURE
A session attribute that stores an IoFuture related with the IoSession. DefaultIoFilterChain clears this attribute and notifies the future when fireSessionCreated() or fireExceptionCaught(Throwable) is invoked.

Constructor Detail

DefaultIoFilterChain

public DefaultIoFilterChain(AbstractIoSession session)
Create a new default chain, associated with a session. It will only contain a HeadFilter and a TailFilter.

Parameters:
session - The session associated with the created filter chain
Method Detail

getSession

public IoSession getSession()
Description copied from interface: IoFilterChain
Returns the parent IoSession of this chain.

Specified by:
getSession in interface IoFilterChain
Returns:
IoSession

getEntry

public IoFilterChain.Entry getEntry(java.lang.String name)
Description copied from interface: IoFilterChain
Returns the IoFilterChain.Entry with the specified name in this chain.

Specified by:
getEntry in interface IoFilterChain
Parameters:
name - The filter's name we are looking for
Returns:
null if there's no such name in this chain

getEntry

public IoFilterChain.Entry getEntry(IoFilter filter)
Description copied from interface: IoFilterChain
Returns the IoFilterChain.Entry with the specified filter in this chain.

Specified by:
getEntry in interface IoFilterChain
Parameters:
filter - The Filter we are looking for
Returns:
null if there's no such filter in this chain

getEntry

public IoFilterChain.Entry getEntry(java.lang.Class<? extends IoFilter> filterType)
Description copied from interface: IoFilterChain
Returns the IoFilterChain.Entry with the specified filterType in this chain. If there's more than one filter with the specified type, the first match will be chosen.

Specified by:
getEntry in interface IoFilterChain
Parameters:
filterType - The filter class we are looking for
Returns:
null if there's no such name in this chain

get

public IoFilter get(java.lang.String name)
Description copied from interface: IoFilterChain
Returns the IoFilter with the specified name in this chain.

Specified by:
get in interface IoFilterChain
Parameters:
name - the filter's name
Returns:
null if there's no such name in this chain

get

public IoFilter get(java.lang.Class<? extends IoFilter> filterType)
Description copied from interface: IoFilterChain
Returns the IoFilter with the specified filterType in this chain. If there's more than one filter with the specified type, the first match will be chosen.

Specified by:
get in interface IoFilterChain
Parameters:
filterType - The filter class
Returns:
null if there's no such name in this chain

getNextFilter

public IoFilter.NextFilter getNextFilter(java.lang.String name)
Description copied from interface: IoFilterChain
Returns the IoFilter.NextFilter of the IoFilter with the specified name in this chain.

Specified by:
getNextFilter in interface IoFilterChain
Parameters:
name - The filter's name we want the next filter
Returns:
null if there's no such name in this chain

getNextFilter

public IoFilter.NextFilter getNextFilter(IoFilter filter)
Description copied from interface: IoFilterChain
Returns the IoFilter.NextFilter of the specified IoFilter in this chain.

Specified by:
getNextFilter in interface IoFilterChain
Parameters:
filter - The filter for which we want the next filter
Returns:
null if there's no such name in this chain

getNextFilter

public IoFilter.NextFilter getNextFilter(java.lang.Class<? extends IoFilter> filterType)
Description copied from interface: IoFilterChain
Returns the IoFilter.NextFilter of the specified filterType in this chain. If there's more than one filter with the specified type, the first match will be chosen.

Specified by:
getNextFilter in interface IoFilterChain
Parameters:
filterType - The Filter class for which we want the next filter
Returns:
null if there's no such name in this chain

addFirst

public void addFirst(java.lang.String name,
                     IoFilter filter)
Description copied from interface: IoFilterChain
Adds the specified filter with the specified name at the beginning of this chain.

Specified by:
addFirst in interface IoFilterChain
Parameters:
name - The filter's name
filter - The filter to add

addLast

public void addLast(java.lang.String name,
                    IoFilter filter)
Description copied from interface: IoFilterChain
Adds the specified filter with the specified name at the end of this chain.

Specified by:
addLast in interface IoFilterChain
Parameters:
name - The filter's name
filter - The filter to add

addBefore

public void addBefore(java.lang.String baseName,
                      java.lang.String name,
                      IoFilter filter)
Description copied from interface: IoFilterChain
Adds the specified filter with the specified name just before the filter whose name is baseName in this chain.

Specified by:
addBefore in interface IoFilterChain
Parameters:
baseName - The targeted Filter's name
name - The filter's name
filter - The filter to add

addAfter

public void addAfter(java.lang.String baseName,
                     java.lang.String name,
                     IoFilter filter)
Description copied from interface: IoFilterChain
Adds the specified filter with the specified name just after the filter whose name is baseName in this chain.

Specified by:
addAfter in interface IoFilterChain
Parameters:
baseName - The targeted Filter's name
name - The filter's name
filter - The filter to add

remove

public IoFilter remove(java.lang.String name)
Description copied from interface: IoFilterChain
Removes the filter with the specified name from this chain.

Specified by:
remove in interface IoFilterChain
Parameters:
name - The name of the filter to remove
Returns:
The removed filter

remove

public void remove(IoFilter filter)
Description copied from interface: IoFilterChain
Replace the filter with the specified name with the specified new filter.

Specified by:
remove in interface IoFilterChain

remove

public IoFilter remove(java.lang.Class<? extends IoFilter> filterType)
Description copied from interface: IoFilterChain
Replace the filter of the specified type with the specified new filter. If there's more than one filter with the specified type, the first match will be replaced.

Specified by:
remove in interface IoFilterChain
Returns:
The removed filter

replace

public IoFilter replace(java.lang.String name,
                        IoFilter newFilter)
Description copied from interface: IoFilterChain
Replace the filter with the specified name with the specified new filter.

Specified by:
replace in interface IoFilterChain
Parameters:
name - The name of the filter we want to replace
newFilter - The new filter
Returns:
the old filter

replace

public void replace(IoFilter oldFilter,
                    IoFilter newFilter)
Description copied from interface: IoFilterChain
Replace the filter with the specified name with the specified new filter.

Specified by:
replace in interface IoFilterChain
Parameters:
oldFilter - The filter we want to replace
newFilter - The new filter

replace

public IoFilter replace(java.lang.Class<? extends IoFilter> oldFilterType,
                        IoFilter newFilter)
Description copied from interface: IoFilterChain
Replace the filter of the specified type with the specified new filter. If there's more than one filter with the specified type, the first match will be replaced.

Specified by:
replace in interface IoFilterChain
Parameters:
oldFilterType - The filter class we want to replace
newFilter - The new filter

clear

public void clear()
           throws java.lang.Exception
Description copied from interface: IoFilterChain
Removes all filters added to this chain.

Specified by:
clear in interface IoFilterChain
Throws:
java.lang.Exception

fireSessionCreated

public void fireSessionCreated()
Description copied from interface: IoFilterChain
Fires a IoHandler.sessionCreated(IoSession) event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.

Specified by:
fireSessionCreated in interface IoFilterChain

fireSessionOpened

public void fireSessionOpened()
Description copied from interface: IoFilterChain
Fires a IoHandler.sessionOpened(IoSession) event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.

Specified by:
fireSessionOpened in interface IoFilterChain

fireSessionClosed

public void fireSessionClosed()
Description copied from interface: IoFilterChain
Fires a IoHandler.sessionClosed(IoSession) event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.

Specified by:
fireSessionClosed in interface IoFilterChain

fireSessionIdle

public void fireSessionIdle(IdleStatus status)
Description copied from interface: IoFilterChain
Fires a IoHandler.sessionIdle(IoSession, IdleStatus) event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.

Specified by:
fireSessionIdle in interface IoFilterChain
Parameters:
status - The current status to propagate

fireMessageReceived

public void fireMessageReceived(java.lang.Object message)
Description copied from interface: IoFilterChain
Fires a IoHandler#messageReceived(Object) event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.

Specified by:
fireMessageReceived in interface IoFilterChain
Parameters:
message - The received message

fireMessageSent

public void fireMessageSent(WriteRequest request)
Description copied from interface: IoFilterChain
Fires a IoHandler#messageSent(IoSession) event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.

Specified by:
fireMessageSent in interface IoFilterChain
Parameters:
request - The sent request

fireExceptionCaught

public void fireExceptionCaught(java.lang.Throwable cause)
Description copied from interface: IoFilterChain
Fires a IoHandler.exceptionCaught(IoSession, Throwable) event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.

Specified by:
fireExceptionCaught in interface IoFilterChain
Parameters:
cause - The exception cause

fireFilterWrite

public void fireFilterWrite(WriteRequest writeRequest)
Description copied from interface: IoFilterChain
Fires a IoSession.write(Object) event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.

Specified by:
fireFilterWrite in interface IoFilterChain
Parameters:
writeRequest - The message to write

fireFilterClose

public void fireFilterClose()
Description copied from interface: IoFilterChain
Fires a IoSession.close() event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.

Specified by:
fireFilterClose in interface IoFilterChain

getAll

public java.util.List<IoFilterChain.Entry> getAll()
Specified by:
getAll in interface IoFilterChain
Returns:
The list of all IoFilterChain.Entrys this chain contains.

getAllReversed

public java.util.List<IoFilterChain.Entry> getAllReversed()
Specified by:
getAllReversed in interface IoFilterChain
Returns:
The reversed list of all IoFilterChain.Entrys this chain contains.

contains

public boolean contains(java.lang.String name)
Specified by:
contains in interface IoFilterChain
Parameters:
name - The filter's name we are looking for
Returns:
true if this chain contains an IoFilter with the specified name.

contains

public boolean contains(IoFilter filter)
Specified by:
contains in interface IoFilterChain
Parameters:
filter - The filter we are looking for
Returns:
true if this chain contains the specified filter.

contains

public boolean contains(java.lang.Class<? extends IoFilter> filterType)
Specified by:
contains in interface IoFilterChain
Parameters:
filterType - The filter's class we are looking for
Returns:
true if this chain contains an IoFilter of the specified filterType.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2004-2011 Apache MINA Project. All Rights Reserved.