directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r159009 - in directory/network/trunk/src: java/org/apache/mina/io/ java/org/apache/mina/io/datagram/ java/org/apache/mina/io/socket/ java/org/apache/mina/protocol/ java/org/apache/mina/protocol/io/ java/org/apache/mina/protocol/vmpipe/ java/org/apache/mina/registry/ test/org/apache/mina/io/ test/org/apache/mina/protocol/
Date Fri, 25 Mar 2005 13:43:24 GMT
Author: trustin
Date: Fri Mar 25 05:43:18 2005
New Revision: 159009

URL: http://svn.apache.org/viewcvs?view=rev&rev=159009
Log:
It is turned out that filter chains are not nestable.  Nested filter chains will cause emission of duplicate events.  So, I made chains unnestable.

Modified:
    directory/network/trunk/src/java/org/apache/mina/io/AbstractIoHandlerFilterChain.java
    directory/network/trunk/src/java/org/apache/mina/io/IoAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/io/IoConnector.java
    directory/network/trunk/src/java/org/apache/mina/io/IoHandlerFilterChain.java
    directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramConnector.java
    directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramFilterChain.java
    directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramSession.java
    directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java
    directory/network/trunk/src/java/org/apache/mina/io/socket/SocketFilterChain.java
    directory/network/trunk/src/java/org/apache/mina/io/socket/SocketIoProcessor.java
    directory/network/trunk/src/java/org/apache/mina/io/socket/SocketSession.java
    directory/network/trunk/src/java/org/apache/mina/protocol/AbstractProtocolHandlerFilterChain.java
    directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolConnector.java
    directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolHandlerFilterChain.java
    directory/network/trunk/src/java/org/apache/mina/protocol/io/IoAdapter.java
    directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolConnector.java
    directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolFilterChain.java
    directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java
    directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeFilter.java
    directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeFilterChain.java
    directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeIdleStatusChecker.java
    directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeSession.java
    directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java
    directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
    directory/network/trunk/src/test/org/apache/mina/io/IoHandlerFilterChainTest.java
    directory/network/trunk/src/test/org/apache/mina/protocol/ProtocolHandlerFilterChainTest.java

Modified: directory/network/trunk/src/java/org/apache/mina/io/AbstractIoHandlerFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/AbstractIoHandlerFilterChain.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/AbstractIoHandlerFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/AbstractIoHandlerFilterChain.java Fri Mar 25 05:43:18 2005
@@ -9,6 +9,7 @@
 
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IdleStatus;
+import org.apache.mina.io.IoHandlerFilter.NextFilter;
 
 public abstract class AbstractIoHandlerFilterChain implements IoHandlerFilterChain
 {
@@ -51,90 +52,7 @@
         public void filterWrite( NextFilter nextFilter, IoSession session,
                                  ByteBuffer buf, Object marker )
         {
-            if( parent == null )
-            {
-                // write only when root filter chain traversal is finished.
-                doWrite( session, buf, marker );
-            }
-        }
-    };
-    
-    private final IoHandlerFilter NEXT_FILTER = new IoHandlerFilter()
-    {
-        public void sessionOpened( NextFilter nextFilter, IoSession session )
-        {
-            if( parent != null )
-            {
-                Entry e = ( Entry ) parent.filter2entry.get( AbstractIoHandlerFilterChain.this );
-                e.nextFilter.sessionOpened( session );
-            }
-            nextFilter.sessionOpened( session );
-        }
-
-        public void sessionClosed( NextFilter nextFilter, IoSession session )
-        {
-            if( parent != null )
-            {
-                Entry e = ( Entry ) parent.filter2entry.get( AbstractIoHandlerFilterChain.this );
-                e.nextFilter.sessionClosed( session );
-            }
-            nextFilter.sessionClosed( session );
-        }
-
-        public void sessionIdle( NextFilter nextFilter, IoSession session,
-                                IdleStatus status )
-        {
-            if( parent != null )
-            {
-                Entry e = ( Entry ) parent.filter2entry.get( AbstractIoHandlerFilterChain.this );
-                
-                e.nextFilter.sessionIdle( session, status );
-            }
-            nextFilter.sessionIdle( session, status );
-        }
-
-        public void exceptionCaught( NextFilter nextFilter,
-                                    IoSession session, Throwable cause )
-        {
-            if( parent != null )
-            {
-                Entry e = ( Entry ) parent.filter2entry.get( AbstractIoHandlerFilterChain.this );
-                e.nextFilter.exceptionCaught( session, cause );
-            }
-            nextFilter.exceptionCaught( session, cause );
-        }
-
-        public void dataRead( NextFilter nextFilter, IoSession session,
-                             ByteBuffer buf )
-        {
-            if( parent != null )
-            {
-                Entry e = ( Entry ) parent.filter2entry.get( AbstractIoHandlerFilterChain.this );
-                e.nextFilter.dataRead( session, buf );
-            }
-            nextFilter.dataRead( session, buf );
-        }
-
-        public void dataWritten( NextFilter nextFilter, IoSession session,
-                                Object marker )
-        {
-            if( parent != null )
-            {
-                Entry e = ( Entry ) parent.filter2entry.get( AbstractIoHandlerFilterChain.this );
-                e.nextFilter.dataWritten( session, marker );
-            }
-            nextFilter.dataWritten( session, marker );
-        }
-        
-        public void filterWrite( NextFilter nextFilter, IoSession session,
-                                 ByteBuffer buf, Object marker )
-        {
-            if( parent != null )
-            {
-                Entry e = ( Entry ) parent.filter2entry.get( AbstractIoHandlerFilterChain.this );
-                e.prevFilter.filterWrite( session, buf, marker );
-            }
-            nextFilter.filterWrite( session, buf, marker );
+            doWrite( session, buf, marker );
         }
     };
     
@@ -142,56 +60,38 @@
     {
         public void sessionOpened( NextFilter nextFilter, IoSession session )
         {
-            if( parent == null )
-            {
-                session.getHandler().sessionOpened( session );
-            }
+            session.getHandler().sessionOpened( session );
         }
 
         public void sessionClosed( NextFilter nextFilter, IoSession session )
         {
-            if( parent == null )
-            {
-                session.getHandler().sessionClosed( session );
-            }
+            session.getHandler().sessionClosed( session );
         }
 
         public void sessionIdle( NextFilter nextFilter, IoSession session,
                                 IdleStatus status )
         {
-            if( parent == null )
-            {
-                session.getHandler().sessionIdle( session, status );
-            }
+            session.getHandler().sessionIdle( session, status );
         }
 
         public void exceptionCaught( NextFilter nextFilter,
                                     IoSession session, Throwable cause )
         {
-            if( parent == null )
-            {
-                session.getHandler().exceptionCaught( session, cause );
-            }
+            session.getHandler().exceptionCaught( session, cause );
         }
 
         public void dataRead( NextFilter nextFilter, IoSession session,
                              ByteBuffer buf )
         {
-            if( parent == null )
-            {
-                IoHandler handler = session.getHandler();
-                handler.dataRead( session, buf );
-                buf.release();
-            }
+            IoHandler handler = session.getHandler();
+            handler.dataRead( session, buf );
+            buf.release();
         }
 
         public void dataWritten( NextFilter nextFilter, IoSession session,
                                 Object marker )
         {
-            if( parent == null )
-            {
-                session.getHandler().dataWritten( session, marker );
-            }
+            session.getHandler().dataWritten( session, marker );
         }
 
         public void filterWrite( NextFilter nextFilter,
@@ -201,10 +101,6 @@
         }
     };
     
-    private final boolean root;
-
-    private AbstractIoHandlerFilterChain parent;
-    
     private final Map name2entry = new HashMap();
 
     private final Map filter2entry = new IdentityHashMap();
@@ -213,33 +109,11 @@
     
     private final Entry tail;
 
-    protected AbstractIoHandlerFilterChain( boolean root )
+    protected AbstractIoHandlerFilterChain()
     {
-        this.root = root;
-
         head = new Entry( null, null, "head", HEAD_FILTER );
         tail = new Entry( head, null, "tail", TAIL_FILTER );
         head.nextEntry = tail;
-        
-        if( !root )
-        {
-            register( head, IoHandlerFilterChain.NEXT_FILTER, NEXT_FILTER );
-        }
-    }
-    
-    public IoHandlerFilterChain getRoot()
-    {
-        AbstractIoHandlerFilterChain current = this;
-        while( current.parent != null )
-        {
-            current = current.parent;
-        }
-        return current;
-    }
-    
-    public IoHandlerFilterChain getParent()
-    {
-        return parent;
     }
     
     public IoHandlerFilter getChild( String name )
@@ -258,7 +132,7 @@
     public synchronized void addFirst( String name,
                                        IoHandlerFilter filter )
     {
-        checkAddable( name, filter );
+        checkAddable( name );
         register( head, name, filter );
     }
 
@@ -269,7 +143,7 @@
     public synchronized void addLast( String name,
                                       IoHandlerFilter filter )
     {
-        checkAddable( name, filter );
+        checkAddable( name );
         register( tail.prevEntry, name, filter );
     }
 
@@ -283,7 +157,7 @@
                                         IoHandlerFilter filter )
     {
         Entry baseEntry = checkOldName( baseName );
-        checkAddable( name, filter );
+        checkAddable( name );
         register( baseEntry, name, filter );
     }
 
@@ -297,7 +171,7 @@
                                        IoHandlerFilter filter )
     {
         Entry baseEntry = checkOldName( baseName );
-        checkAddable( name, filter );
+        checkAddable( name );
         register( baseEntry.prevEntry, name, filter );
     }
 
@@ -316,10 +190,6 @@
         name2entry.remove( name );
         IoHandlerFilter filter = entry.filter;
         filter2entry.remove( filter );
-        if ( filter instanceof AbstractIoHandlerFilterChain )
-        {
-            ( ( AbstractIoHandlerFilterChain ) filter ).parent = null;
-        }
     }
 
 
@@ -337,24 +207,6 @@
 
     private void register( Entry prevEntry, String name, IoHandlerFilter filter )
     {
-        if ( filter instanceof AbstractIoHandlerFilterChain )
-        {
-            if( !this.getClass().isAssignableFrom( filter.getClass() ) )
-            {
-                throw new IllegalArgumentException( "Incompatible chain" );
-            }
-            if( ( ( AbstractIoHandlerFilterChain ) filter ).root )
-            {
-                throw new IllegalArgumentException( "Root chain cannot be added." );
-            }
-            if( ( ( AbstractIoHandlerFilterChain ) filter ).parent != null )
-            {
-                throw new IllegalArgumentException( "Already added to other parent chain." );
-            }
-
-            ( ( AbstractIoHandlerFilterChain ) filter ).parent = this;
-        }
-        
         Entry newEntry = new Entry( prevEntry, prevEntry.nextEntry, name, filter );
         prevEntry.nextEntry.prevEntry = newEntry;
         prevEntry.nextEntry = newEntry;
@@ -382,23 +234,15 @@
     /**
      * Checks the specified interceptor name is already taken and throws an exception if already taken.
      */
-    private void checkAddable( String name, IoHandlerFilter filter )
+    private void checkAddable( String name )
     {
         if ( name2entry.containsKey( name ) )
         {
             throw new IllegalArgumentException( "Other interceptor is using name '" + name + "'" );
         }
-
-        if ( filter instanceof AbstractIoHandlerFilterChain )
-        {
-            if ( ( ( AbstractIoHandlerFilterChain ) filter ).parent != null )
-            {
-                throw new IllegalArgumentException( "This interceptor chain has its parent already." );
-            }
-        }
     }
 
-    public void sessionOpened( NextFilter nextFilter, IoSession session )
+    public void sessionOpened( IoSession session )
     {
         Entry head = this.head;
         callNextSessionOpened(head, session);
@@ -413,11 +257,11 @@
         }
         catch( Throwable e )
         {
-            fireExceptionCaught( session, e );
+            exceptionCaught( session, e );
         }
     }
 
-    public void sessionClosed( NextFilter nextFilter, IoSession session )
+    public void sessionClosed( IoSession session )
     {
         Entry head = this.head;
         callNextSessionClosed(head, session);
@@ -432,11 +276,11 @@
         }
         catch( Throwable e )
         {
-            fireExceptionCaught( session, e );
+            exceptionCaught( session, e );
         }
     }
 
-    public void sessionIdle( NextFilter nextFilter, IoSession session, IdleStatus status )
+    public void sessionIdle( IoSession session, IdleStatus status )
     {
         Entry head = this.head;
         callNextSessionIdle(head, session, status);
@@ -452,11 +296,11 @@
         }
         catch( Throwable e )
         {
-            fireExceptionCaught( session, e );
+            exceptionCaught( session, e );
         }
     }
 
-    public void dataRead( NextFilter nextFilter, IoSession session, ByteBuffer buf )
+    public void dataRead( IoSession session, ByteBuffer buf )
     {
         Entry head = this.head;
         callNextDataRead(head, session, buf);
@@ -472,11 +316,11 @@
         }
         catch( Throwable e )
         {
-            fireExceptionCaught( session, e );
+            exceptionCaught( session, e );
         }
     }
 
-    public void dataWritten( NextFilter nextFilter, IoSession session, Object marker )
+    public void dataWritten( IoSession session, Object marker )
     {
         Entry head = this.head;
         callNextDataWritten(head, session, marker);
@@ -492,11 +336,11 @@
         }
         catch( Throwable e )
         {
-            fireExceptionCaught( session, e );
+            exceptionCaught( session, e );
         }
     }
 
-    public void exceptionCaught( NextFilter nextFilter, IoSession session, Throwable cause )
+    public void exceptionCaught( IoSession session, Throwable cause )
     {
         Entry head = this.head;
         callNextExceptionCaught(head, session, cause);
@@ -516,8 +360,7 @@
         }
     }
     
-    public void filterWrite( NextFilter nextFilter,
-                             IoSession session, ByteBuffer buf, Object marker )
+    public void filterWrite( IoSession session, ByteBuffer buf, Object marker )
     {
         Entry tail = this.tail;
         callPreviousFilterWrite( tail, session, buf, marker );
@@ -538,7 +381,7 @@
         }
         catch( Throwable e )
         {
-            fireExceptionCaught( session, e );
+            exceptionCaught( session, e );
         }
     }
 
@@ -565,18 +408,6 @@
             e = e.prevEntry;
         }
         return list;
-    }
-    
-    private void fireExceptionCaught( IoSession session, Throwable cause )
-    {
-        try
-        {
-            getRoot().exceptionCaught( null, session, cause );
-        }
-        catch( Throwable t )
-        {
-            t.printStackTrace();
-        }
     }
     
     protected abstract void doWrite( IoSession session, ByteBuffer buffer, Object marker );

Modified: directory/network/trunk/src/java/org/apache/mina/io/IoAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/IoAcceptor.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/IoAcceptor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/IoAcceptor.java Fri Mar 25 05:43:18 2005
@@ -62,8 +62,6 @@
      */
     void unbind( SocketAddress address );
 
-    IoHandlerFilterChain newFilterChain();
-    
     IoHandlerFilterChain getFilterChain();
     
     /**

Modified: directory/network/trunk/src/java/org/apache/mina/io/IoConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/IoConnector.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/IoConnector.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/IoConnector.java Fri Mar 25 05:43:18 2005
@@ -69,8 +69,6 @@
     IoSession connect( SocketAddress address, int timeout, IoHandler handler )
             throws IOException;
 
-    IoHandlerFilterChain newFilterChain();
-    
     IoHandlerFilterChain getFilterChain();
 
     /**

Modified: directory/network/trunk/src/java/org/apache/mina/io/IoHandlerFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/IoHandlerFilterChain.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/IoHandlerFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/IoHandlerFilterChain.java Fri Mar 25 05:43:18 2005
@@ -3,12 +3,7 @@
 import java.util.List;
 
 
-public interface IoHandlerFilterChain extends IoHandlerFilter {
-    static String NEXT_FILTER = "nextFilter";
-    
-    IoHandlerFilterChain getRoot();
-    IoHandlerFilterChain getParent();
-
+public interface IoHandlerFilterChain {
     IoHandlerFilter getChild( String name );
     List getChildren();
     List getChildrenReversed();

Modified: directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java Fri Mar 25 05:43:18 2005
@@ -47,7 +47,7 @@
 {
     private static volatile int nextId = 0;
 
-    private final DatagramFilterChain filters = new DatagramFilterChain( true, this );
+    private final DatagramFilterChain filters = new DatagramFilterChain( this );
 
     private final int id = nextId ++ ;
 
@@ -300,12 +300,12 @@
                 newBuf.flip();
 
                 session.increaseReadBytes( newBuf.remaining() );
-                filters.dataRead( null, session, newBuf );
+                filters.dataRead( session, newBuf );
             }
         }
         catch( IOException e )
         {
-            filters.exceptionCaught( null, session, e );
+            filters.exceptionCaught( session, e );
         }
         finally
         {
@@ -336,7 +336,7 @@
             }
             catch( IOException e )
             {
-                session.getFilters().exceptionCaught( null, session, e );
+                session.getFilters().exceptionCaught( session, e );
             }
         }
     }
@@ -376,11 +376,10 @@
                 }
                 catch( IllegalStateException e )
                 {
-                    session.getFilters().exceptionCaught( null, session,
-                            e );
+                    session.getFilters().exceptionCaught( session, e );
                 }
 
-                session.getFilters().dataWritten( null, session, marker );
+                session.getFilters().dataWritten( session, marker );
                 continue;
             }
 
@@ -406,7 +405,7 @@
                 }
 
                 session.increaseWrittenBytes( writtenBytes );
-                session.getFilters().dataWritten( null, session, marker );
+                session.getFilters().dataWritten( session, marker );
             }
         }
     }
@@ -511,11 +510,6 @@
                 }
             }
         }
-    }
-    
-    public IoHandlerFilterChain newFilterChain()
-    {
-        return new DatagramFilterChain( false, this );
     }
     
     public IoHandlerFilterChain getFilterChain()

Modified: directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramConnector.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramConnector.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramConnector.java Fri Mar 25 05:43:18 2005
@@ -48,7 +48,7 @@
 {
     private static volatile int nextId = 0;
 
-    private final DatagramFilterChain filters = new DatagramFilterChain( true, this );
+    private final DatagramFilterChain filters = new DatagramFilterChain( this );
 
     private final int id = nextId ++ ;
 
@@ -255,12 +255,12 @@
                 newBuf.put( readBuf );
                 newBuf.flip();
 
-                filters.dataRead( null, session, newBuf );
+                filters.dataRead( session, newBuf );
             }
         }
         catch( IOException e )
         {
-            filters.exceptionCaught( null, session, e );
+            filters.exceptionCaught( session, e );
         }
         finally
         {
@@ -291,7 +291,7 @@
             }
             catch( IOException e )
             {
-                session.getFilters().exceptionCaught( null, session, e );
+                session.getFilters().exceptionCaught( session, e );
             }
         }
     }
@@ -331,11 +331,10 @@
                 }
                 catch( IllegalStateException e )
                 {
-                    session.getFilters().exceptionCaught( null, session,
-                            e );
+                    session.getFilters().exceptionCaught( session, e );
                 }
 
-                session.getFilters().dataWritten( null, session, marker );
+                session.getFilters().dataWritten( session, marker );
                 continue;
             }
 
@@ -358,7 +357,7 @@
                     writeBufferQueue.pop();
                     writeMarkerQueue.pop();
                 }
-                session.getFilters().dataWritten( null, session, marker );
+                session.getFilters().dataWritten( session, marker );
             }
         }
     }
@@ -426,11 +425,6 @@
         }
     }
 
-    public IoHandlerFilterChain newFilterChain()
-    {
-        return new DatagramFilterChain( false, this );
-    }
-    
     public IoHandlerFilterChain getFilterChain()
     {
         return filters;

Modified: directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramFilterChain.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramFilterChain.java Fri Mar 25 05:43:18 2005
@@ -9,9 +9,8 @@
 
     private final DatagramProcessor processor;
 
-    DatagramFilterChain( boolean root, DatagramProcessor processor )
+    DatagramFilterChain( DatagramProcessor processor )
     {
-        super( root );
         this.processor = processor;
     }
 

Modified: directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramSession.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramSession.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramSession.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramSession.java Fri Mar 25 05:43:18 2005
@@ -139,7 +139,7 @@
 
     public void write( ByteBuffer buf, Object marker )
     {
-        filters.filterWrite( null, this, buf, marker );
+        filters.filterWrite( this, buf, marker );
     }
 
     public TransportType getTransportType()

Modified: directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java Fri Mar 25 05:43:18 2005
@@ -49,7 +49,7 @@
 {
     private static volatile int nextId = 0;
 
-    private final SocketFilterChain filters = new SocketFilterChain( true );
+    private final SocketFilterChain filters = new SocketFilterChain();
 
     private final int id = nextId ++ ;
 
@@ -422,18 +422,10 @@
         }
     }
 
-
-    public IoHandlerFilterChain newFilterChain()
-    {
-        return new SocketFilterChain( false );
-    }
-
-
     public IoHandlerFilterChain getFilterChain()
     {
         return filters;
     }
-
 
     private static class RegistrationRequest
     {

Modified: directory/network/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java Fri Mar 25 05:43:18 2005
@@ -48,7 +48,7 @@
 
     private final int id = nextId++;
 
-    private final SocketFilterChain filters = new SocketFilterChain( true );
+    private final SocketFilterChain filters = new SocketFilterChain();
 
     private final Selector selector;
 
@@ -328,11 +328,6 @@
         }
     }
 
-    public IoHandlerFilterChain newFilterChain()
-    {
-        return new SocketFilterChain( false );
-    }
-    
     public IoHandlerFilterChain getFilterChain()
     {
         return filters;

Modified: directory/network/trunk/src/java/org/apache/mina/io/socket/SocketFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/socket/SocketFilterChain.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/socket/SocketFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/socket/SocketFilterChain.java Fri Mar 25 05:43:18 2005
@@ -7,9 +7,8 @@
 
 class SocketFilterChain extends AbstractIoHandlerFilterChain {
 
-    SocketFilterChain( boolean root )
+    SocketFilterChain()
     {
-        super( root );
     }
 
     protected void doWrite( IoSession session, ByteBuffer buf, Object marker )

Modified: directory/network/trunk/src/java/org/apache/mina/io/socket/SocketIoProcessor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/socket/SocketIoProcessor.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/socket/SocketIoProcessor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/socket/SocketIoProcessor.java Fri Mar 25 05:43:18 2005
@@ -161,12 +161,12 @@
             catch( IOException e )
             {
                 registered = false;
-                session.getFilters().exceptionCaught( null, session, e );
+                session.getFilters().exceptionCaught( session, e );
             }
 
             if( registered )
             {
-                session.getFilters().sessionOpened( null, session );
+                session.getFilters().sessionOpened( session );
             }
         }
     }
@@ -198,11 +198,11 @@
             }
             catch( IOException e )
             {
-                session.getFilters().exceptionCaught( null, session, e );
+                session.getFilters().exceptionCaught( session, e );
             }
             finally
             {
-                session.getFilters().sessionClosed( null, session );
+                session.getFilters().sessionClosed( session );
             }
         }
     }
@@ -267,7 +267,7 @@
                     ByteBuffer newBuf = ByteBuffer.allocate( readBytes );
                     newBuf.put( buf );
                     newBuf.flip();
-                    session.getFilters().dataRead( null, session, newBuf );
+                    session.getFilters().dataRead( session, newBuf );
                 }
             }
             else
@@ -279,7 +279,7 @@
         {
             if( e instanceof IOException )
                 scheduleRemove( session );
-            session.getFilters().exceptionCaught( null, session, e );
+            session.getFilters().exceptionCaught( session, e );
         }
         finally
         {
@@ -353,7 +353,7 @@
             && ( currentTime - lastIoTime ) >= idleTime )
         {
             session.setIdle( status, true );
-            session.getFilters().sessionIdle( null, session, status );
+            session.getFilters().sessionIdle( session, status );
         }
     }
 
@@ -367,7 +367,7 @@
         {
             session
                     .getFilters()
-                    .exceptionCaught( null, session, new WriteTimeoutException() );
+                    .exceptionCaught( session, new WriteTimeoutException() );
         }
     }
 
@@ -398,7 +398,7 @@
             catch( IOException e )
             {
                 scheduleRemove( session );
-                session.getFilters().exceptionCaught( null, session, e );
+                session.getFilters().exceptionCaught( session, e );
             }
         }
     }
@@ -436,11 +436,10 @@
                 }
                 catch( IllegalStateException e )
                 {
-                    session.getFilters().exceptionCaught( null, session,
-                            e );
+                    session.getFilters().exceptionCaught( session, e );
                 }
 
-                session.getFilters().dataWritten( null, session, marker );
+                session.getFilters().dataWritten( session, marker );
                 continue;
             }
 

Modified: directory/network/trunk/src/java/org/apache/mina/io/socket/SocketSession.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/socket/SocketSession.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/socket/SocketSession.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/socket/SocketSession.java Fri Mar 25 05:43:18 2005
@@ -27,7 +27,6 @@
 import org.apache.mina.common.SessionConfig;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.io.IoHandler;
-import org.apache.mina.io.IoHandlerFilterChain;
 import org.apache.mina.io.IoSession;
 import org.apache.mina.util.Queue;
 
@@ -41,7 +40,7 @@
 {
     private static final int DEFAULT_READ_BUFFER_SIZE = 1024;
 
-    private final IoHandlerFilterChain filters;
+    private final SocketFilterChain filters;
 
     private final SocketChannel ch;
 
@@ -82,7 +81,7 @@
     /**
      * Creates a new instance.
      */
-    SocketSession( IoHandlerFilterChain filters, SocketChannel ch,
+    SocketSession( SocketFilterChain filters, SocketChannel ch,
                    IoHandler defaultHandler )
     {
         this.filters = filters;
@@ -96,7 +95,7 @@
         this.localAddress = ch.socket().getLocalSocketAddress();
     }
 
-    IoHandlerFilterChain getFilters()
+    SocketFilterChain getFilters()
     {
         return filters;
     }
@@ -169,7 +168,7 @@
 
     public void write( ByteBuffer buf, Object marker )
     {
-        filters.filterWrite( null, this, buf, marker );
+        filters.filterWrite( this, buf, marker );
     }
 
     public TransportType getTransportType()

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/AbstractProtocolHandlerFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/AbstractProtocolHandlerFilterChain.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/AbstractProtocolHandlerFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/AbstractProtocolHandlerFilterChain.java Fri Mar 25 05:43:18 2005
@@ -8,6 +8,7 @@
 import java.util.Map;
 
 import org.apache.mina.common.IdleStatus;
+import org.apache.mina.protocol.ProtocolHandlerFilter.NextFilter;
 
 public abstract class AbstractProtocolHandlerFilterChain implements ProtocolHandlerFilterChain
 {
@@ -50,89 +51,7 @@
         public void filterWrite( NextFilter nextFilter, ProtocolSession session,
                                  Object message )
         {
-            if( parent == null )
-            {
-                // write only when root filter chain traversal is finished.
-                doWrite( session, message );
-            }
-        }
-    };
-    
-    private final ProtocolHandlerFilter NEXT_FILTER = new ProtocolHandlerFilter()
-    {
-        public void sessionOpened( NextFilter nextFilter, ProtocolSession session )
-        {
-            if( parent != null )
-            {
-                Entry e = ( Entry ) parent.filter2entry.get( AbstractProtocolHandlerFilterChain.this );
-                e.nextFilter.sessionOpened( session );
-            }
-            nextFilter.sessionOpened( session );
-        }
-
-        public void sessionClosed( NextFilter nextFilter, ProtocolSession session )
-        {
-            if( parent != null )
-            {
-                Entry e = ( Entry ) parent.filter2entry.get( AbstractProtocolHandlerFilterChain.this );
-                e.nextFilter.sessionClosed( session );
-            }
-            nextFilter.sessionClosed( session );
-        }
-
-        public void sessionIdle( NextFilter nextFilter, ProtocolSession session,
-                                IdleStatus status )
-        {
-            if( parent != null )
-            {
-                Entry e = ( Entry ) parent.filter2entry.get( AbstractProtocolHandlerFilterChain.this );
-                e.nextFilter.sessionIdle( session, status );
-            }
-            nextFilter.sessionIdle( session, status );
-        }
-
-        public void exceptionCaught( NextFilter nextFilter,
-                                    ProtocolSession session, Throwable cause )
-        {
-            if( parent != null )
-            {
-                Entry e = ( Entry ) parent.filter2entry.get( AbstractProtocolHandlerFilterChain.this );
-                e.nextFilter.exceptionCaught( session, cause );
-            }
-            nextFilter.exceptionCaught( session, cause );
-        }
-
-        public void messageReceived( NextFilter nextFilter, ProtocolSession session,
-                                     Object message )
-        {
-            if( parent != null )
-            {
-                Entry e = ( Entry ) parent.filter2entry.get( AbstractProtocolHandlerFilterChain.this );
-                e.nextFilter.messageReceived( session, message );
-            }
-            nextFilter.messageReceived( session, message );
-        }
-
-        public void messageSent( NextFilter nextFilter, ProtocolSession session,
-                                 Object message )
-        {
-            if( parent != null )
-            {
-                Entry e = ( Entry ) parent.filter2entry.get( AbstractProtocolHandlerFilterChain.this );
-                e.nextFilter.messageSent( session, message );
-            }
-            nextFilter.messageSent( session, message );
-        }
-        
-        public void filterWrite( NextFilter nextFilter, ProtocolSession session,
-                                 Object message )
-        {
-            if( parent != null )
-            {
-                Entry e = ( Entry ) parent.filter2entry.get( AbstractProtocolHandlerFilterChain.this );
-                e.prevFilter.filterWrite( session, message );
-            }
-            nextFilter.filterWrite( session, message );
+            doWrite( session, message );
         }
     };
     
@@ -140,55 +59,37 @@
     {
         public void sessionOpened( NextFilter nextFilter, ProtocolSession session )
         {
-            if( parent == null )
-            {
-                session.getHandler().sessionOpened( session );
-            }
+            session.getHandler().sessionOpened( session );
         }
 
         public void sessionClosed( NextFilter nextFilter, ProtocolSession session )
         {
-            if( parent == null )
-            {
-                session.getHandler().sessionClosed( session );
-            }
+            session.getHandler().sessionClosed( session );
         }
 
         public void sessionIdle( NextFilter nextFilter, ProtocolSession session,
                                 IdleStatus status )
         {
-            if( parent == null )
-            {
-                session.getHandler().sessionIdle( session, status );
-            }
+            session.getHandler().sessionIdle( session, status );
         }
 
         public void exceptionCaught( NextFilter nextFilter,
                                     ProtocolSession session, Throwable cause )
         {
-            if( parent == null )
-            {
-                session.getHandler().exceptionCaught( session, cause );
-            }
+            session.getHandler().exceptionCaught( session, cause );
         }
 
         public void messageReceived( NextFilter nextFilter, ProtocolSession session,
                                      Object message )
         {
-            if( parent == null )
-            {
-                ProtocolHandler handler = session.getHandler();
-                handler.messageReceived( session, message );
-            }
+            ProtocolHandler handler = session.getHandler();
+            handler.messageReceived( session, message );
         }
 
         public void messageSent( NextFilter nextFilter, ProtocolSession session,
                                  Object message )
         {
-            if( parent == null )
-            {
-                session.getHandler().messageSent( session, message );
-            }
+            session.getHandler().messageSent( session, message );
         }
 
         public void filterWrite( NextFilter nextFilter,
@@ -198,10 +99,6 @@
         }
     };
 
-    private final boolean root;
-    
-    private AbstractProtocolHandlerFilterChain parent;
-    
     private final Map name2entry = new HashMap();
 
     private final Map filter2entry = new IdentityHashMap();
@@ -210,33 +107,11 @@
 
     private final Entry tail;
 
-    protected AbstractProtocolHandlerFilterChain( boolean root )
+    protected AbstractProtocolHandlerFilterChain()
     {
-        this.root = root;
-        
         head = new Entry( null, null, "head", HEAD_FILTER );
         tail = new Entry( head, null, "tail", TAIL_FILTER );
         head.nextEntry = tail;
-        
-        if( !root )
-        {
-            register( head, ProtocolHandlerFilterChain.NEXT_FILTER, NEXT_FILTER );
-        }
-    }
-    
-    public ProtocolHandlerFilterChain getRoot()
-    {
-        AbstractProtocolHandlerFilterChain current = this;
-        while( current.parent != null )
-        {
-            current = current.parent;
-        }
-        return current;
-    }
-    
-    public ProtocolHandlerFilterChain getParent()
-    {
-        return parent;
     }
     
     public ProtocolHandlerFilter getChild( String name )
@@ -255,7 +130,7 @@
     public synchronized void addFirst( String name,
                                        ProtocolHandlerFilter filter )
     {
-        checkAddable( name, filter );
+        checkAddable( name );
         register( head, name, filter );
     }
 
@@ -266,7 +141,7 @@
     public synchronized void addLast( String name,
                                       ProtocolHandlerFilter filter )
     {
-        checkAddable( name, filter );
+        checkAddable( name );
         register( tail.prevEntry, name, filter );
     }
 
@@ -280,7 +155,7 @@
                                         ProtocolHandlerFilter filter )
     {
         Entry baseEntry = checkOldName( baseName );
-        checkAddable( name, filter );
+        checkAddable( name );
         register( baseEntry, name, filter );
     }
 
@@ -294,7 +169,7 @@
                                        ProtocolHandlerFilter filter )
     {
         Entry baseEntry = checkOldName( baseName );
-        checkAddable( name, filter );
+        checkAddable( name );
         register( baseEntry.prevEntry, name, filter );
     }
 
@@ -313,10 +188,6 @@
         name2entry.remove( name );
         ProtocolHandlerFilter filter = entry.filter;
         filter2entry.remove( filter );
-        if ( filter instanceof AbstractProtocolHandlerFilterChain )
-        {
-            ( ( AbstractProtocolHandlerFilterChain ) filter ).parent = null;
-        }
     }
 
 
@@ -334,23 +205,6 @@
 
     private void register( Entry prevEntry, String name, ProtocolHandlerFilter filter )
     {
-        if ( filter instanceof AbstractProtocolHandlerFilterChain )
-        {
-            if( !this.getClass().isAssignableFrom( filter.getClass() ) )
-            {
-                throw new IllegalArgumentException( "Incompatible chain" );
-            }
-            if( ( ( AbstractProtocolHandlerFilterChain ) filter ).root )
-            {
-                throw new IllegalArgumentException( "Root chain cannot be added." );
-            }
-            if( ( ( AbstractProtocolHandlerFilterChain ) filter ).parent != null )
-            {
-                throw new IllegalArgumentException( "Already added to other parent chain." );
-            }
-
-            ( ( AbstractProtocolHandlerFilterChain ) filter ).parent = this;
-        }
         Entry newEntry = new Entry( prevEntry, prevEntry.nextEntry, name, filter );
         prevEntry.nextEntry.prevEntry = newEntry;
         prevEntry.nextEntry = newEntry;
@@ -378,23 +232,15 @@
     /**
      * Checks the specified interceptor name is already taken and throws an exception if already taken.
      */
-    private void checkAddable( String name, ProtocolHandlerFilter filter )
+    private void checkAddable( String name )
     {
         if ( name2entry.containsKey( name ) )
         {
             throw new IllegalArgumentException( "Other interceptor is using name '" + name + "'" );
         }
-
-        if ( filter instanceof AbstractProtocolHandlerFilterChain )
-        {
-            if ( ( ( AbstractProtocolHandlerFilterChain ) filter ).parent != null )
-            {
-                throw new IllegalArgumentException( "This interceptor chain has its parent already." );
-            }
-        }
     }
 
-    public void sessionOpened( NextFilter nextFilter, ProtocolSession session )
+    public void sessionOpened( ProtocolSession session )
     {
         Entry head = this.head;
         callNextSessionOpened(head, session);
@@ -409,11 +255,11 @@
         }
         catch( Throwable e )
         {
-            fireExceptionCaught( session, e );
+            exceptionCaught( session, e );
         }
     }
 
-    public void sessionClosed( NextFilter nextFilter, ProtocolSession session )
+    public void sessionClosed( ProtocolSession session )
     {
         Entry head = this.head;
         callNextSessionClosed(head, session);
@@ -429,11 +275,11 @@
         }
         catch( Throwable e )
         {
-            fireExceptionCaught( session, e );
+            exceptionCaught( session, e );
         }
     }
 
-    public void sessionIdle( NextFilter nextFilter, ProtocolSession session, IdleStatus status )
+    public void sessionIdle( ProtocolSession session, IdleStatus status )
     {
         Entry head = this.head;
         callNextSessionIdle(head, session, status);
@@ -449,11 +295,11 @@
         }
         catch( Throwable e )
         {
-            fireExceptionCaught( session, e );
+            exceptionCaught( session, e );
         }
     }
 
-    public void messageReceived( NextFilter nextFilter, ProtocolSession session, Object message )
+    public void messageReceived( ProtocolSession session, Object message )
     {
         Entry head = this.head;
         callNextMessageReceived(head, session, message );
@@ -469,11 +315,11 @@
         }
         catch( Throwable e )
         {
-            fireExceptionCaught( session, e );
+            exceptionCaught( session, e );
         }
     }
 
-    public void messageSent( NextFilter nextFilter, ProtocolSession session, Object message )
+    public void messageSent( ProtocolSession session, Object message )
     {
         Entry head = this.head;
         callNextMessageSent(head, session, message);
@@ -489,11 +335,11 @@
         }
         catch( Throwable e )
         {
-            fireExceptionCaught( session, e );
+            exceptionCaught( session, e );
         }
     }
 
-    public void exceptionCaught( NextFilter nextFilter, ProtocolSession session, Throwable cause )
+    public void exceptionCaught( ProtocolSession session, Throwable cause )
     {
         Entry head = this.head;
         callNextExceptionCaught(head, session, cause);
@@ -513,8 +359,7 @@
         }
     }
     
-    public void filterWrite( NextFilter nextFilter,
-                             ProtocolSession session, Object message )
+    public void filterWrite( ProtocolSession session, Object message )
     {
         Entry tail = this.tail;
         callPreviousFilterWrite( tail, session, message );
@@ -535,7 +380,7 @@
         }
         catch( Throwable e )
         {
-            fireExceptionCaught( session, e );
+            exceptionCaught( session, e );
         }
     }
 
@@ -562,18 +407,6 @@
             e = e.prevEntry;
         }
         return list;
-    }
-    
-    private void fireExceptionCaught( ProtocolSession session, Throwable cause )
-    {
-        try
-        {
-            getRoot().exceptionCaught( null, session, cause );
-        }
-        catch( Throwable t )
-        {
-            t.printStackTrace();
-        }
     }
     
     protected abstract void doWrite( ProtocolSession session, Object message );

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolAcceptor.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolAcceptor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolAcceptor.java Fri Mar 25 05:43:18 2005
@@ -59,7 +59,5 @@
      */
     void unbind( SocketAddress address );
 
-    ProtocolHandlerFilterChain newFilterChain();
-    
     ProtocolHandlerFilterChain getFilterChain();
 }

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolConnector.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolConnector.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolConnector.java Fri Mar 25 05:43:18 2005
@@ -67,7 +67,5 @@
                             ProtocolProvider protocolProvider )
             throws IOException;
 
-    ProtocolHandlerFilterChain newFilterChain();
-    
     ProtocolHandlerFilterChain getFilterChain();
 }

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolHandlerFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolHandlerFilterChain.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolHandlerFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolHandlerFilterChain.java Fri Mar 25 05:43:18 2005
@@ -3,12 +3,7 @@
 import java.util.List;
 
 
-public interface ProtocolHandlerFilterChain extends ProtocolHandlerFilter {
-    static String NEXT_FILTER = "nextFilter";
-    
-    ProtocolHandlerFilterChain getRoot();
-    ProtocolHandlerFilterChain getParent();
-
+public interface ProtocolHandlerFilterChain {
     ProtocolHandlerFilter getChild( String name );
     List getChildren();
     List getChildrenReversed();

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/io/IoAdapter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/io/IoAdapter.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/io/IoAdapter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/io/IoAdapter.java Fri Mar 25 05:43:18 2005
@@ -52,17 +52,12 @@
  */
 public class IoAdapter
 {
-    private final IoProtocolFilterChain filters = new IoProtocolFilterChain( true );
+    private final IoProtocolFilterChain filters = new IoProtocolFilterChain();
 
     IoAdapter()
     {
     }
     
-    public ProtocolHandlerFilterChain newFilterChain()
-    {
-        return new IoProtocolFilterChain( false );
-    }
-    
     public ProtocolHandlerFilterChain getFilterChain()
     {
         return filters;
@@ -109,24 +104,22 @@
 
         public void sessionOpened( IoSession session )
         {
-            filters.sessionOpened( null, getProtocolSession( session ) );
+            filters.sessionOpened( getProtocolSession( session ) );
         }
 
         public void sessionClosed( IoSession session )
         {
-            filters.sessionClosed( null, getProtocolSession( session ) );
+            filters.sessionClosed( getProtocolSession( session ) );
         }
 
         public void sessionIdle( IoSession session, IdleStatus status )
         {
-            filters.sessionIdle( null, getProtocolSession( session ),
-                    status );
+            filters.sessionIdle( getProtocolSession( session ), status );
         }
 
         public void exceptionCaught( IoSession session, Throwable cause )
         {
-            filters.exceptionCaught( null, getProtocolSession( session ),
-                    cause );
+            filters.exceptionCaught( getProtocolSession( session ), cause );
         }
 
         public void dataRead( IoSession session, ByteBuffer in )
@@ -147,8 +140,7 @@
                     {
                         do
                         {
-                            filters.messageReceived( null, psession,
-                                    queue.pop() );
+                            filters.messageReceived( psession, queue.pop() );
                         }
                         while( !queue.isEmpty() );
                     }
@@ -157,11 +149,11 @@
             catch( ProtocolViolationException pve )
             {
                 pve.setBuffer( in );
-                filters.exceptionCaught( null, psession, pve );
+                filters.exceptionCaught( psession, pve );
             }
             catch( Throwable t )
             {
-                filters.exceptionCaught( null, psession, t );
+                filters.exceptionCaught( psession, t );
             }
         }
 
@@ -169,8 +161,8 @@
         {
             if( marker == null )
                 return;
-            filters.messageSent( null, ( ProtocolSession ) session
-                    .getAttachment(), marker );
+            filters.messageSent( 
+                    ( ProtocolSession ) session.getAttachment(), marker );
         }
 
         void doWrite( IoSession session )
@@ -211,7 +203,7 @@
             }
             catch( Throwable t )
             {
-                filters.exceptionCaught( null, psession, t );
+                filters.exceptionCaught( psession, t );
             }
         }
 
@@ -298,7 +290,7 @@
 
         public void write( Object message )
         {
-            filters.filterWrite( null, this, message );
+            filters.filterWrite( this, message );
         }
 
         public TransportType getTransportType()

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolAcceptor.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolAcceptor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolAcceptor.java Fri Mar 25 05:43:18 2005
@@ -55,11 +55,6 @@
         acceptor.unbind( address );
     }
     
-    public ProtocolHandlerFilterChain newFilterChain()
-    {
-        return adapter.newFilterChain();
-    }
-
     public ProtocolHandlerFilterChain getFilterChain()
     {
         return adapter.getFilterChain();

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolConnector.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolConnector.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolConnector.java Fri Mar 25 05:43:18 2005
@@ -63,11 +63,6 @@
         return adapter.toProtocolSession( session );
     }
 
-    public ProtocolHandlerFilterChain newFilterChain()
-    {
-        return adapter.newFilterChain();
-    }
-
     public ProtocolHandlerFilterChain getFilterChain()
     {
         return adapter.getFilterChain();

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolFilterChain.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolFilterChain.java Fri Mar 25 05:43:18 2005
@@ -7,11 +7,12 @@
 
 class IoProtocolFilterChain extends AbstractProtocolHandlerFilterChain {
 
-    IoProtocolFilterChain( boolean root ) {
-        super( root );
+    IoProtocolFilterChain()
+    {
     }
 
-    protected void doWrite(ProtocolSession session, Object message) {
+    protected void doWrite( ProtocolSession session, Object message )
+    {
         ProtocolSessionImpl s = ( ProtocolSessionImpl ) session;
         Queue writeQueue = s.writeQueue;
         synchronized( writeQueue )

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java Fri Mar 25 05:43:18 2005
@@ -24,7 +24,7 @@
 {
     static final Map boundHandlers = new HashMap();
 
-    private final VmPipeFilterChain filters = new VmPipeFilterChain( true );
+    private final VmPipeFilterChain filters = new VmPipeFilterChain();
 
     /**
      * Creates a new instance.
@@ -68,11 +68,6 @@
         }
     }
     
-    public ProtocolHandlerFilterChain newFilterChain()
-    {
-        return new VmPipeFilterChain( false );
-    }
-    
     public ProtocolHandlerFilterChain getFilterChain()
     {
         return filters;
@@ -82,13 +77,13 @@
     {
         final VmPipeAddress address;
 
-        final ProtocolHandlerFilterChain filters;
+        final VmPipeFilterChain filters;
 
         final ProtocolHandler handler;
 
         private Entry( VmPipeAddress address,
-                      ProtocolHandlerFilterChain filters,
-                      ProtocolHandler handler )
+                       VmPipeFilterChain filters,
+                       ProtocolHandler handler )
         {
             this.address = address;
             this.filters = filters;

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java Fri Mar 25 05:43:18 2005
@@ -21,7 +21,7 @@
  */
 public class VmPipeConnector implements ProtocolConnector
 {
-    private final VmPipeFilterChain filters = new VmPipeFilterChain( true );
+    private final VmPipeFilterChain filters = new VmPipeFilterChain();
 
     /**
      * Creates a new instance.
@@ -29,11 +29,6 @@
     public VmPipeConnector()
     {
         filters.addLast( "VMPipe", new VmPipeFilter() );
-    }
-    
-    public ProtocolHandlerFilterChain newFilterChain()
-    {
-        return new VmPipeFilterChain( false );
     }
     
     public ProtocolHandlerFilterChain getFilterChain()

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeFilter.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeFilter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeFilter.java Fri Mar 25 05:43:18 2005
@@ -16,7 +16,7 @@
 class VmPipeFilter extends ProtocolHandlerFilterAdapter
 {
     public void messageReceived( ProtocolHandler nextHandler,
-                                ProtocolSession session, Object message )
+                                 ProtocolSession session, Object message )
     {
         VmPipeSession vps = ( VmPipeSession ) session;
 
@@ -24,7 +24,7 @@
         vps.lastReadTime = System.currentTimeMillis();
 
         // fire messageSent event first
-        vps.remoteFilters.messageSent( null, vps.remoteSession, message );
+        vps.remoteFilters.messageSent( vps.remoteSession, message );
 
         // and then messageReceived
         nextHandler.messageReceived( session, message );

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeFilterChain.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeFilterChain.java Fri Mar 25 05:43:18 2005
@@ -5,9 +5,8 @@
 
 class VmPipeFilterChain extends AbstractProtocolHandlerFilterChain {
 
-    VmPipeFilterChain( boolean root )
+    VmPipeFilterChain()
     {
-        super( root );
     }
 
     protected void doWrite(ProtocolSession session, Object message)
@@ -18,8 +17,7 @@
         {
             if( s.closed )
                 throw new IllegalStateException( "Session is closed." );
-            s.remoteFilters.messageReceived( null,
-                                             s.remoteSession, message );
+            s.remoteFilters.messageReceived( s.remoteSession, message );
         }
     }
 }

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeIdleStatusChecker.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeIdleStatusChecker.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeIdleStatusChecker.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeIdleStatusChecker.java Fri Mar 25 05:43:18 2005
@@ -82,8 +82,7 @@
                                                    && ( currentTime - session.lastReadTime ) > idleTime;
                                 if( session.bothIdle )
                                     session.localFilters
-                                            .sessionIdle( null,
-                                                          session,
+                                            .sessionIdle( session,
                                                           IdleStatus.BOTH_IDLE );
                             }
 
@@ -95,8 +94,7 @@
                                                      && ( currentTime - session.lastReadTime ) > idleTime;
                                 if( session.readerIdle )
                                     session.localFilters
-                                            .sessionIdle( null,
-                                                          session,
+                                            .sessionIdle( session,
                                                           IdleStatus.READER_IDLE );
                             }
 
@@ -108,8 +106,7 @@
                                                      && ( currentTime - session.lastReadTime ) > idleTime;
                                 if( session.writerIdle )
                                     session.localFilters
-                                            .sessionIdle( null,
-                                                          session,
+                                            .sessionIdle( session,
                                                           IdleStatus.WRITER_IDLE );
                             }
                         }

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeSession.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeSession.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeSession.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeSession.java Fri Mar 25 05:43:18 2005
@@ -11,7 +11,6 @@
 import org.apache.mina.protocol.ProtocolDecoder;
 import org.apache.mina.protocol.ProtocolEncoder;
 import org.apache.mina.protocol.ProtocolHandler;
-import org.apache.mina.protocol.ProtocolHandlerFilterChain;
 import org.apache.mina.protocol.ProtocolSession;
 
 /**
@@ -30,9 +29,9 @@
 
     private final VmPipeSessionConfig config = new VmPipeSessionConfig();
 
-    final ProtocolHandlerFilterChain localFilters;
+    final VmPipeFilterChain localFilters;
 
-    final ProtocolHandlerFilterChain remoteFilters;
+    final VmPipeFilterChain remoteFilters;
 
     final VmPipeSession remoteSession;
 
@@ -57,9 +56,9 @@
      */
     VmPipeSession( Object lock, SocketAddress localAddress,
                   SocketAddress remoteAddress,
-                  ProtocolHandlerFilterChain localFilters,
+                  VmPipeFilterChain localFilters,
                   ProtocolHandler localHandler,
-                  ProtocolHandlerFilterChain removeFilters,
+                  VmPipeFilterChain removeFilters,
                   ProtocolHandler remoteHandler )
     {
         this.lock = lock;
@@ -71,8 +70,8 @@
 
         remoteSession = new VmPipeSession( this, remoteHandler );
 
-        removeFilters.sessionOpened( null, remoteSession );
-        localFilters.sessionOpened( null, this );
+        removeFilters.sessionOpened( remoteSession );
+        localFilters.sessionOpened( this );
     }
 
     /**
@@ -113,8 +112,8 @@
                 return;
 
             closed = remoteSession.closed = true;
-            localFilters.sessionClosed( null, this );
-            remoteFilters.sessionClosed( null, remoteSession );
+            localFilters.sessionClosed( this );
+            remoteFilters.sessionClosed( remoteSession );
         }
     }
 
@@ -130,7 +129,7 @@
 
     public void write( Object message )
     {
-        localFilters.filterWrite( null, this, message );
+        localFilters.filterWrite( this, message );
     }
 
     public TransportType getTransportType()

Modified: directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java Fri Mar 25 05:43:18 2005
@@ -55,11 +55,7 @@
      */
     void unbind( Service service );
 
-    IoHandlerFilterChain newIoFilterChain( TransportType transportType );
-    
     IoHandlerFilterChain getIoFilterChain( TransportType transportType );
-    
-    ProtocolHandlerFilterChain newProtocolFilterChain( TransportType transportType );
     
     ProtocolHandlerFilterChain getProtocolFilterChain( TransportType transportType );
 

Modified: directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java Fri Mar 25 05:43:18 2005
@@ -117,16 +117,8 @@
         stopThreadPools();
     }
 
-    public IoHandlerFilterChain newIoFilterChain(TransportType transportType) {
-        return findIoAcceptor( transportType ).newFilterChain();
-    }
-
     public IoHandlerFilterChain getIoFilterChain(TransportType transportType) {
         return findIoAcceptor( transportType ).getFilterChain();
-    }
-
-    public ProtocolHandlerFilterChain newProtocolFilterChain(TransportType transportType) {
-        return findProtocolAcceptor( transportType ).newFilterChain();
     }
 
     public ProtocolHandlerFilterChain getProtocolFilterChain(TransportType transportType) {

Modified: directory/network/trunk/src/test/org/apache/mina/io/IoHandlerFilterChainTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/io/IoHandlerFilterChainTest.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/io/IoHandlerFilterChainTest.java (original)
+++ directory/network/trunk/src/test/org/apache/mina/io/IoHandlerFilterChainTest.java Fri Mar 25 05:43:18 2005
@@ -12,13 +12,13 @@
 
 public class IoHandlerFilterChainTest extends TestCase
 {
-    private IoHandlerFilterChain chain;
+    private IoHandlerFilterChainImpl chain;
     private IoSession session;
     private String result;
 
     public void setUp()
     {
-        chain = new IoHandlerFilterChainImpl( true );
+        chain = new IoHandlerFilterChainImpl();
         session = new TestSession();
         result = "";
     }
@@ -32,7 +32,7 @@
         run( "HSO HDR HDW HSI HEC HSC" );
     }
     
-    public void testSimpleChain()
+    public void testChained()
     {
         chain.addLast( "A", new TestFilter( 'A' ) );
         chain.addLast( "B", new TestFilter( 'B' ) );
@@ -44,32 +44,14 @@
              "ASC BSC HSC" );
     }
     
-    public void testNestedChain()
-    {
-        IoHandlerFilterChainImpl childChain = new IoHandlerFilterChainImpl( false );
-
-        chain.addLast( "A", new TestFilter( 'A' ) );
-        chain.addLast( "child", childChain );
-        chain.addLast( "B", new TestFilter( 'B' ) );
-        childChain.addFirst( "C", new TestFilter( 'C' ) );
-        childChain.addLast( "D", new TestFilter( 'D' ) );
-        
-        run( "ASO CSO BSO HSO DSO" +
-             "ADR CDR BDR HDR DDR" +
-             "BFW DFW AFW ADW CDW BDW HDW DDW CFW" +
-             "ASI CSI BSI HSI DSI" +
-             "AEC CEC BEC HEC DEC" +
-             "ASC CSC BSC HSC DSC" );
-    }
-    
     private void run( String expectedResult )
     {
-        chain.sessionOpened( null, session );
-        chain.dataRead( null, session, ByteBuffer.allocate( 16 ) );
-        chain.filterWrite( null, session, ByteBuffer.allocate( 16 ), null );
-        chain.sessionIdle( null, session, IdleStatus.READER_IDLE );
-        chain.exceptionCaught( null, session, new Exception() );
-        chain.sessionClosed( null, session );
+        chain.sessionOpened( session );
+        chain.dataRead( session, ByteBuffer.allocate( 16 ) );
+        chain.filterWrite( session, ByteBuffer.allocate( 16 ), null );
+        chain.sessionIdle( session, IdleStatus.READER_IDLE );
+        chain.exceptionCaught( session, new Exception() );
+        chain.sessionClosed( session );
         
         result = formatResult( result );
         expectedResult = formatResult( expectedResult );
@@ -253,13 +235,13 @@
 
     private static class IoHandlerFilterChainImpl extends AbstractIoHandlerFilterChain
     {
-        protected IoHandlerFilterChainImpl(boolean root) {
-            super( root );
+        protected IoHandlerFilterChainImpl()
+        {
         }
 
         protected void doWrite(IoSession session, ByteBuffer buffer, Object marker)
         {
-            getRoot().dataWritten( null, session, marker );
+            dataWritten( session, marker );
         }
     }
     

Modified: directory/network/trunk/src/test/org/apache/mina/protocol/ProtocolHandlerFilterChainTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/protocol/ProtocolHandlerFilterChainTest.java?view=diff&r1=159008&r2=159009
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/protocol/ProtocolHandlerFilterChainTest.java (original)
+++ directory/network/trunk/src/test/org/apache/mina/protocol/ProtocolHandlerFilterChainTest.java Fri Mar 25 05:43:18 2005
@@ -11,13 +11,13 @@
 
 public class ProtocolHandlerFilterChainTest extends TestCase
 {
-    private ProtocolHandlerFilterChain chain;
+    private ProtocolHandlerFilterChainImpl chain;
     private ProtocolSession session;
     private String result;
 
     public void setUp()
     {
-        chain = new ProtocolHandlerFilterChainImpl( true );
+        chain = new ProtocolHandlerFilterChainImpl();
         session = new TestSession();
         result = "";
     }
@@ -31,7 +31,7 @@
         run( "HSO HMR HMS HSI HEC HSC" );
     }
     
-    public void testSimpleChain()
+    public void testChained()
     {
         chain.addLast( "A", new TestFilter( 'A' ) );
         chain.addLast( "B", new TestFilter( 'B' ) );
@@ -43,32 +43,14 @@
              "ASC BSC HSC" );
     }
     
-    public void testNestedChain()
-    {
-        ProtocolHandlerFilterChainImpl childChain = new ProtocolHandlerFilterChainImpl( false );
-
-        chain.addLast( "A", new TestFilter( 'A' ) );
-        chain.addLast( "child", childChain );
-        chain.addLast( "B", new TestFilter( 'B' ) );
-        childChain.addFirst( "C", new TestFilter( 'C' ) );
-        childChain.addLast( "D", new TestFilter( 'D' ) );
-        
-        run( "ASO CSO BSO HSO DSO" +
-             "AMR CMR BMR HMR DMR" +
-             "BFW DFW AFW AMS CMS BMS HMS DMS CFW" +
-             "ASI CSI BSI HSI DSI" +
-             "AEC CEC BEC HEC DEC" +
-             "ASC CSC BSC HSC DSC" );
-    }
-    
     private void run( String expectedResult )
     {
-        chain.sessionOpened( null, session );
-        chain.messageReceived( null, session, new Object() );
-        chain.filterWrite( null, session, new Object() );
-        chain.sessionIdle( null, session, IdleStatus.READER_IDLE );
-        chain.exceptionCaught( null, session, new Exception() );
-        chain.sessionClosed( null, session );
+        chain.sessionOpened( session );
+        chain.messageReceived( session, new Object() );
+        chain.filterWrite( session, new Object() );
+        chain.sessionIdle( session, IdleStatus.READER_IDLE );
+        chain.exceptionCaught( session, new Exception() );
+        chain.sessionClosed( session );
         
         result = formatResult( result );
         expectedResult = formatResult( expectedResult );
@@ -244,14 +226,13 @@
 
     private static class ProtocolHandlerFilterChainImpl extends AbstractProtocolHandlerFilterChain
     {
-        protected ProtocolHandlerFilterChainImpl( boolean root )
+        protected ProtocolHandlerFilterChainImpl()
         {
-            super( root );
         }
 
         protected void doWrite( ProtocolSession session, Object message )
         {
-            getRoot().messageSent( null, session, message );
+            messageSent( session, message );
         }
     }
     



Mime
View raw message