org.apache.mina.protocol
Class AbstractProtocolFilterChain

java.lang.Object
  extended by org.apache.mina.protocol.AbstractProtocolFilterChain
All Implemented Interfaces:
ProtocolFilterChain
Direct Known Subclasses:
ProtocolSessionFilterChain, ProtocolSessionManagerFilterChain

public abstract class AbstractProtocolFilterChain
extends Object
implements ProtocolFilterChain

An abstract implementation of ProtocolFilterChain that provides common operations for developers to extend protocol layer.

All methods has been implemented. The list of filters is maintained as a doublely linked list. You can fire any MINA events which is filtered by this chain using these public methods:

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

Version:
$Rev: 332218 $, $Date: 2005-11-10 12:52:42 +0900 $
Author:
The Apache Directory Project

Constructor Summary
protected AbstractProtocolFilterChain()
           
 
Method Summary
 void addAfter(String baseName, String name, ProtocolFilter filter)
          Adds the specified interceptor with the specified name just after the interceptor whose name is baseName in this chain.
 void addBefore(String baseName, String name, ProtocolFilter filter)
          Adds the specified interceptor with the specified name just before the interceptor whose name is baseName in this chain.
 void addFirst(String name, ProtocolFilter filter)
          Adds the specified interceptor with the specified name at the beginning of this chain.
 void addLast(String name, ProtocolFilter filter)
          Adds the specified interceptor with the specified name at the end of this chain.
 void clear()
          Removes all interceptors added to this chain.
protected  ProtocolFilter createHeadFilter()
          Override this method to create custom head of this filter chain.
protected  ProtocolFilter createTailFilter()
          Override this method to create custom head of this filter chain.
protected abstract  void doWrite(ProtocolSession session, Object message)
           
 void exceptionCaught(ProtocolSession session, Throwable cause)
           
 void filterWrite(ProtocolSession session, Object message)
           
 ProtocolFilter getChild(String name)
           
 List getChildren()
           
 List getChildrenReversed()
           
 void messageReceived(ProtocolSession session, Object message)
           
 void messageSent(ProtocolSession session, Object message)
           
 ProtocolFilter remove(String name)
          Removes the interceptor with the specified name from this chain.
 void sessionClosed(ProtocolSession session)
           
 void sessionIdle(ProtocolSession session, IdleStatus status)
           
 void sessionOpened(ProtocolSession session)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractProtocolFilterChain

protected AbstractProtocolFilterChain()
Method Detail

createHeadFilter

protected ProtocolFilter createHeadFilter()
Override this method to create custom head of this filter chain.


createTailFilter

protected ProtocolFilter createTailFilter()
Override this method to create custom head of this filter chain.


getChild

public ProtocolFilter getChild(String name)
Specified by:
getChild in interface ProtocolFilterChain

addFirst

public void addFirst(String name,
                     ProtocolFilter filter)
Adds the specified interceptor with the specified name at the beginning of this chain.

Specified by:
addFirst in interface ProtocolFilterChain

addLast

public void addLast(String name,
                    ProtocolFilter filter)
Adds the specified interceptor with the specified name at the end of this chain.

Specified by:
addLast in interface ProtocolFilterChain

addBefore

public void addBefore(String baseName,
                      String name,
                      ProtocolFilter filter)
Adds the specified interceptor with the specified name just before the interceptor whose name is baseName in this chain.

Specified by:
addBefore in interface ProtocolFilterChain

addAfter

public void addAfter(String baseName,
                     String name,
                     ProtocolFilter filter)
Adds the specified interceptor with the specified name just after the interceptor whose name is baseName in this chain.

Specified by:
addAfter in interface ProtocolFilterChain

remove

public ProtocolFilter remove(String name)
Removes the interceptor with the specified name from this chain.

Specified by:
remove in interface ProtocolFilterChain

clear

public void clear()
Removes all interceptors added to this chain.

Specified by:
clear in interface ProtocolFilterChain

sessionOpened

public void sessionOpened(ProtocolSession session)

sessionClosed

public void sessionClosed(ProtocolSession session)

sessionIdle

public void sessionIdle(ProtocolSession session,
                        IdleStatus status)

messageReceived

public void messageReceived(ProtocolSession session,
                            Object message)

messageSent

public void messageSent(ProtocolSession session,
                        Object message)

exceptionCaught

public void exceptionCaught(ProtocolSession session,
                            Throwable cause)

filterWrite

public void filterWrite(ProtocolSession session,
                        Object message)

getChildren

public List getChildren()
Specified by:
getChildren in interface ProtocolFilterChain

getChildrenReversed

public List getChildrenReversed()
Specified by:
getChildrenReversed in interface ProtocolFilterChain

doWrite

protected abstract void doWrite(ProtocolSession session,
                                Object message)


Copyright © 2004-2005 . All Rights Reserved.