org.apache.mina.common.support
Class AbstractIoFilterChain

java.lang.Object
  extended by org.apache.mina.common.support.AbstractIoFilterChain
All Implemented Interfaces:
IoFilterChain
Direct Known Subclasses:
VmPipeFilterChain

public abstract class AbstractIoFilterChain
extends java.lang.Object
implements IoFilterChain

An abstract implementation of IoFilterChain that provides common operations for developers to implement their own transport layer.

The only method a developer should implement is doWrite(IoSession, IoFilter.WriteRequest). This method is invoked when filter chain is evaluated for IoFilter.filterWrite(NextFilter, IoSession, IoFilter.WriteRequest) and finally to be written out.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.mina.common.IoFilterChain
IoFilterChain.Entry
 
Field Summary
static java.lang.String CONNECT_FUTURE
          A session attribute that stores a ConnectFuture related with the IoSession.
 
Constructor Summary
protected AbstractIoFilterChain(IoSession 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)
          Returns true if this chain contains an IoFilter of the specified filterType.
 boolean contains(IoFilter filter)
          Returns true if this chain contains the specified filter.
 boolean contains(java.lang.String name)
          Returns true if this chain contains an IoFilter with the specified name.
protected abstract  void doClose(IoSession session)
           
protected abstract  void doWrite(IoSession session, IoFilter.WriteRequest writeRequest)
           
protected  void finalize()
           
 void fireExceptionCaught(IoSession session, java.lang.Throwable cause)
          Fires a IoHandler.exceptionCaught(IoSession, Throwable) event.
 void fireFilterClose(IoSession session)
          Fires a IoSession.close() event.
 void fireFilterWrite(IoSession session, IoFilter.WriteRequest writeRequest)
          Fires a IoSession.write(Object) event.
 void fireMessageReceived(IoSession session, java.lang.Object message)
          Fires a IoFilterChain.fireMessageReceived(IoSession, Object) event.
 void fireMessageSent(IoSession session, IoFilter.WriteRequest request)
          Fires a IoHandler.sessionOpened(IoSession) event.
 void fireSessionClosed(IoSession session)
          Fires a IoHandler.sessionClosed(IoSession) event.
 void fireSessionCreated(IoSession session)
          Fires a IoHandler.sessionCreated(IoSession) event.
 void fireSessionIdle(IoSession session, IdleStatus status)
          Fires a IoHandler.sessionIdle(IoSession, IdleStatus) event.
 void fireSessionOpened(IoSession session)
          Fires a IoHandler.sessionOpened(IoSession) event.
 IoFilter get(java.lang.String name)
          Returns the IoFilter with the specified name in this chain.
 java.util.List<IoFilterChain.Entry> getAll()
          Returns the list of all IoFilterChain.Entrys this chain contains.
 java.util.List<IoFilterChain.Entry> getAllReversed()
          Returns the reversed list of all IoFilterChain.Entrys this chain contains.
 IoFilterChain.Entry getEntry(java.lang.String name)
          Returns the IoFilterChain.Entry with the specified name 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.String name)
          Removes the filter with the specified name from this chain.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONNECT_FUTURE

public static final java.lang.String CONNECT_FUTURE
A session attribute that stores a ConnectFuture related with the IoSession. AbstractIoFilterChain clears this attribute and notifies the future when fireSessionOpened(IoSession) or fireExceptionCaught(IoSession, Throwable) is invoked

Constructor Detail

AbstractIoFilterChain

protected AbstractIoFilterChain(IoSession session)
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
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
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
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

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

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

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

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

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 - if IoFilter.onPostRemove(IoFilterChain, String, NextFilter) thrown an exception.

fireSessionCreated

public void fireSessionCreated(IoSession session)
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(IoSession session)
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(IoSession session)
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(IoSession session,
                            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

fireMessageReceived

public void fireMessageReceived(IoSession session,
                                java.lang.Object message)
Description copied from interface: IoFilterChain
Fires a IoFilterChain.fireMessageReceived(IoSession, 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

fireMessageSent

public void fireMessageSent(IoSession session,
                            IoFilter.WriteRequest request)
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:
fireMessageSent in interface IoFilterChain

fireExceptionCaught

public void fireExceptionCaught(IoSession session,
                                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

fireFilterWrite

public void fireFilterWrite(IoSession session,
                            IoFilter.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

fireFilterClose

public void fireFilterClose(IoSession session)
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()
Description copied from interface: IoFilterChain
Returns the list of all IoFilterChain.Entrys this chain contains.

Specified by:
getAll in interface IoFilterChain

getAllReversed

public java.util.List<IoFilterChain.Entry> getAllReversed()
Description copied from interface: IoFilterChain
Returns the reversed list of all IoFilterChain.Entrys this chain contains.

Specified by:
getAllReversed in interface IoFilterChain

contains

public boolean contains(java.lang.String name)
Description copied from interface: IoFilterChain
Returns true if this chain contains an IoFilter with the specified name.

Specified by:
contains in interface IoFilterChain

contains

public boolean contains(IoFilter filter)
Description copied from interface: IoFilterChain
Returns true if this chain contains the specified filter.

Specified by:
contains in interface IoFilterChain

contains

public boolean contains(java.lang.Class<? extends IoFilter> filterType)
Description copied from interface: IoFilterChain
Returns true if this chain contains an IoFilter of the specified filterType.

Specified by:
contains in interface IoFilterChain

toString

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

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

doWrite

protected abstract void doWrite(IoSession session,
                                IoFilter.WriteRequest writeRequest)
                         throws java.lang.Exception
Throws:
java.lang.Exception

doClose

protected abstract void doClose(IoSession session)
                         throws java.lang.Exception
Throws:
java.lang.Exception