directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r158988 - in directory/network/trunk/src: java/org/apache/mina/common/ 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/
Date Fri, 25 Mar 2005 04:50:52 GMT
Author: trustin
Date: Thu Mar 24 20:50:47 2005
New Revision: 158988

URL: http://svn.apache.org/viewcvs?view=rev&rev=158988
Log:
* Fixed: Events are fire more than once to handlers when chains are nested.
* Removed FilterChainType:
** Now all filter chains have a pre-registered filter 'nextFilter'.
** If you add your filters before nextFilter, it is pre-processing.
** If you add your filters after nextFilter, it is post-processing.
** If you add your filters around nextFilter, it is around-processing.

Creating test cases related with chains is in progress...

Added:
    directory/network/trunk/src/test/org/apache/mina/io/IoHandlerFilterChainTest.java   (with props)
Removed:
    directory/network/trunk/src/java/org/apache/mina/common/FilterChainType.java
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/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/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/VmPipeFilterChain.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/AbstractBindTest.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=158987&r2=158988
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/AbstractIoHandlerFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/AbstractIoHandlerFilterChain.java Thu Mar 24 20:50:47 2005
@@ -8,7 +8,6 @@
 import java.util.Map;
 
 import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.FilterChainType;
 import org.apache.mina.common.IdleStatus;
 
 public abstract class AbstractIoHandlerFilterChain implements IoHandlerFilterChain
@@ -52,7 +51,7 @@
         public void filterWrite( NextFilter nextFilter, IoSession session,
                                  ByteBuffer buf, Object marker )
         {
-            if( AbstractIoHandlerFilterChain.this.parent == null )
+            if( parent == null )
             {
                 // write only when root filter chain traversal is finished.
                 doWrite( session, buf, marker );
@@ -60,42 +59,139 @@
         }
     };
     
-    private static final IoHandlerFilter TAIL_FILTER = new IoHandlerFilter()
+    private final IoHandlerFilter NEXT_FILTER = new IoHandlerFilter()
     {
         public void sessionOpened( NextFilter nextFilter, IoSession session )
         {
-            session.getHandler().sessionOpened( 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 );
+        }
+    };
+    
+    private final IoHandlerFilter TAIL_FILTER = new IoHandlerFilter()
+    {
+        public void sessionOpened( NextFilter nextFilter, IoSession session )
+        {
+            if( parent == null )
+            {
+                session.getHandler().sessionOpened( session );
+            }
         }
 
         public void sessionClosed( NextFilter nextFilter, IoSession session )
         {
-            session.getHandler().sessionClosed( session );
+            if( parent == null )
+            {
+                session.getHandler().sessionClosed( session );
+            }
         }
 
         public void sessionIdle( NextFilter nextFilter, IoSession session,
                                 IdleStatus status )
         {
-            session.getHandler().sessionIdle( session, status );
+            if( parent == null )
+            {
+                session.getHandler().sessionIdle( session, status );
+            }
         }
 
         public void exceptionCaught( NextFilter nextFilter,
                                     IoSession session, Throwable cause )
         {
-            session.getHandler().exceptionCaught( session, cause );
+            if( parent == null )
+            {
+                session.getHandler().exceptionCaught( session, cause );
+            }
         }
 
         public void dataRead( NextFilter nextFilter, IoSession session,
                              ByteBuffer buf )
         {
-            IoHandler handler = session.getHandler();
-            handler.dataRead( session, buf );
-            buf.release();
+            if( parent == null )
+            {
+                IoHandler handler = session.getHandler();
+                handler.dataRead( session, buf );
+                buf.release();
+            }
         }
 
         public void dataWritten( NextFilter nextFilter, IoSession session,
                                 Object marker )
         {
-            session.getHandler().dataWritten( session, marker );
+            if( parent == null )
+            {
+                session.getHandler().dataWritten( session, marker );
+            }
         }
 
         public void filterWrite( NextFilter nextFilter,
@@ -107,28 +203,21 @@
 
     private AbstractIoHandlerFilterChain parent;
     
-    private final FilterChainType type; 
-    
     private final Map name2entry = new HashMap();
 
     private final Map filter2entry = new IdentityHashMap();
 
     private final Entry head;
-
+    
     private final Entry tail;
 
-    protected AbstractIoHandlerFilterChain( FilterChainType type )
+    protected AbstractIoHandlerFilterChain()
     {
-        if( type == null )
-        {
-            throw new NullPointerException( "type" );
-        }
-        
-        this.type = type;
-        
         head = new Entry( null, null, "head", HEAD_FILTER );
         tail = new Entry( head, null, "tail", TAIL_FILTER );
         head.nextEntry = tail;
+        
+        register( head, IoHandlerFilterChain.NEXT_FILTER, NEXT_FILTER );
     }
     
     public IoHandlerFilterChain getRoot()
@@ -146,11 +235,6 @@
         return parent;
     }
     
-    public FilterChainType getType()
-    {
-        return type;
-    }
-    
     public IoHandlerFilter getChild( String name )
     {
         Entry e = ( Entry ) name2entry.get( name );
@@ -296,29 +380,15 @@
     public void sessionOpened( NextFilter nextFilter, IoSession session )
     {
         Entry head = this.head;
-        callNextSessionOpened(head, nextFilter, session);
+        callNextSessionOpened(head, session);
     }
 
     private void callNextSessionOpened( Entry entry,
-                                        NextFilter nextFilter, IoSession session)
+                                        IoSession session)
     {
         try
         {
-            if( nextFilter == null )
-            {
-                entry.filter.sessionOpened( entry.nextFilter, session );
-            }
-            else if ( type == FilterChainType.PREPROCESS )
-            {
-                entry.filter.sessionOpened( entry.nextFilter, session );
-                nextFilter.sessionOpened( session );
-            }
-            else // POSTPROCESS
-            {
-                nextFilter.sessionOpened( session );
-                entry.filter.sessionOpened( entry.nextFilter, session );
-            }
-                
+            entry.filter.sessionOpened( entry.nextFilter, session );
         }
         catch( Throwable e )
         {
@@ -329,29 +399,15 @@
     public void sessionClosed( NextFilter nextFilter, IoSession session )
     {
         Entry head = this.head;
-        callNextSessionClosed(head, nextFilter, session);
+        callNextSessionClosed(head, session);
     }
 
     private void callNextSessionClosed( Entry entry,
-                                        NextFilter nextFilter, IoSession session )
+                                        IoSession session )
     {
         try
         {
-            if( nextFilter == null )
-            {
-                entry.filter.sessionClosed( entry.nextFilter, session );
-            }
-            else if( type == FilterChainType.PREPROCESS )
-            {
-                entry.filter.sessionClosed( entry.nextFilter, session );
-                nextFilter.sessionClosed( session );
-            }
-            else // POSTPROCESS
-            {
-                nextFilter.sessionClosed( session );
-                entry.filter.sessionClosed( entry.nextFilter, session );
-            }
-                
+            entry.filter.sessionClosed( entry.nextFilter, session );
         }
         catch( Throwable e )
         {
@@ -362,29 +418,16 @@
     public void sessionIdle( NextFilter nextFilter, IoSession session, IdleStatus status )
     {
         Entry head = this.head;
-        callNextSessionIdle(head, nextFilter, session, status);
+        callNextSessionIdle(head, session, status);
     }
 
     private void callNextSessionIdle( Entry entry,
-                                      NextFilter nextFilter, IoSession session,
+                                      IoSession session,
                                       IdleStatus status )
     {
         try
         {
-            if( nextFilter == null )
-            {
-                entry.filter.sessionIdle( entry.nextFilter, session, status );
-            }
-            else if( type == FilterChainType.PREPROCESS )
-            {
-                entry.filter.sessionIdle( entry.nextFilter, session, status );
-                nextFilter.sessionIdle( session, status );
-            }
-            else // POSTPROCESS
-            {
-                nextFilter.sessionIdle( session, status );
-                entry.filter.sessionIdle( entry.nextFilter, session, status );
-            }
+            entry.filter.sessionIdle( entry.nextFilter, session, status );
         }
         catch( Throwable e )
         {
@@ -395,29 +438,16 @@
     public void dataRead( NextFilter nextFilter, IoSession session, ByteBuffer buf )
     {
         Entry head = this.head;
-        callNextDataRead(head, nextFilter, session, buf);
+        callNextDataRead(head, session, buf);
     }
 
     private void callNextDataRead( Entry entry,
-                                   NextFilter nextFilter, IoSession session,
+                                   IoSession session,
                                    ByteBuffer buf )
     {
         try
         {
-            if( nextFilter == null )
-            {
-                entry.filter.dataRead( entry.nextFilter, session, buf );
-            }
-            else if( type == FilterChainType.PREPROCESS )
-            {
-                entry.filter.dataRead( entry.nextFilter, session, buf );
-                nextFilter.dataRead( session, buf );
-            }
-            else // POSTPROCESS
-            {
-                nextFilter.dataRead( session, buf );
-                entry.filter.dataRead( entry.nextFilter, session, buf );
-            }
+            entry.filter.dataRead( entry.nextFilter, session, buf );
         }
         catch( Throwable e )
         {
@@ -428,29 +458,16 @@
     public void dataWritten( NextFilter nextFilter, IoSession session, Object marker )
     {
         Entry head = this.head;
-        callNextDataWritten(head, nextFilter, session, marker);
+        callNextDataWritten(head, session, marker);
     }
 
     private void callNextDataWritten( Entry entry,
-                                      NextFilter nextFilter, IoSession session,
+                                      IoSession session,
                                       Object marker ) 
     {
         try
         {
-            if( nextFilter == null )
-            {
-                entry.filter.dataWritten( entry.nextFilter, session, marker );
-            }
-            else if( type == FilterChainType.PREPROCESS )
-            {
-                entry.filter.dataWritten( entry.nextFilter, session, marker );
-                nextFilter.dataWritten( session, marker );
-            }
-            else // POSTPROCESS
-            {
-                nextFilter.dataWritten( session, marker );
-                entry.filter.dataWritten( entry.nextFilter, session, marker );
-            }
+            entry.filter.dataWritten( entry.nextFilter, session, marker );
         }
         catch( Throwable e )
         {
@@ -461,29 +478,16 @@
     public void exceptionCaught( NextFilter nextFilter, IoSession session, Throwable cause )
     {
         Entry head = this.head;
-        callNextExceptionCaught(head, nextFilter, session, cause);
+        callNextExceptionCaught(head, session, cause);
     }
 
     private void callNextExceptionCaught( Entry entry,
-                                          NextFilter nextFilter, IoSession session,
+                                          IoSession session,
                                           Throwable cause )
     {
         try
         {
-            if( nextFilter == null )
-            {
-                entry.filter.exceptionCaught( entry.nextFilter, session, cause );
-            }
-            else if( type == FilterChainType.PREPROCESS )
-            {
-                entry.filter.exceptionCaught( entry.nextFilter, session, cause );
-                nextFilter.exceptionCaught( session, cause );
-            }
-            else // POSTPROCESS
-            {
-                entry.filter.exceptionCaught( entry.nextFilter, session, cause );
-                nextFilter.exceptionCaught( session, cause );
-            }
+            entry.filter.exceptionCaught( entry.nextFilter, session, cause );
         }
         catch( Throwable e )
         {
@@ -495,11 +499,11 @@
                              IoSession session, ByteBuffer buf, Object marker )
     {
         Entry tail = this.tail;
-        callPreviousFilterWrite( tail, nextFilter, session, buf, marker );
+        callPreviousFilterWrite( tail, session, buf, marker );
     }
 
     private void callPreviousFilterWrite( Entry entry,
-                                          NextFilter prevFilter, IoSession session,
+                                          IoSession session,
                                           ByteBuffer buf, Object marker )
     {
         if( buf == null )
@@ -509,20 +513,7 @@
         
         try
         {
-            if( prevFilter == null )
-            {
-                entry.filter.filterWrite( entry.prevFilter, session, buf, marker );
-            }
-            else if( type == FilterChainType.PREPROCESS )
-            {
-                entry.filter.filterWrite( entry.prevFilter, session, buf, marker );
-                prevFilter.filterWrite( session, buf, marker );
-            }
-            else // POSTPROCESS
-            {
-                entry.filter.filterWrite( entry.prevFilter, session, buf, marker );
-                prevFilter.filterWrite( session, buf, marker );
-            }
+            entry.filter.filterWrite( entry.prevFilter, session, buf, marker );
         }
         catch( Throwable e )
         {
@@ -605,38 +596,38 @@
                 public void sessionOpened( IoSession session )
                 {
                     Entry nextEntry = Entry.this.nextEntry;
-                    callNextSessionOpened( nextEntry, null, session );
+                    callNextSessionOpened( nextEntry, session );
                 }
 
                 public void sessionClosed( IoSession session )
                 {
                     Entry nextEntry = Entry.this.nextEntry;
-                    callNextSessionClosed( nextEntry, null, session );
+                    callNextSessionClosed( nextEntry, session );
                 }
 
                 public void sessionIdle( IoSession session, IdleStatus status )
                 {
                     Entry nextEntry = Entry.this.nextEntry;
-                    callNextSessionIdle( nextEntry, null, session, status );
+                    callNextSessionIdle( nextEntry, session, status );
                 }
 
                 public void exceptionCaught( IoSession session,
                                             Throwable cause )
                 {
                     Entry nextEntry = Entry.this.nextEntry;
-                    callNextExceptionCaught( nextEntry, null, session, cause );
+                    callNextExceptionCaught( nextEntry, session, cause );
                 }
 
                 public void dataRead( IoSession session, ByteBuffer buf )
                 {
                     Entry nextEntry = Entry.this.nextEntry;
-                    callNextDataRead( nextEntry, null, session, buf );
+                    callNextDataRead( nextEntry, session, buf );
                 }
 
                 public void dataWritten( IoSession session, Object marker )
                 {
                     Entry nextEntry = Entry.this.nextEntry;
-                    callNextDataWritten( nextEntry, null, session, marker );
+                    callNextDataWritten( nextEntry, session, marker );
                 }
                 
                 public void filterWrite( IoSession session, ByteBuffer buf, Object marker )
@@ -682,7 +673,7 @@
                 public void filterWrite( IoSession session, ByteBuffer buf, Object marker )
                 {
                     Entry nextEntry = Entry.this.prevEntry;
-                    callPreviousFilterWrite( nextEntry, null, session, buf, marker );
+                    callPreviousFilterWrite( nextEntry, session, buf, 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=158987&r2=158988
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/IoAcceptor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/IoAcceptor.java Thu Mar 24 20:50:47 2005
@@ -21,8 +21,6 @@
 import java.io.IOException;
 import java.net.SocketAddress;
 
-import org.apache.mina.common.FilterChainType;
-
 /**
  * Accepts incoming connection, communicates with clients, and fires events to
  * {@link IoHandler}s.
@@ -64,7 +62,7 @@
      */
     void unbind( SocketAddress address );
 
-    IoHandlerFilterChain newFilterChain( FilterChainType type );
+    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=158987&r2=158988
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/IoConnector.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/IoConnector.java Thu Mar 24 20:50:47 2005
@@ -21,8 +21,6 @@
 import java.io.IOException;
 import java.net.SocketAddress;
 
-import org.apache.mina.common.FilterChainType;
-
 /**
  * Connects to endpoint, communicates with the server, and fires events to
  * {@link IoHandler}s.
@@ -71,7 +69,7 @@
     IoSession connect( SocketAddress address, int timeout, IoHandler handler )
             throws IOException;
 
-    IoHandlerFilterChain newFilterChain( FilterChainType type );
+    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=158987&r2=158988
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/IoHandlerFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/IoHandlerFilterChain.java Thu Mar 24 20:50:47 2005
@@ -2,13 +2,12 @@
 
 import java.util.List;
 
-import org.apache.mina.common.FilterChainType;
-
 
 public interface IoHandlerFilterChain extends IoHandlerFilter {
+    static String NEXT_FILTER = "nextFilter";
+    
     IoHandlerFilterChain getRoot();
     IoHandlerFilterChain getParent();
-    FilterChainType getType();
 
     IoHandlerFilter getChild( String name );
     List getChildren();

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=158987&r2=158988
==============================================================================
--- 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 Thu Mar 24 20:50:47 2005
@@ -30,7 +30,6 @@
 import java.util.Set;
 
 import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.FilterChainType;
 import org.apache.mina.io.DefaultExceptionMonitor;
 import org.apache.mina.io.ExceptionMonitor;
 import org.apache.mina.io.IoAcceptor;
@@ -48,7 +47,7 @@
 {
     private static volatile int nextId = 0;
 
-    private final DatagramFilterChain filters = new DatagramFilterChain( FilterChainType.PREPROCESS, this );
+    private final DatagramFilterChain filters = new DatagramFilterChain( this );
 
     private final int id = nextId ++ ;
 
@@ -514,9 +513,9 @@
         }
     }
     
-    public IoHandlerFilterChain newFilterChain( FilterChainType type )
+    public IoHandlerFilterChain newFilterChain()
     {
-        return new DatagramFilterChain( type, this );
+        return new DatagramFilterChain( 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=158987&r2=158988
==============================================================================
--- 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 Thu Mar 24 20:50:47 2005
@@ -29,7 +29,6 @@
 import java.util.Set;
 
 import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.FilterChainType;
 import org.apache.mina.io.DefaultExceptionMonitor;
 import org.apache.mina.io.ExceptionMonitor;
 import org.apache.mina.io.IoConnector;
@@ -49,7 +48,7 @@
 {
     private static volatile int nextId = 0;
 
-    private final DatagramFilterChain filters = new DatagramFilterChain( FilterChainType.PREPROCESS, this );
+    private final DatagramFilterChain filters = new DatagramFilterChain( this );
 
     private final int id = nextId ++ ;
 
@@ -427,9 +426,9 @@
         }
     }
 
-    public IoHandlerFilterChain newFilterChain( FilterChainType type )
+    public IoHandlerFilterChain newFilterChain()
     {
-        return new DatagramFilterChain( type, this );
+        return new DatagramFilterChain( this );
     }
     
     public IoHandlerFilterChain getFilterChain()

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=158987&r2=158988
==============================================================================
--- 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 Thu Mar 24 20:50:47 2005
@@ -1,7 +1,6 @@
 package org.apache.mina.io.datagram;
 
 import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.FilterChainType;
 import org.apache.mina.io.AbstractIoHandlerFilterChain;
 import org.apache.mina.io.IoSession;
 import org.apache.mina.util.Queue;
@@ -10,10 +9,8 @@
 
     private final DatagramProcessor processor;
 
-    DatagramFilterChain( FilterChainType type, DatagramProcessor processor )
+    DatagramFilterChain( DatagramProcessor processor )
     {
-        super( type );
-        
         this.processor = processor;
     }
 

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=158987&r2=158988
==============================================================================
--- 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 Thu Mar 24 20:50:47 2005
@@ -31,7 +31,6 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.mina.common.FilterChainType;
 import org.apache.mina.io.DefaultExceptionMonitor;
 import org.apache.mina.io.ExceptionMonitor;
 import org.apache.mina.io.IoAcceptor;
@@ -50,7 +49,7 @@
 {
     private static volatile int nextId = 0;
 
-    private final SocketFilterChain filters = new SocketFilterChain( FilterChainType.PREPROCESS );
+    private final SocketFilterChain filters = new SocketFilterChain();
 
     private final int id = nextId ++ ;
 
@@ -424,9 +423,9 @@
     }
 
 
-    public IoHandlerFilterChain newFilterChain( FilterChainType type )
+    public IoHandlerFilterChain newFilterChain()
     {
-        return new SocketFilterChain( type );
+        return new SocketFilterChain();
     }
 
 

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=158987&r2=158988
==============================================================================
--- 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 Thu Mar 24 20:50:47 2005
@@ -28,7 +28,6 @@
 import java.util.Iterator;
 import java.util.Set;
 
-import org.apache.mina.common.FilterChainType;
 import org.apache.mina.io.DefaultExceptionMonitor;
 import org.apache.mina.io.ExceptionMonitor;
 import org.apache.mina.io.IoConnector;
@@ -49,7 +48,7 @@
 
     private final int id = nextId++;
 
-    private final SocketFilterChain filters = new SocketFilterChain( FilterChainType.PREPROCESS );
+    private final SocketFilterChain filters = new SocketFilterChain();
 
     private final Selector selector;
 
@@ -329,9 +328,9 @@
         }
     }
 
-    public IoHandlerFilterChain newFilterChain( FilterChainType type )
+    public IoHandlerFilterChain newFilterChain()
     {
-        return new SocketFilterChain( type );
+        return new SocketFilterChain();
     }
     
     public IoHandlerFilterChain getFilterChain()

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=158987&r2=158988
==============================================================================
--- 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 Thu Mar 24 20:50:47 2005
@@ -1,16 +1,14 @@
 package org.apache.mina.io.socket;
 
 import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.FilterChainType;
 import org.apache.mina.io.AbstractIoHandlerFilterChain;
 import org.apache.mina.io.IoSession;
 import org.apache.mina.util.Queue;
 
 class SocketFilterChain extends AbstractIoHandlerFilterChain {
 
-    SocketFilterChain( FilterChainType type )
+    SocketFilterChain()
     {
-        super( type );
     }
 
     protected void doWrite( IoSession session, ByteBuffer buf, Object marker )

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=158987&r2=158988
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/AbstractProtocolHandlerFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/AbstractProtocolHandlerFilterChain.java Thu Mar 24 20:50:47 2005
@@ -7,7 +7,6 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.mina.common.FilterChainType;
 import org.apache.mina.common.IdleStatus;
 
 public abstract class AbstractProtocolHandlerFilterChain implements ProtocolHandlerFilterChain
@@ -51,7 +50,7 @@
         public void filterWrite( NextFilter nextFilter, ProtocolSession session,
                                  Object message )
         {
-            if( AbstractProtocolHandlerFilterChain.this.parent == null )
+            if( parent == null )
             {
                 // write only when root filter chain traversal is finished.
                 doWrite( session, message );
@@ -59,41 +58,137 @@
         }
     };
     
-    private static final ProtocolHandlerFilter TAIL_FILTER = new ProtocolHandlerFilter()
+    private final ProtocolHandlerFilter NEXT_FILTER = new ProtocolHandlerFilter()
     {
         public void sessionOpened( NextFilter nextFilter, ProtocolSession session )
         {
-            session.getHandler().sessionOpened( 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 )
         {
-            session.getHandler().sessionClosed( 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 )
         {
-            session.getHandler().sessionIdle( session, 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 )
         {
-            session.getHandler().exceptionCaught( session, 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 )
         {
-            ProtocolHandler handler = session.getHandler();
-            handler.messageReceived( session, 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 )
         {
-            session.getHandler().messageSent( session, 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 );
+        }
+    };
+    
+    private final ProtocolHandlerFilter TAIL_FILTER = new ProtocolHandlerFilter()
+    {
+        public void sessionOpened( NextFilter nextFilter, ProtocolSession session )
+        {
+            if( parent == null )
+            {
+                session.getHandler().sessionOpened( session );
+            }
+        }
+
+        public void sessionClosed( NextFilter nextFilter, ProtocolSession session )
+        {
+            if( parent == null )
+            {
+                session.getHandler().sessionClosed( session );
+            }
+        }
+
+        public void sessionIdle( NextFilter nextFilter, ProtocolSession session,
+                                IdleStatus status )
+        {
+            if( parent == null )
+            {
+                session.getHandler().sessionIdle( session, status );
+            }
+        }
+
+        public void exceptionCaught( NextFilter nextFilter,
+                                    ProtocolSession session, Throwable cause )
+        {
+            if( parent == null )
+            {
+                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 );
+            }
+        }
+
+        public void messageSent( NextFilter nextFilter, ProtocolSession session,
+                                 Object message )
+        {
+            if( parent == null )
+            {
+                session.getHandler().messageSent( session, message );
+            }
         }
 
         public void filterWrite( NextFilter nextFilter,
@@ -105,8 +200,6 @@
 
     private AbstractProtocolHandlerFilterChain parent;
     
-    private final FilterChainType type; 
-    
     private final Map name2entry = new HashMap();
 
     private final Map filter2entry = new IdentityHashMap();
@@ -115,18 +208,13 @@
 
     private final Entry tail;
 
-    protected AbstractProtocolHandlerFilterChain( FilterChainType type )
+    protected AbstractProtocolHandlerFilterChain()
     {
-        if( type == null )
-        {
-            throw new NullPointerException( "type" );
-        }
-        
-        this.type = type;
-        
         head = new Entry( null, null, "head", HEAD_FILTER );
         tail = new Entry( head, null, "tail", TAIL_FILTER );
         head.nextEntry = tail;
+        
+        register( head, ProtocolHandlerFilterChain.NEXT_FILTER, NEXT_FILTER );
     }
     
     public ProtocolHandlerFilterChain getRoot()
@@ -144,11 +232,6 @@
         return parent;
     }
     
-    public FilterChainType getType()
-    {
-        return type;
-    }
-    
     public ProtocolHandlerFilter getChild( String name )
     {
         Entry e = ( Entry ) name2entry.get( name );
@@ -294,29 +377,15 @@
     public void sessionOpened( NextFilter nextFilter, ProtocolSession session )
     {
         Entry head = this.head;
-        callNextSessionOpened(head, nextFilter, session);
+        callNextSessionOpened(head, session);
     }
 
     private void callNextSessionOpened( Entry entry,
-                                        NextFilter nextFilter, ProtocolSession session)
+                                        ProtocolSession session)
     {
         try
         {
-            if( nextFilter == null )
-            {
-                entry.filter.sessionOpened( entry.nextFilter, session );
-            }
-            else if ( type == FilterChainType.PREPROCESS )
-            {
-                entry.filter.sessionOpened( entry.nextFilter, session );
-                nextFilter.sessionOpened( session );
-            }
-            else // POSTPROCESS
-            {
-                nextFilter.sessionOpened( session );
-                entry.filter.sessionOpened( entry.nextFilter, session );
-            }
-                
+            entry.filter.sessionOpened( entry.nextFilter, session );
         }
         catch( Throwable e )
         {
@@ -327,28 +396,15 @@
     public void sessionClosed( NextFilter nextFilter, ProtocolSession session )
     {
         Entry head = this.head;
-        callNextSessionClosed(head, nextFilter, session);
+        callNextSessionClosed(head, session);
     }
 
     private void callNextSessionClosed( Entry entry,
-                                        NextFilter nextFilter, ProtocolSession session )
+                                        ProtocolSession session )
     {
         try
         {
-            if( nextFilter == null )
-            {
-                entry.filter.sessionClosed( entry.nextFilter, session );
-            }
-            else if( type == FilterChainType.PREPROCESS )
-            {
-                entry.filter.sessionClosed( entry.nextFilter, session );
-                nextFilter.sessionClosed( session );
-            }
-            else // POSTPROCESS
-            {
-                nextFilter.sessionClosed( session );
-                entry.filter.sessionClosed( entry.nextFilter, session );
-            }
+            entry.filter.sessionClosed( entry.nextFilter, session );
                 
         }
         catch( Throwable e )
@@ -360,29 +416,16 @@
     public void sessionIdle( NextFilter nextFilter, ProtocolSession session, IdleStatus status )
     {
         Entry head = this.head;
-        callNextSessionIdle(head, nextFilter, session, status);
+        callNextSessionIdle(head, session, status);
     }
 
     private void callNextSessionIdle( Entry entry,
-                                      NextFilter nextFilter, ProtocolSession session,
+                                      ProtocolSession session,
                                       IdleStatus status )
     {
         try
         {
-            if( nextFilter == null )
-            {
-                entry.filter.sessionIdle( entry.nextFilter, session, status );
-            }
-            else if( type == FilterChainType.PREPROCESS )
-            {
-                entry.filter.sessionIdle( entry.nextFilter, session, status );
-                nextFilter.sessionIdle( session, status );
-            }
-            else // POSTPROCESS
-            {
-                nextFilter.sessionIdle( session, status );
-                entry.filter.sessionIdle( entry.nextFilter, session, status );
-            }
+            entry.filter.sessionIdle( entry.nextFilter, session, status );
         }
         catch( Throwable e )
         {
@@ -393,29 +436,16 @@
     public void messageReceived( NextFilter nextFilter, ProtocolSession session, Object message )
     {
         Entry head = this.head;
-        callNextMessageReceived(head, nextFilter, session, message );
+        callNextMessageReceived(head, session, message );
     }
 
     private void callNextMessageReceived( Entry entry,
-                                   NextFilter nextFilter, ProtocolSession session,
-                                   Object message )
+                                          ProtocolSession session,
+                                          Object message )
     {
         try
         {
-            if( nextFilter == null )
-            {
-                entry.filter.messageReceived( entry.nextFilter, session, message );
-            }
-            else if( type == FilterChainType.PREPROCESS )
-            {
-                entry.filter.messageReceived( entry.nextFilter, session, message );
-                nextFilter.messageReceived( session, message );
-            }
-            else // POSTPROCESS
-            {
-                nextFilter.messageReceived( session, message );
-                entry.filter.messageReceived( entry.nextFilter, session, message );
-            }
+            entry.filter.messageReceived( entry.nextFilter, session, message );
         }
         catch( Throwable e )
         {
@@ -426,29 +456,16 @@
     public void messageSent( NextFilter nextFilter, ProtocolSession session, Object message )
     {
         Entry head = this.head;
-        callNextMessageSent(head, nextFilter, session, message);
+        callNextMessageSent(head, session, message);
     }
 
     private void callNextMessageSent( Entry entry,
-                                      NextFilter nextFilter, ProtocolSession session,
+                                      ProtocolSession session,
                                       Object message ) 
     {
         try
         {
-            if( nextFilter == null )
-            {
-                entry.filter.messageSent( entry.nextFilter, session, message );
-            }
-            else if( type == FilterChainType.PREPROCESS )
-            {
-                entry.filter.messageSent( entry.nextFilter, session, message );
-                nextFilter.messageSent( session, message );
-            }
-            else // POSTPROCESS
-            {
-                nextFilter.messageSent( session, message );
-                entry.filter.messageSent( entry.nextFilter, session, message );
-            }
+            entry.filter.messageSent( entry.nextFilter, session, message );
         }
         catch( Throwable e )
         {
@@ -459,29 +476,16 @@
     public void exceptionCaught( NextFilter nextFilter, ProtocolSession session, Throwable cause )
     {
         Entry head = this.head;
-        callNextExceptionCaught(head, nextFilter, session, cause);
+        callNextExceptionCaught(head, session, cause);
     }
 
     private void callNextExceptionCaught( Entry entry,
-                                          NextFilter nextFilter, ProtocolSession session,
+                                          ProtocolSession session,
                                           Throwable cause )
     {
         try
         {
-            if( nextFilter == null )
-            {
-                entry.filter.exceptionCaught( entry.nextFilter, session, cause );
-            }
-            else if( type == FilterChainType.PREPROCESS )
-            {
-                entry.filter.exceptionCaught( entry.nextFilter, session, cause );
-                nextFilter.exceptionCaught( session, cause );
-            }
-            else // POSTPROCESS
-            {
-                entry.filter.exceptionCaught( entry.nextFilter, session, cause );
-                nextFilter.exceptionCaught( session, cause );
-            }
+            entry.filter.exceptionCaught( entry.nextFilter, session, cause );
         }
         catch( Throwable e )
         {
@@ -493,11 +497,11 @@
                              ProtocolSession session, Object message )
     {
         Entry tail = this.tail;
-        callPreviousFilterWrite( tail, nextFilter, session, message );
+        callPreviousFilterWrite( tail, session, message );
     }
 
     private void callPreviousFilterWrite( Entry entry,
-                                          NextFilter prevFilter, ProtocolSession session,
+                                          ProtocolSession session,
                                           Object message )
     {
         if( message == null )
@@ -507,20 +511,7 @@
         
         try
         {
-            if( prevFilter == null )
-            {
-                entry.filter.filterWrite( entry.prevFilter, session, message );
-            }
-            else if( type == FilterChainType.PREPROCESS )
-            {
-                entry.filter.filterWrite( entry.prevFilter, session, message );
-                prevFilter.filterWrite( session, message );
-            }
-            else // POSTPROCESS
-            {
-                entry.filter.filterWrite( entry.prevFilter, session, message );
-                prevFilter.filterWrite( session, message );
-            }
+            entry.filter.filterWrite( entry.prevFilter, session, message );
         }
         catch( Throwable e )
         {
@@ -603,38 +594,38 @@
                 public void sessionOpened( ProtocolSession session )
                 {
                     Entry nextEntry = Entry.this.nextEntry;
-                    callNextSessionOpened( nextEntry, null, session );
+                    callNextSessionOpened( nextEntry, session );
                 }
 
                 public void sessionClosed( ProtocolSession session )
                 {
                     Entry nextEntry = Entry.this.nextEntry;
-                    callNextSessionClosed( nextEntry, null, session );
+                    callNextSessionClosed( nextEntry, session );
                 }
 
                 public void sessionIdle( ProtocolSession session, IdleStatus status )
                 {
                     Entry nextEntry = Entry.this.nextEntry;
-                    callNextSessionIdle( nextEntry, null, session, status );
+                    callNextSessionIdle( nextEntry, session, status );
                 }
 
                 public void exceptionCaught( ProtocolSession session,
                                             Throwable cause )
                 {
                     Entry nextEntry = Entry.this.nextEntry;
-                    callNextExceptionCaught( nextEntry, null, session, cause );
+                    callNextExceptionCaught( nextEntry, session, cause );
                 }
 
                 public void messageReceived( ProtocolSession session, Object message )
                 {
                     Entry nextEntry = Entry.this.nextEntry;
-                    callNextMessageReceived( nextEntry, null, session, message );
+                    callNextMessageReceived( nextEntry, session, message );
                 }
 
                 public void messageSent( ProtocolSession session, Object message )
                 {
                     Entry nextEntry = Entry.this.nextEntry;
-                    callNextMessageSent( nextEntry, null, session, message );
+                    callNextMessageSent( nextEntry, session, message );
                 }
                 
                 public void filterWrite( ProtocolSession session, Object message )
@@ -680,7 +671,7 @@
                 public void filterWrite( ProtocolSession session, Object message )
                 {
                     Entry nextEntry = Entry.this.prevEntry;
-                    callPreviousFilterWrite( nextEntry, null, session, message );
+                    callPreviousFilterWrite( nextEntry, session, 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=158987&r2=158988
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolAcceptor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolAcceptor.java Thu Mar 24 20:50:47 2005
@@ -21,8 +21,6 @@
 import java.io.IOException;
 import java.net.SocketAddress;
 
-import org.apache.mina.common.FilterChainType;
-
 /**
  * Accepts incoming connection, communicates with clients, and fires events to
  * {@link ProtocolHandler}s.
@@ -61,7 +59,7 @@
      */
     void unbind( SocketAddress address );
 
-    ProtocolHandlerFilterChain newFilterChain( FilterChainType type );
+    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=158987&r2=158988
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolConnector.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolConnector.java Thu Mar 24 20:50:47 2005
@@ -21,8 +21,6 @@
 import java.io.IOException;
 import java.net.SocketAddress;
 
-import org.apache.mina.common.FilterChainType;
-
 /**
  * Connects to endpoint, communicates with the server, and fires events to
  * {@link ProtocolProvider}s.
@@ -69,7 +67,7 @@
                             ProtocolProvider protocolProvider )
             throws IOException;
 
-    ProtocolHandlerFilterChain newFilterChain( FilterChainType type );
+    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=158987&r2=158988
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolHandlerFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/ProtocolHandlerFilterChain.java Thu Mar 24 20:50:47 2005
@@ -2,13 +2,12 @@
 
 import java.util.List;
 
-import org.apache.mina.common.FilterChainType;
-
 
 public interface ProtocolHandlerFilterChain extends ProtocolHandlerFilter {
+    static String NEXT_FILTER = "nextFilter";
+    
     ProtocolHandlerFilterChain getRoot();
     ProtocolHandlerFilterChain getParent();
-    FilterChainType getType();
 
     ProtocolHandlerFilter getChild( String name );
     List getChildren();

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=158987&r2=158988
==============================================================================
--- 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 Thu Mar 24 20:50:47 2005
@@ -21,7 +21,6 @@
 import java.net.SocketAddress;
 
 import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.FilterChainType;
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.common.SessionConfig;
 import org.apache.mina.common.TransportType;
@@ -53,15 +52,15 @@
  */
 public class IoAdapter
 {
-    private final IoProtocolFilterChain filters = new IoProtocolFilterChain( FilterChainType.PREPROCESS );
+    private final IoProtocolFilterChain filters = new IoProtocolFilterChain();
 
     IoAdapter()
     {
     }
     
-    public ProtocolHandlerFilterChain newFilterChain( FilterChainType type )
+    public ProtocolHandlerFilterChain newFilterChain()
     {
-        return new IoProtocolFilterChain( type );
+        return new IoProtocolFilterChain();
     }
     
     public ProtocolHandlerFilterChain getFilterChain()

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=158987&r2=158988
==============================================================================
--- 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 Thu Mar 24 20:50:47 2005
@@ -6,7 +6,6 @@
 import java.io.IOException;
 import java.net.SocketAddress;
 
-import org.apache.mina.common.FilterChainType;
 import org.apache.mina.io.IoAcceptor;
 import org.apache.mina.protocol.ProtocolAcceptor;
 import org.apache.mina.protocol.ProtocolHandlerFilterChain;
@@ -56,9 +55,9 @@
         acceptor.unbind( address );
     }
     
-    public ProtocolHandlerFilterChain newFilterChain( FilterChainType type )
+    public ProtocolHandlerFilterChain newFilterChain()
     {
-        return adapter.newFilterChain( type );
+        return adapter.newFilterChain();
     }
 
     public ProtocolHandlerFilterChain 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=158987&r2=158988
==============================================================================
--- 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 Thu Mar 24 20:50:47 2005
@@ -6,7 +6,6 @@
 import java.io.IOException;
 import java.net.SocketAddress;
 
-import org.apache.mina.common.FilterChainType;
 import org.apache.mina.io.IoConnector;
 import org.apache.mina.io.IoSession;
 import org.apache.mina.protocol.ProtocolConnector;
@@ -64,9 +63,9 @@
         return adapter.toProtocolSession( session );
     }
 
-    public ProtocolHandlerFilterChain newFilterChain( FilterChainType type )
+    public ProtocolHandlerFilterChain newFilterChain()
     {
-        return adapter.newFilterChain( type );
+        return adapter.newFilterChain();
     }
 
     public ProtocolHandlerFilterChain 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=158987&r2=158988
==============================================================================
--- 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 Thu Mar 24 20:50:47 2005
@@ -1,6 +1,5 @@
 package org.apache.mina.protocol.io;
 
-import org.apache.mina.common.FilterChainType;
 import org.apache.mina.protocol.AbstractProtocolHandlerFilterChain;
 import org.apache.mina.protocol.ProtocolSession;
 import org.apache.mina.protocol.io.IoAdapter.ProtocolSessionImpl;
@@ -8,8 +7,7 @@
 
 class IoProtocolFilterChain extends AbstractProtocolHandlerFilterChain {
 
-    IoProtocolFilterChain(FilterChainType type) {
-        super(type);
+    IoProtocolFilterChain() {
     }
 
     protected void doWrite(ProtocolSession session, Object message) {

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=158987&r2=158988
==============================================================================
--- 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 Thu Mar 24 20:50:47 2005
@@ -8,7 +8,6 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.mina.common.FilterChainType;
 import org.apache.mina.protocol.ProtocolAcceptor;
 import org.apache.mina.protocol.ProtocolHandler;
 import org.apache.mina.protocol.ProtocolHandlerFilterChain;
@@ -25,7 +24,7 @@
 {
     static final Map boundHandlers = new HashMap();
 
-    private final VmPipeFilterChain filters = new VmPipeFilterChain( FilterChainType.PREPROCESS );
+    private final VmPipeFilterChain filters = new VmPipeFilterChain();
 
     /**
      * Creates a new instance.
@@ -69,9 +68,9 @@
         }
     }
     
-    public ProtocolHandlerFilterChain newFilterChain( FilterChainType type )
+    public ProtocolHandlerFilterChain newFilterChain()
     {
-        return new VmPipeFilterChain( type );
+        return new VmPipeFilterChain();
     }
     
     public ProtocolHandlerFilterChain getFilterChain()

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=158987&r2=158988
==============================================================================
--- 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 Thu Mar 24 20:50:47 2005
@@ -6,7 +6,6 @@
 import java.io.IOException;
 import java.net.SocketAddress;
 
-import org.apache.mina.common.FilterChainType;
 import org.apache.mina.protocol.ProtocolConnector;
 import org.apache.mina.protocol.ProtocolHandlerFilterChain;
 import org.apache.mina.protocol.ProtocolProvider;
@@ -22,7 +21,7 @@
  */
 public class VmPipeConnector implements ProtocolConnector
 {
-    private final VmPipeFilterChain filters = new VmPipeFilterChain( FilterChainType.PREPROCESS );
+    private final VmPipeFilterChain filters = new VmPipeFilterChain();
 
     /**
      * Creates a new instance.
@@ -32,9 +31,9 @@
         filters.addLast( "VMPipe", new VmPipeFilter() );
     }
     
-    public ProtocolHandlerFilterChain newFilterChain( FilterChainType type )
+    public ProtocolHandlerFilterChain newFilterChain()
     {
-        return new VmPipeFilterChain( type );
+        return new VmPipeFilterChain();
     }
     
     public ProtocolHandlerFilterChain getFilterChain()

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=158987&r2=158988
==============================================================================
--- 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 Thu Mar 24 20:50:47 2005
@@ -1,14 +1,12 @@
 package org.apache.mina.protocol.vmpipe;
 
-import org.apache.mina.common.FilterChainType;
 import org.apache.mina.protocol.AbstractProtocolHandlerFilterChain;
 import org.apache.mina.protocol.ProtocolSession;
 
 class VmPipeFilterChain extends AbstractProtocolHandlerFilterChain {
 
-    VmPipeFilterChain( FilterChainType type )
+    VmPipeFilterChain()
     {
-        super(type);
     }
 
     protected void doWrite(ProtocolSession session, Object message)

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=158987&r2=158988
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java Thu Mar 24 20:50:47 2005
@@ -21,7 +21,6 @@
 import java.io.IOException;
 import java.util.Set;
 
-import org.apache.mina.common.FilterChainType;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.io.IoHandler;
 import org.apache.mina.io.IoHandlerFilterChain;
@@ -56,11 +55,11 @@
      */
     void unbind( Service service );
 
-    IoHandlerFilterChain newIoFilterChain( TransportType transportType, FilterChainType chainType );
+    IoHandlerFilterChain newIoFilterChain( TransportType transportType );
     
     IoHandlerFilterChain getIoFilterChain( TransportType transportType );
     
-    ProtocolHandlerFilterChain newProtocolFilterChain( TransportType transportType, FilterChainType chainType );
+    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=158987&r2=158988
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java Thu Mar 24 20:50:47 2005
@@ -9,7 +9,6 @@
 import java.util.Iterator;
 import java.util.Set;
 
-import org.apache.mina.common.FilterChainType;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.io.IoAcceptor;
 import org.apache.mina.io.IoHandler;
@@ -118,16 +117,16 @@
         stopThreadPools();
     }
 
-    public IoHandlerFilterChain newIoFilterChain(TransportType transportType, FilterChainType chainType) {
-        return findIoAcceptor( transportType ).newFilterChain( chainType );
+    public IoHandlerFilterChain newIoFilterChain(TransportType transportType) {
+        return findIoAcceptor( transportType ).newFilterChain();
     }
 
     public IoHandlerFilterChain getIoFilterChain(TransportType transportType) {
         return findIoAcceptor( transportType ).getFilterChain();
     }
 
-    public ProtocolHandlerFilterChain newProtocolFilterChain(TransportType transportType, FilterChainType chainType) {
-        return findProtocolAcceptor( transportType ).newFilterChain( chainType );
+    public ProtocolHandlerFilterChain newProtocolFilterChain(TransportType transportType) {
+        return findProtocolAcceptor( transportType ).newFilterChain();
     }
 
     public ProtocolHandlerFilterChain getProtocolFilterChain(TransportType transportType) {

Modified: directory/network/trunk/src/test/org/apache/mina/io/AbstractBindTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/io/AbstractBindTest.java?view=diff&r1=158987&r2=158988
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/io/AbstractBindTest.java (original)
+++ directory/network/trunk/src/test/org/apache/mina/io/AbstractBindTest.java Thu Mar 24 20:50:47 2005
@@ -98,8 +98,7 @@
     {
         InetSocketAddress addr = new InetSocketAddress( port );
         EchoProtocolHandler handler = new EchoProtocolHandler();
-        // we test only 8192 times to avoid too many open files exception.
-        for( int i = 0; i < 8192; i++ ) 
+        for( int i = 0; i < 1024; i++ ) 
         {
             acceptor.unbind( addr );
             acceptor.bind( addr, handler );

Added: 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=auto&rev=158988
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/io/IoHandlerFilterChainTest.java (added)
+++ directory/network/trunk/src/test/org/apache/mina/io/IoHandlerFilterChainTest.java Thu Mar 24 20:50:47 2005
@@ -0,0 +1,97 @@
+package org.apache.mina.io;
+
+import java.net.SocketAddress;
+
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IdleStatus;
+import org.apache.mina.common.SessionConfig;
+import org.apache.mina.common.TransportType;
+
+import junit.framework.TestCase;
+
+// I'll use easymock to test AbstractIoHandlerFilterChain
+public class IoHandlerFilterChainTest extends TestCase {
+
+    private static class TestSession implements IoSession
+    {
+        private final IoHandlerFilterChain chain;
+        private final IoHandler handler;
+        
+        private TestSession( IoHandlerFilterChain chain, IoHandler handler )
+        {
+            this.chain = chain;
+            this.handler = handler;
+        }
+        
+        public IoHandler getHandler()
+        {
+            return handler;
+        }
+
+        public void close() {
+        }
+
+        public void write(ByteBuffer buf, Object marker) {
+            chain.filterWrite( null, this, buf, marker );
+        }
+
+        public Object getAttachment() {
+            return null;
+        }
+
+        public void setAttachment(Object attachment) {
+        }
+
+        public TransportType getTransportType() {
+            return null;
+        }
+
+        public boolean isConnected() {
+            return false;
+        }
+
+        public SessionConfig getConfig() {
+            return null;
+        }
+
+        public SocketAddress getRemoteAddress() {
+            return null;
+        }
+
+        public SocketAddress getLocalAddress() {
+            return null;
+        }
+
+        public long getReadBytes() {
+            return 0;
+        }
+
+        public long getWrittenBytes() {
+            return 0;
+        }
+
+        public long getLastIoTime() {
+            return 0;
+        }
+
+        public long getLastReadTime() {
+            return 0;
+        }
+
+        public long getLastWriteTime() {
+            return 0;
+        }
+
+        public boolean isIdle(IdleStatus status) {
+            return false;
+        }
+    }
+
+    private static class IoHandlerFilterChainImpl extends AbstractIoHandlerFilterChain
+    {
+        protected void doWrite(IoSession session, ByteBuffer buffer, Object marker)
+        {
+            session.getHandler().dataWritten( session, marker );
+        }
+    }
+}

Propchange: directory/network/trunk/src/test/org/apache/mina/io/IoHandlerFilterChainTest.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision



Mime
View raw message