directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r156130 - in incubator/directory/network/mina/trunk/src: examples/org/apache/mina/examples/echoserver/ examples/org/apache/mina/examples/netcat/ examples/org/apache/mina/examples/reverser/ examples/org/apache/mina/examples/sumup/ 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/ java/org/apache/mina/util/ test/org/apache/mina/examples/echoserver/ test/org/apache/mina/util/
Date Fri, 04 Mar 2005 04:10:18 GMT
Author: trustin
Date: Thu Mar  3 20:10:11 2005
New Revision: 156130

URL: http://svn.apache.org/viewcvs?view=rev&rev=156130
Log:
* Reverted FilterManagers to old linked list version.
* FilterManagers can now hide internal filters using 'hidden' property

Modified:
    incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java
    incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/netcat/Main.java
    incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/reverser/Main.java
    incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/sumup/Client.java
    incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/sumup/Server.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/IoHandlerFilter.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramConnector.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/ProtocolHandlerFilter.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/io/IoAdapter.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/util/IoHandlerFilterManager.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/util/ProtocolHandlerFilterManager.java
    incubator/directory/network/mina/trunk/src/test/org/apache/mina/examples/echoserver/Test.java
    incubator/directory/network/mina/trunk/src/test/org/apache/mina/util/IoHandlerFilterManagerTest.java
    incubator/directory/network/mina/trunk/src/test/org/apache/mina/util/ProtocolHandlerFilterManagerTest.java

Modified: incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java (original)
+++ incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java Thu Mar  3 20:10:11 2005
@@ -21,7 +21,6 @@
 import java.net.InetSocketAddress;
 
 import org.apache.mina.io.IoAcceptor;
-import org.apache.mina.io.IoHandlerFilter;
 import org.apache.mina.io.datagram.DatagramAcceptor;
 import org.apache.mina.io.filter.IoThreadPoolFilter;
 import org.apache.mina.io.socket.SocketAcceptor;
@@ -47,7 +46,7 @@
 
         // Add thread pool filter
         // MINA runs in a single thread if you don't add this filter.
-        acceptor.addFilter( IoHandlerFilter.MAX_PRIORITY, threadPoolFilter );
+        acceptor.addFilter( Integer.MAX_VALUE, threadPoolFilter );
 
         // Bind
         acceptor.bind( new InetSocketAddress( PORT ),
@@ -57,8 +56,7 @@
         IoAcceptor datagramAcceptor = new DatagramAcceptor();
 
         // Add thread pool filter
-        datagramAcceptor.addFilter( IoHandlerFilter.MAX_PRIORITY,
-                threadPoolFilter );
+        datagramAcceptor.addFilter( Integer.MAX_VALUE, threadPoolFilter );
 
         // Bind
         datagramAcceptor.bind( new InetSocketAddress( PORT ),

Modified: incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/netcat/Main.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/netcat/Main.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/netcat/Main.java (original)
+++ incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/netcat/Main.java Thu Mar  3 20:10:11 2005
@@ -20,7 +20,6 @@
 
 import java.net.InetSocketAddress;
 
-import org.apache.mina.io.IoHandlerFilter;
 import org.apache.mina.io.filter.IoThreadPoolFilter;
 import org.apache.mina.io.socket.SocketConnector;
 
@@ -47,8 +46,7 @@
 
         // Add I/O thread pool filter.
         // MINA runs in a single thread if you don't add this filter.
-        connector.addFilter( IoHandlerFilter.MAX_PRIORITY,
-                new IoThreadPoolFilter() );
+        connector.addFilter( Integer.MAX_VALUE, new IoThreadPoolFilter() );
 
         // Start communication.
         connector.connect( new InetSocketAddress( args[ 0 ], Integer

Modified: incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/reverser/Main.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/reverser/Main.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/reverser/Main.java (original)
+++ incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/reverser/Main.java Thu Mar  3 20:10:11 2005
@@ -20,10 +20,8 @@
 
 import java.net.InetSocketAddress;
 
-import org.apache.mina.io.IoHandlerFilter;
 import org.apache.mina.io.filter.IoThreadPoolFilter;
 import org.apache.mina.io.socket.SocketAcceptor;
-import org.apache.mina.protocol.ProtocolHandlerFilter;
 import org.apache.mina.protocol.filter.ProtocolThreadPoolFilter;
 import org.apache.mina.protocol.io.IoProtocolAcceptor;
 
@@ -55,10 +53,8 @@
                 new SocketAcceptor() );
 
         // Add both thread pool filters.
-        acceptor.getIoAcceptor().addFilter( IoHandlerFilter.MAX_PRIORITY,
-                ioThreadPoolFilter );
-        acceptor.addFilter( ProtocolHandlerFilter.MAX_PRIORITY,
-                protocolThreadPoolFilter );
+        acceptor.getIoAcceptor().addFilter( Integer.MAX_VALUE, ioThreadPoolFilter );
+        acceptor.addFilter( Integer.MAX_VALUE, protocolThreadPoolFilter );
 
         // Bind
         acceptor.bind( new InetSocketAddress( PORT ),

Modified: incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/sumup/Client.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/sumup/Client.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/sumup/Client.java (original)
+++ incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/sumup/Client.java Thu Mar  3 20:10:11 2005
@@ -6,10 +6,8 @@
 import java.io.IOException;
 import java.net.InetSocketAddress;
 
-import org.apache.mina.io.IoHandlerFilter;
 import org.apache.mina.io.filter.IoThreadPoolFilter;
 import org.apache.mina.io.socket.SocketConnector;
-import org.apache.mina.protocol.ProtocolHandlerFilter;
 import org.apache.mina.protocol.ProtocolProvider;
 import org.apache.mina.protocol.ProtocolSession;
 import org.apache.mina.protocol.filter.ProtocolThreadPoolFilter;
@@ -56,10 +54,8 @@
 
         IoProtocolConnector connector = new IoProtocolConnector(
                 new SocketConnector() );
-        connector.getIoConnector().addFilter( IoHandlerFilter.MAX_PRIORITY,
-                ioThreadPoolFilter );
-        connector.addFilter( ProtocolHandlerFilter.MAX_PRIORITY,
-                protocolThreadPoolFilter );
+        connector.getIoConnector().addFilter( Integer.MAX_VALUE, ioThreadPoolFilter );
+        connector.addFilter( Integer.MAX_VALUE, protocolThreadPoolFilter );
 
         ProtocolProvider protocolProvider = new ClientProtocolProvider(
                 values );

Modified: incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/sumup/Server.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/sumup/Server.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/sumup/Server.java (original)
+++ incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/sumup/Server.java Thu Mar  3 20:10:11 2005
@@ -5,10 +5,8 @@
 
 import java.net.InetSocketAddress;
 
-import org.apache.mina.io.IoHandlerFilter;
 import org.apache.mina.io.filter.IoThreadPoolFilter;
 import org.apache.mina.io.socket.SocketAcceptor;
-import org.apache.mina.protocol.ProtocolHandlerFilter;
 import org.apache.mina.protocol.filter.ProtocolThreadPoolFilter;
 import org.apache.mina.protocol.io.IoProtocolAcceptor;
 
@@ -37,10 +35,8 @@
         IoProtocolAcceptor acceptor = new IoProtocolAcceptor(
                 new SocketAcceptor() );
 
-        acceptor.getIoAcceptor().addFilter( IoHandlerFilter.MAX_PRIORITY,
-                ioThreadPoolFilter );
-        acceptor.addFilter( ProtocolHandlerFilter.MAX_PRIORITY,
-                protocolThreadPoolFilter );
+        acceptor.getIoAcceptor().addFilter( Integer.MAX_VALUE, ioThreadPoolFilter );
+        acceptor.addFilter( Integer.MAX_VALUE, protocolThreadPoolFilter );
 
         acceptor.bind( new InetSocketAddress( SERVER_PORT ),
                 new ServerProtocolProvider() );

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/IoHandlerFilter.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/IoHandlerFilter.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/IoHandlerFilter.java (original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/IoHandlerFilter.java Thu Mar  3 20:10:11 2005
@@ -48,12 +48,6 @@
  */
 public interface IoHandlerFilter
 {
-    /** The minimum priority */
-    static int MIN_PRIORITY = 0;
-
-    /** The maximum priority */
-    static int MAX_PRIORITY = 99;
-
     /**
      * Filters {@link IoHandler#sessionOpened(IoSession)} event.
      */

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java (original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java Thu Mar  3 20:10:11 2005
@@ -426,7 +426,7 @@
 
     public void addFilter( int priority, IoHandlerFilter filter )
     {
-        filterManager.addFilter( priority, filter );
+        filterManager.addFilter( priority, false, filter );
     }
 
     public void removeFilter( IoHandlerFilter filter )

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramConnector.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramConnector.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramConnector.java (original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramConnector.java Thu Mar  3 20:10:11 2005
@@ -423,7 +423,7 @@
 
     public void addFilter( int priority, IoHandlerFilter filter )
     {
-        filterManager.addFilter( priority, filter );
+        filterManager.addFilter( priority, false, filter );
     }
 
     public void removeFilter( IoHandlerFilter filter )

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java (original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java Thu Mar  3 20:10:11 2005
@@ -289,7 +289,7 @@
 
     public void addFilter( int priority, IoHandlerFilter filter )
     {
-        filterManager.addFilter( priority, filter );
+        filterManager.addFilter( priority, false, filter );
     }
 
     public void removeFilter( IoHandlerFilter filter )

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java (original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java Thu Mar  3 20:10:11 2005
@@ -284,7 +284,7 @@
 
     public void addFilter( int priority, IoHandlerFilter filter )
     {
-        filterManager.addFilter( priority, filter );
+        filterManager.addFilter( priority, false, filter );
 
     }
 

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/ProtocolHandlerFilter.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/ProtocolHandlerFilter.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/ProtocolHandlerFilter.java (original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/ProtocolHandlerFilter.java Thu Mar  3 20:10:11 2005
@@ -19,7 +19,6 @@
 package org.apache.mina.protocol;
 
 import org.apache.mina.common.IdleStatus;
-import org.apache.mina.io.IoHandlerFilter;
 
 /**
  * A filter which intercepts {@link ProtocolHandler} events like Servlet
@@ -46,12 +45,6 @@
  */
 public interface ProtocolHandlerFilter
 {
-    /** The minimum priority */
-    static int MIN_PRIORITY = IoHandlerFilter.MIN_PRIORITY;
-
-    /** The maximum priority */
-    static int MAX_PRIORITY = IoHandlerFilter.MAX_PRIORITY;
-
     /**
      * Filters {@link ProtocolHandler#sessionOpened(ProtocolSession)} event.
      */

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/io/IoAdapter.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/io/IoAdapter.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/io/IoAdapter.java (original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/io/IoAdapter.java Thu Mar  3 20:10:11 2005
@@ -70,7 +70,7 @@
      */
     public void addFilter( int priority, ProtocolHandlerFilter filter )
     {
-        filterManager.addFilter( priority, filter );
+        filterManager.addFilter( priority, false, filter );
     }
 
     /**

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java (original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java Thu Mar  3 20:10:11 2005
@@ -26,16 +26,14 @@
 {
     static final Map boundHandlers = new HashMap();
 
-    private final ProtocolHandlerFilterManager filterManager = new ProtocolHandlerFilterManager(
-            ProtocolHandlerFilter.MIN_PRIORITY - 1,
-            ProtocolHandlerFilter.MAX_PRIORITY );
+    private final ProtocolHandlerFilterManager filterManager = new ProtocolHandlerFilterManager();
 
     /**
      * Creates a new instance.
      */
     public VmPipeAcceptor()
     {
-        filterManager.addFilter( -1, new VmPipeFilter() );
+        filterManager.addFilter( Integer.MIN_VALUE, true, new VmPipeFilter() );
     }
 
     public void bind( SocketAddress address, ProtocolProvider protocolProvider )
@@ -74,7 +72,7 @@
 
     public void addFilter( int priority, ProtocolHandlerFilter filter )
     {
-        filterManager.addFilter( priority, filter );
+        filterManager.addFilter( priority, false, filter );
     }
 
     public void removeFilter( ProtocolHandlerFilter filter )

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java (original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java Thu Mar  3 20:10:11 2005
@@ -30,12 +30,12 @@
      */
     public VmPipeConnector()
     {
-        filterManager.addFilter( Integer.MIN_VALUE - 1, new VmPipeFilter() );
+        filterManager.addFilter( Integer.MIN_VALUE - 1, true, new VmPipeFilter() );
     }
 
     public void addFilter( int priority, ProtocolHandlerFilter filter )
     {
-        filterManager.addFilter( priority, filter );
+        filterManager.addFilter( priority, false, filter );
     }
 
     public void removeFilter( ProtocolHandlerFilter filter )

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java (original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java Thu Mar  3 20:10:11 2005
@@ -55,16 +55,11 @@
 
     public SimpleServiceRegistry() throws IOException
     {
-        socketIoAcceptor.addFilter( IoHandlerFilter.MAX_PRIORITY,
-                ioThreadPoolFilter );
-        datagramIoAcceptor.addFilter( IoHandlerFilter.MAX_PRIORITY,
-                ioThreadPoolFilter );
-        socketProtocolAcceptor.addFilter( ProtocolHandlerFilter.MAX_PRIORITY,
-                protocolThreadPoolFilter );
-        datagramProtocolAcceptor.addFilter(
-                ProtocolHandlerFilter.MAX_PRIORITY, protocolThreadPoolFilter );
-        vmPipeAcceptor.addFilter( ProtocolHandlerFilter.MAX_PRIORITY,
-                protocolThreadPoolFilter );
+        socketIoAcceptor.addFilter( Integer.MAX_VALUE, ioThreadPoolFilter );
+        datagramIoAcceptor.addFilter( Integer.MAX_VALUE, ioThreadPoolFilter );
+        socketProtocolAcceptor.addFilter( Integer.MAX_VALUE, protocolThreadPoolFilter );
+        datagramProtocolAcceptor.addFilter( Integer.MAX_VALUE, protocolThreadPoolFilter );
+        vmPipeAcceptor.addFilter( Integer.MAX_VALUE, protocolThreadPoolFilter );
     }
 
     public synchronized void bind( Service service, IoHandler ioHandler )

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/util/IoHandlerFilterManager.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/util/IoHandlerFilterManager.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/util/IoHandlerFilterManager.java (original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/util/IoHandlerFilterManager.java Thu Mar  3 20:10:11 2005
@@ -19,7 +19,6 @@
 package org.apache.mina.util;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
 import org.apache.mina.common.ByteBuffer;
@@ -86,88 +85,96 @@
         }
     };
 
-    private final Entry[] entries;
+    private Entry head = new Entry( null, null, Integer.MIN_VALUE,
+            FINAL_FILTER, true );
 
-    private final int minPriority;
-
-    private final int maxPriority;
-
-    public IoHandlerFilterManager( int minPriority, int maxPriority )
-    {
-        this.minPriority = minPriority;
-        this.maxPriority = maxPriority;
-
-        entries = new Entry[ maxPriority - minPriority + 2 ];
-        entries[ 0 ] = new Entry( minPriority - 1, FINAL_FILTER );
-    }
+    private final Entry tail = head;
 
     public IoHandlerFilterManager()
     {
-        this( IoHandlerFilter.MIN_PRIORITY, IoHandlerFilter.MAX_PRIORITY );
     }
 
-    public synchronized void addFilter( int priority, IoHandlerFilter filter )
+    public synchronized void addFilter( int priority, boolean hidden, IoHandlerFilter filter )
     {
-        if( priority < minPriority || priority > maxPriority )
+        Entry e = head;
+        Entry prevEntry = null;
+        for( ;; )
         {
-            throw new IllegalArgumentException( "priority: " + priority
-                    + " (should be " + minPriority + '~' + maxPriority + ')' );
+            if( e.priority < priority )
+            {
+                Entry newEntry = new Entry( prevEntry, e, priority, filter, hidden );
+                if( prevEntry == null )
+                {
+                    head = newEntry;
+                }
+                else
+                {
+                    prevEntry.nextEntry.prevEntry = newEntry;
+                    prevEntry.nextEntry = newEntry;
+                }
+                break;
+            }
+            else if( e.priority == priority )
+            {
+                throw new IllegalArgumentException(
+                        "Other filter is registered with priority "
+                                                                                                + priority
+                                                                                                + " already." );
+            }
+            prevEntry = e;
+            e = e.nextEntry;
         }
+    }
 
-        if( entries[ priority - minPriority + 1 ] == null )
-        {
-            entries[ priority - minPriority + 1 ] = new Entry( priority,
-                    filter );
-        }
-        else
+    public synchronized void removeFilter( IoHandlerFilter filter )
+    {
+        if( filter == tail )
         {
             throw new IllegalArgumentException(
-                    "Other filter is registered with priority " + priority
-                            + " already." );
+                    "Cannot remove the internal filter." );
         }
-    }
 
-    public synchronized boolean removeFilter( IoHandlerFilter filter )
-    {
-        for( int i = entries.length - 1; i > 0; i -- )
+        Entry e = head;
+        Entry prevEntry = null;
+        for( ;; )
         {
-            if( entries[ i ] != null && filter == entries[ i ].filter )
+            if( e.nextEntry == null )
             {
-                entries[ i ] = null;
-                return true;
+                break;
             }
+            else if( e.filter == filter )
+            {
+                if( prevEntry == null )
+                {
+                    // e is head
+                    e.nextEntry.prevEntry = null;
+                    head = e.nextEntry;
+                }
+                else
+                {
+                    e.nextEntry.prevEntry = prevEntry;
+                    prevEntry.nextEntry = e.nextEntry;
+                }
+                break;
+            }
+            prevEntry = e;
+            e = e.nextEntry;
         }
-
-        return false;
     }
 
     public synchronized void removeAllFilters()
     {
-        Arrays.fill( entries, 1, entries.length, null );
-    }
-
-    private Entry findNextEntry( int currentPriority )
-    {
-        currentPriority -= minPriority;
-
-        for( ; currentPriority >= 0; currentPriority -- )
-        {
-            Entry e = entries[ currentPriority ];
-            if( e != null )
-            {
-                return e;
-            }
-        }
-
-        throw new InternalError();
+        tail.prevEntry = null;
+        tail.nextEntry = null;
+        head = tail;
     }
 
     public void fireSessionOpened( IoSession session )
     {
-        Entry entry = findNextEntry( maxPriority + 1 );
+        Entry head = this.head;
         try
         {
-            entry.filter.sessionOpened( entry.nextHandler, session );
+            head.filter.sessionOpened( head.nextHandler, session );
         }
         catch( Throwable e )
         {
@@ -177,10 +184,10 @@
 
     public void fireSessionClosed( IoSession session )
     {
-        Entry entry = findNextEntry( maxPriority + 1 );
+        Entry head = this.head;
         try
         {
-            entry.filter.sessionClosed( entry.nextHandler, session );
+            head.filter.sessionClosed( head.nextHandler, session );
         }
         catch( Throwable e )
         {
@@ -190,10 +197,10 @@
 
     public void fireSessionIdle( IoSession session, IdleStatus status )
     {
-        Entry entry = findNextEntry( maxPriority + 1 );
+        Entry head = this.head;
         try
         {
-            entry.filter.sessionIdle( entry.nextHandler, session, status );
+            head.filter.sessionIdle( head.nextHandler, session, status );
         }
         catch( Throwable e )
         {
@@ -203,10 +210,10 @@
 
     public void fireDataRead( IoSession session, ByteBuffer buf )
     {
-        Entry entry = findNextEntry( maxPriority + 1 );
+        Entry head = this.head;
         try
         {
-            entry.filter.dataRead( entry.nextHandler, session, buf );
+            head.filter.dataRead( head.nextHandler, session, buf );
         }
         catch( Throwable e )
         {
@@ -216,10 +223,10 @@
 
     public void fireDataWritten( IoSession session, Object marker )
     {
-        Entry entry = findNextEntry( maxPriority + 1 );
+        Entry head = this.head;
         try
         {
-            entry.filter.dataWritten( entry.nextHandler, session, marker );
+            head.filter.dataWritten( head.nextHandler, session, marker );
         }
         catch( Throwable e )
         {
@@ -229,10 +236,10 @@
 
     public void fireExceptionCaught( IoSession session, Throwable cause )
     {
-        Entry entry = findNextEntry( maxPriority + 1 );
+        Entry head = this.head;
         try
         {
-            entry.filter.exceptionCaught( entry.nextHandler, session, cause );
+            head.filter.exceptionCaught( head.nextHandler, session, cause );
         }
         catch( Throwable e )
         {
@@ -243,15 +250,10 @@
     public void write( IoSession session, WriteCommand cmd, ByteBuffer buf,
                       Object marker )
     {
+        Entry e = tail;
         ByteBuffer newBuf;
-        for( int i = 0; i < entries.length; i ++ )
+        do
         {
-            Entry e = entries[ i ];
-            if( e == null )
-            {
-                continue;
-            }
-
             newBuf = e.filter.filterWrite( session, buf );
             if( buf != newBuf )
             {
@@ -264,53 +266,81 @@
                 return;
             }
             buf = newBuf;
+            e = e.prevEntry;
         }
+        while( e != null );
 
         cmd.execute( buf, marker );
     }
 
     public List getAllFilters()
     {
-        List list = new ArrayList( maxPriority - minPriority + 1 );
-        for( int priority = maxPriority + 1;; )
+        List list = new ArrayList();
+        Entry e = head;
+        do
         {
-            Entry e = findNextEntry( priority );
-            if( e.priority < minPriority )
+            if( !e.hidden )
             {
-                break;
+                list.add( e.filter );
             }
+            e = e.nextEntry;
+        }
+        while( e != null );
 
-            priority = e.priority;
-            list.add( e.filter );
+        return list;
+    }
+
+    public List getAllFiltersReversed()
+    {
+        List list = new ArrayList();
+        Entry e = tail;
+        do
+        {
+            if( !e.hidden )
+            {
+                list.add( e.filter );
+            }
+            e = e.prevEntry;
         }
+        while( e != null );
 
         return list;
+
     }
 
     private class Entry
     {
+        private Entry prevEntry;
+
+        private Entry nextEntry;
+
         private final int priority;
+        
+        private final boolean hidden;
 
         private final IoHandlerFilter filter;
 
         private final IoHandler nextHandler;
 
-        private Entry( int priority, IoHandlerFilter filter )
+        private Entry( Entry prevEntry, Entry nextEntry, int priority,
+                      IoHandlerFilter filter, boolean hidden )
         {
             if( filter == null )
                 throw new NullPointerException( "filter" );
+            this.prevEntry = prevEntry;
+            this.nextEntry = nextEntry;
             this.priority = priority;
             this.filter = filter;
+            this.hidden = hidden;
             this.nextHandler = new IoHandler()
             {
 
                 public void sessionOpened( IoSession session )
                 {
-                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        nextEntry.filter.sessionOpened(
-                                nextEntry.nextHandler, session );
+                        Entry.this.nextEntry.filter.sessionOpened(
+                                Entry.this.nextEntry.nextHandler, session );
                     }
                     catch( Throwable e )
                     {
@@ -321,11 +351,10 @@
 
                 public void sessionClosed( IoSession session )
                 {
-                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        nextEntry.filter.sessionClosed(
-                                nextEntry.nextHandler, session );
+                        Entry.this.nextEntry.filter.sessionClosed(
+                                Entry.this.nextEntry.nextHandler, session );
                     }
                     catch( Throwable e )
                     {
@@ -336,11 +365,11 @@
 
                 public void sessionIdle( IoSession session, IdleStatus status )
                 {
-                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        nextEntry.filter.sessionIdle( nextEntry.nextHandler,
-                                session, status );
+                        Entry.this.nextEntry.filter.sessionIdle(
+                                Entry.this.nextEntry.nextHandler, session,
+                                status );
                     }
                     catch( Throwable e )
                     {
@@ -352,11 +381,11 @@
                 public void exceptionCaught( IoSession session,
                                             Throwable cause )
                 {
-                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        nextEntry.filter.exceptionCaught(
-                                nextEntry.nextHandler, session, cause );
+                        Entry.this.nextEntry.filter.exceptionCaught(
+                                Entry.this.nextEntry.nextHandler, session,
+                                cause );
                     }
                     catch( Throwable e )
                     {
@@ -366,11 +395,11 @@
 
                 public void dataRead( IoSession session, ByteBuffer buf )
                 {
-                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        nextEntry.filter.dataRead( nextEntry.nextHandler,
-                                session, buf );
+                        Entry.this.nextEntry.filter.dataRead(
+                                Entry.this.nextEntry.nextHandler, session,
+                                buf );
                     }
                     catch( Throwable e )
                     {
@@ -381,11 +410,11 @@
 
                 public void dataWritten( IoSession session, Object marker )
                 {
-                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        nextEntry.filter.dataWritten( nextEntry.nextHandler,
-                                session, marker );
+                        Entry.this.nextEntry.filter.dataWritten(
+                                Entry.this.nextEntry.nextHandler, session,
+                                marker );
                     }
                     catch( Throwable e )
                     {

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/util/ProtocolHandlerFilterManager.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/util/ProtocolHandlerFilterManager.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/util/ProtocolHandlerFilterManager.java (original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/util/ProtocolHandlerFilterManager.java Thu Mar  3 20:10:11 2005
@@ -19,7 +19,6 @@
 package org.apache.mina.util;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
 import org.apache.mina.common.IdleStatus;
@@ -80,89 +79,96 @@
         }
     };
 
-    private final Entry[] entries;
+    private Entry head = new Entry( null, null, Integer.MIN_VALUE,
+                                    FINAL_FILTER, true );
 
-    private final int minPriority;
-
-    private final int maxPriority;
-
-    public ProtocolHandlerFilterManager( int minPriority, int maxPriority )
-    {
-        this.minPriority = minPriority;
-        this.maxPriority = maxPriority;
-
-        entries = new Entry[ maxPriority - minPriority + 2 ];
-        entries[ 0 ] = new Entry( minPriority - 1, FINAL_FILTER );
-    }
+    private Entry tail = head;
 
     public ProtocolHandlerFilterManager()
     {
-        this( ProtocolHandlerFilter.MIN_PRIORITY,
-                ProtocolHandlerFilter.MAX_PRIORITY );
     }
 
-    public synchronized void addFilter( int priority,
+    public synchronized void addFilter( int priority, boolean hidden,
                                        ProtocolHandlerFilter filter )
     {
-        if( priority < minPriority || priority > maxPriority )
+        Entry e = head;
+        Entry prevEntry = null;
+        for( ;; )
         {
-            throw new IllegalArgumentException( "priority: " + priority
-                    + " (should be " + minPriority + '~' + maxPriority + ')' );
+            if( e.priority < priority )
+            {
+                Entry newEntry = new Entry( prevEntry, e, priority, filter, hidden );
+                if( prevEntry == null )
+                {
+                    head = newEntry;
+                }
+                else
+                {
+                    prevEntry.nextEntry.prevEntry = newEntry;
+                    prevEntry.nextEntry = newEntry;
+                }
+                break;
+            }
+            else if( e.priority == priority )
+            {
+                throw new IllegalArgumentException(
+                                                    "Other filter is registered with priority "
+                                                                                                                                                                                                                + priority
+                                                                                                                                                                                                                + " already." );
+            }
+            prevEntry = e;
+            e = e.nextEntry;
         }
+    }
 
-        if( entries[ priority - minPriority + 1 ] == null )
-        {
-            entries[ priority - minPriority + 1 ] = new Entry( priority, filter );
-        }
-        else
+    public synchronized void removeFilter( ProtocolHandlerFilter filter )
+    {
+        if( filter == tail )
         {
             throw new IllegalArgumentException(
-                    "Other filter is registered with priority " + priority
-                            + " already." );
+                    "Cannot remove the internal filter.");
         }
-    }
 
-    public synchronized boolean removeFilter( ProtocolHandlerFilter filter )
-    {
-        for( int i = entries.length - 1; i > 0; i -- )
+        Entry e = head;
+        Entry prevEntry = null;
+        for( ;; )
         {
-            if( entries[ i ] != null && filter == entries[ i ].filter )
+            if( e.nextEntry == null )
             {
-                entries[ i ] = null;
-                return true;
+                break;
             }
-        }
-
-        return false;
-    }
-
-    public synchronized void removeAllFilters()
-    {
-        Arrays.fill( entries, 1, entries.length, null );
-    }
-
-    private Entry findNextEntry( int currentPriority )
-    {
-        currentPriority -= minPriority;
-
-        for( ; currentPriority >= 0; currentPriority -- )
-        {
-            Entry e = entries[ currentPriority ];
-            if( e != null )
+            else if( e.filter == filter )
             {
-                return e;
+                if( prevEntry == null )
+                {
+                    // e is head
+                    e.nextEntry.prevEntry = null;
+                    head = e.nextEntry;
+                }
+                else
+                {
+                    e.nextEntry.prevEntry = prevEntry;
+                    prevEntry.nextEntry = e.nextEntry;
+                }
+                break;
             }
+            prevEntry = e;
+            e = e.nextEntry;
         }
+    }
 
-        throw new InternalError();
+    public synchronized void removeAllFilters() {
+        tail.prevEntry = null;
+        tail.nextEntry = null;
+        head = tail;
     }
 
     public void fireSessionOpened( ProtocolSession session )
     {
-        Entry entry = findNextEntry( maxPriority + 1 );
+        Entry head = this.head;
         try
         {
-            entry.filter.sessionOpened( entry.nextHandler, session );
+            head.filter.sessionOpened( head.nextHandler, session );
         }
         catch( Throwable e )
         {
@@ -172,10 +178,10 @@
 
     public void fireSessionClosed( ProtocolSession session )
     {
-        Entry entry = findNextEntry( maxPriority + 1 );
+        Entry head = this.head;
         try
         {
-            entry.filter.sessionClosed( entry.nextHandler, session );
+            head.filter.sessionClosed( head.nextHandler, session );
         }
         catch( Throwable e )
         {
@@ -185,10 +191,10 @@
 
     public void fireSessionIdle( ProtocolSession session, IdleStatus status )
     {
-        Entry entry = findNextEntry( maxPriority + 1 );
+        Entry head = this.head;
         try
         {
-            entry.filter.sessionIdle( entry.nextHandler, session, status );
+            head.filter.sessionIdle( head.nextHandler, session, status );
         }
         catch( Throwable e )
         {
@@ -198,10 +204,10 @@
 
     public void fireMessageSent( ProtocolSession session, Object message )
     {
-        Entry entry = findNextEntry( maxPriority + 1 );
+        Entry head = this.head;
         try
         {
-            entry.filter.messageSent( entry.nextHandler, session, message );
+            head.filter.messageSent( head.nextHandler, session, message );
         }
         catch( Throwable e )
         {
@@ -211,11 +217,10 @@
 
     public void fireMessageReceived( ProtocolSession session, Object message )
     {
-        Entry entry = findNextEntry( maxPriority + 1 );
+        Entry head = this.head;
         try
         {
-            entry.filter
-                    .messageReceived( entry.nextHandler, session, message );
+            head.filter.messageReceived( head.nextHandler, session, message );
         }
         catch( Throwable e )
         {
@@ -225,10 +230,10 @@
 
     public void fireExceptionCaught( ProtocolSession session, Throwable cause )
     {
-        Entry entry = findNextEntry( maxPriority + 1 );
+        Entry head = this.head;
         try
         {
-            entry.filter.exceptionCaught( entry.nextHandler, session, cause );
+            head.filter.exceptionCaught( head.nextHandler, session, cause );
         }
         catch( Throwable e )
         {
@@ -236,116 +241,140 @@
         }
     }
 
-    public void write( ProtocolSession session, WriteCommand cmd,
-                      Object message )
+    public void write( ProtocolSession session, WriteCommand cmd, Object message )
     {
-        for( int i = 0; i < entries.length; i ++ )
+        Entry e = tail;
+        do
         {
-            Entry e = entries[ i ];
-            if( e == null )
-            {
-                continue;
-            }
-
             message = e.filter.filterWrite( session, message );
             if( message == null )
             {
                 return;
             }
+
+            e = e.prevEntry;
         }
+        while( e != null );
 
         cmd.execute( message );
     }
 
     public List getAllFilters()
     {
-        List list = new ArrayList( maxPriority - minPriority + 1 );
-        for( int priority = maxPriority + 1;; )
+        List list = new ArrayList();
+        Entry e = head;
+        do
         {
-            Entry e = findNextEntry( priority );
-            if( e.priority < minPriority )
+            if( !e.hidden )
             {
-                break;
+                list.add( e.filter );
             }
+            e = e.nextEntry;
+        }
+        while( e != null );
+
+        return list;
+    }
 
-            priority = e.priority;
-            list.add( e.filter );
+    public List getAllFiltersReversed()
+    {
+        List list = new ArrayList();
+        Entry e = tail;
+        do
+        {
+            if( !e.hidden )
+            {
+                list.add( e.filter );
+            }
+            e = e.prevEntry;
         }
+        while( e != null );
 
         return list;
     }
 
     private class Entry
     {
+        private Entry prevEntry;
+
+        private Entry nextEntry;
+
         private final int priority;
+        
+        private final boolean hidden;
 
         private final ProtocolHandlerFilter filter;
 
         private final ProtocolHandler nextHandler;
 
-        private Entry( int priority, ProtocolHandlerFilter filter )
+        private Entry( Entry prevEntry, Entry nextEntry, int priority,
+                      ProtocolHandlerFilter filter, boolean hidden )
         {
             if( filter == null )
                 throw new NullPointerException( "filter" );
+            this.prevEntry = prevEntry;
+            this.nextEntry = nextEntry;
             this.priority = priority;
             this.filter = filter;
+            this.hidden = hidden;
             this.nextHandler = new ProtocolHandler()
             {
 
                 public void sessionOpened( ProtocolSession session )
                 {
-                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        nextEntry.filter.sessionOpened(
-                                nextEntry.nextHandler, session );
+                        Entry.this.nextEntry.filter
+                                .sessionOpened(
+                                                Entry.this.nextEntry.nextHandler,
+                                                session );
                     }
                     catch( Throwable e )
                     {
-                        ProtocolHandlerFilterManager.this
-                                .fireExceptionCaught( session, e );
+                        ProtocolHandlerFilterManager.this.fireExceptionCaught( session, e );
                     }
                 }
 
                 public void sessionClosed( ProtocolSession session )
                 {
-                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        nextEntry.filter.sessionClosed(
-                                nextEntry.nextHandler, session );
+                        Entry.this.nextEntry.filter
+                                .sessionClosed(
+                                                Entry.this.nextEntry.nextHandler,
+                                                session );
                     }
                     catch( Throwable e )
                     {
-                        ProtocolHandlerFilterManager.this
-                                .fireExceptionCaught( session, e );
+                        ProtocolHandlerFilterManager.this.fireExceptionCaught( session, e );
                     }
                 }
 
                 public void sessionIdle( ProtocolSession session,
                                         IdleStatus status )
                 {
-                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        nextEntry.filter.sessionIdle( nextEntry.nextHandler,
-                                session, status );
+                        Entry.this.nextEntry.filter
+                                .sessionIdle(
+                                              Entry.this.nextEntry.nextHandler,
+                                              session, status );
                     }
                     catch( Throwable e )
                     {
-                        ProtocolHandlerFilterManager.this
-                                .fireExceptionCaught( session, e );
+                        ProtocolHandlerFilterManager.this.fireExceptionCaught( session, e );
                     }
                 }
 
                 public void exceptionCaught( ProtocolSession session,
                                             Throwable cause )
                 {
-                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        nextEntry.filter.exceptionCaught(
-                                nextEntry.nextHandler, session, cause );
+                        Entry.this.nextEntry.filter
+                                .exceptionCaught(
+                                                  Entry.this.nextEntry.nextHandler,
+                                                  session, cause );
                     }
                     catch( Throwable e )
                     {
@@ -356,32 +385,32 @@
                 public void messageReceived( ProtocolSession session,
                                             Object message )
                 {
-                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        nextEntry.filter.messageReceived(
-                                nextEntry.nextHandler, session, message );
+                        Entry.this.nextEntry.filter
+                                .messageReceived(
+                                                  Entry.this.nextEntry.nextHandler,
+                                                  session, message );
                     }
                     catch( Throwable e )
                     {
-                        ProtocolHandlerFilterManager.this
-                                .fireExceptionCaught( session, e );
+                        ProtocolHandlerFilterManager.this.fireExceptionCaught( session, e );
                     }
                 }
 
                 public void messageSent( ProtocolSession session,
                                         Object message )
                 {
-                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        nextEntry.filter.messageSent( nextEntry.nextHandler,
-                                session, message );
+                        Entry.this.nextEntry.filter
+                                .messageSent(
+                                              Entry.this.nextEntry.nextHandler,
+                                              session, message );
                     }
                     catch( Throwable e )
                     {
-                        ProtocolHandlerFilterManager.this
-                                .fireExceptionCaught( session, e );
+                        ProtocolHandlerFilterManager.this.fireExceptionCaught( session, e );
                     }
                 }
             };
@@ -392,4 +421,4 @@
     {
         void execute( Object message );
     }
-}
+}
\ No newline at end of file

Modified: incubator/directory/network/mina/trunk/src/test/org/apache/mina/examples/echoserver/Test.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/test/org/apache/mina/examples/echoserver/Test.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/test/org/apache/mina/examples/echoserver/Test.java (original)
+++ incubator/directory/network/mina/trunk/src/test/org/apache/mina/examples/echoserver/Test.java Thu Mar  3 20:10:11 2005
@@ -108,10 +108,8 @@
         threadPoolFilter = new IoThreadPoolFilter();
         threadPoolFilter.start();
 
-        acceptor
-                .addFilter( IoThreadPoolFilter.MAX_PRIORITY, threadPoolFilter );
-        datagramAcceptor.addFilter( IoThreadPoolFilter.MAX_PRIORITY,
-                threadPoolFilter );
+        acceptor.addFilter( Integer.MAX_VALUE, threadPoolFilter );
+        datagramAcceptor.addFilter( Integer.MAX_VALUE, threadPoolFilter );
     }
 
     protected void tearDown() throws Exception

Modified: incubator/directory/network/mina/trunk/src/test/org/apache/mina/util/IoHandlerFilterManagerTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/test/org/apache/mina/util/IoHandlerFilterManagerTest.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/test/org/apache/mina/util/IoHandlerFilterManagerTest.java (original)
+++ incubator/directory/network/mina/trunk/src/test/org/apache/mina/util/IoHandlerFilterManagerTest.java Thu Mar  3 20:10:11 2005
@@ -26,20 +26,25 @@
     private IoHandlerFilterImpl filterD;
 
     private IoHandlerFilterImpl filterE;
+    
+    private IoHandlerFilterImpl filterX;
 
     public void setUp()
     {
-        manager = new IoHandlerFilterManager(-10, 10);
+        manager = new IoHandlerFilterManager();
         filterA = new IoHandlerFilterImpl( 'A' );
         filterB = new IoHandlerFilterImpl( 'B' );
         filterC = new IoHandlerFilterImpl( 'C' );
         filterD = new IoHandlerFilterImpl( 'D' );
         filterE = new IoHandlerFilterImpl( 'E' );
-        manager.addFilter( 0, filterA );
-        manager.addFilter( -2, filterB );
-        manager.addFilter( 2, filterC );
-        manager.addFilter( -1, filterD );
-        manager.addFilter( 1, filterE );
+        filterX = new IoHandlerFilterImpl( 'X' );
+        
+        manager.addFilter( 0, false, filterA );
+        manager.addFilter( -2, false, filterB );
+        manager.addFilter( 2, false, filterC );
+        manager.addFilter( -1, false, filterD );
+        manager.addFilter( 1, false, filterE );
+        manager.addFilter( 3, true, filterX );
     }
 
     public void testAdd()
@@ -52,6 +57,14 @@
         assertSame( filterA, list.get( 2 ) );
         assertSame( filterD, list.get( 3 ) );
         assertSame( filterB, list.get( 4 ) );
+
+        list = manager.getAllFiltersReversed();
+        assertEquals( 5, list.size() );
+        assertSame( filterC, list.get( 4 ) );
+        assertSame( filterE, list.get( 3 ) );
+        assertSame( filterA, list.get( 2 ) );
+        assertSame( filterD, list.get( 1 ) );
+        assertSame( filterB, list.get( 0 ) );
     }
 
     public void testRemoveFirst()
@@ -65,6 +78,13 @@
         assertSame( filterA, list.get( 1 ) );
         assertSame( filterD, list.get( 2 ) );
         assertSame( filterB, list.get( 3 ) );
+
+        list = manager.getAllFiltersReversed();
+        assertEquals( 4, list.size() );
+        assertSame( filterE, list.get( 3 ) );
+        assertSame( filterA, list.get( 2 ) );
+        assertSame( filterD, list.get( 1 ) );
+        assertSame( filterB, list.get( 0 ) );
     }
 
     public void testRemoveLast()
@@ -78,6 +98,13 @@
         assertSame( filterE, list.get( 1 ) );
         assertSame( filterA, list.get( 2 ) );
         assertSame( filterD, list.get( 3 ) );
+
+        list = manager.getAllFiltersReversed();
+        assertEquals( 4, list.size() );
+        assertSame( filterC, list.get( 3 ) );
+        assertSame( filterE, list.get( 2 ) );
+        assertSame( filterA, list.get( 1 ) );
+        assertSame( filterD, list.get( 0 ) );
     }
 
     public void testRemoveMiddle()
@@ -91,12 +118,19 @@
         assertSame( filterE, list.get( 1 ) );
         assertSame( filterD, list.get( 2 ) );
         assertSame( filterB, list.get( 3 ) );
+
+        list = manager.getAllFiltersReversed();
+        assertEquals( 4, list.size() );
+        assertSame( filterC, list.get( 3 ) );
+        assertSame( filterE, list.get( 2 ) );
+        assertSame( filterD, list.get( 1 ) );
+        assertSame( filterB, list.get( 0 ) );
     }
     
     public void removeAll()
     {
-    	manager.removeAllFilters();
-    	assertEquals( 0, manager.getAllFilters().size() );
+        manager.removeAllFilters();
+        assertEquals( 0, manager.getAllFilters().size() );
     }
 
     public static void main( String[] args )

Modified: incubator/directory/network/mina/trunk/src/test/org/apache/mina/util/ProtocolHandlerFilterManagerTest.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/test/org/apache/mina/util/ProtocolHandlerFilterManagerTest.java?view=diff&r1=156129&r2=156130
==============================================================================
--- incubator/directory/network/mina/trunk/src/test/org/apache/mina/util/ProtocolHandlerFilterManagerTest.java (original)
+++ incubator/directory/network/mina/trunk/src/test/org/apache/mina/util/ProtocolHandlerFilterManagerTest.java Thu Mar  3 20:10:11 2005
@@ -26,20 +26,25 @@
     private ProtocolHandlerFilterImpl filterD;
 
     private ProtocolHandlerFilterImpl filterE;
+    
+    private ProtocolHandlerFilterImpl filterX;
 
     public void setUp()
     {
-        manager = new ProtocolHandlerFilterManager(-10, 10);
+        manager = new ProtocolHandlerFilterManager();
         filterA = new ProtocolHandlerFilterImpl( 'A' );
         filterB = new ProtocolHandlerFilterImpl( 'B' );
         filterC = new ProtocolHandlerFilterImpl( 'C' );
         filterD = new ProtocolHandlerFilterImpl( 'D' );
         filterE = new ProtocolHandlerFilterImpl( 'E' );
-        manager.addFilter( 0, filterA );
-        manager.addFilter( -2, filterB );
-        manager.addFilter( 2, filterC );
-        manager.addFilter( -1, filterD );
-        manager.addFilter( 1, filterE );
+        filterX = new ProtocolHandlerFilterImpl( 'X' );
+        
+        manager.addFilter( 0, false, filterA );
+        manager.addFilter( -2, false, filterB );
+        manager.addFilter( 2, false, filterC );
+        manager.addFilter( -1, false, filterD );
+        manager.addFilter( 1, false, filterE );
+        manager.addFilter( 3, true, filterX );
     }
 
     public void testAdd()
@@ -52,6 +57,14 @@
         assertSame( filterA, list.get( 2 ) );
         assertSame( filterD, list.get( 3 ) );
         assertSame( filterB, list.get( 4 ) );
+
+        list = manager.getAllFiltersReversed();
+        assertEquals( 5, list.size() );
+        assertSame( filterC, list.get( 4 ) );
+        assertSame( filterE, list.get( 3 ) );
+        assertSame( filterA, list.get( 2 ) );
+        assertSame( filterD, list.get( 1 ) );
+        assertSame( filterB, list.get( 0 ) );
     }
 
     public void testRemoveFirst()
@@ -65,6 +78,13 @@
         assertSame( filterA, list.get( 1 ) );
         assertSame( filterD, list.get( 2 ) );
         assertSame( filterB, list.get( 3 ) );
+
+        list = manager.getAllFiltersReversed();
+        assertEquals( 4, list.size() );
+        assertSame( filterE, list.get( 3 ) );
+        assertSame( filterA, list.get( 2 ) );
+        assertSame( filterD, list.get( 1 ) );
+        assertSame( filterB, list.get( 0 ) );
     }
 
     public void testRemoveLast()
@@ -78,6 +98,13 @@
         assertSame( filterE, list.get( 1 ) );
         assertSame( filterA, list.get( 2 ) );
         assertSame( filterD, list.get( 3 ) );
+
+        list = manager.getAllFiltersReversed();
+        assertEquals( 4, list.size() );
+        assertSame( filterC, list.get( 3 ) );
+        assertSame( filterE, list.get( 2 ) );
+        assertSame( filterA, list.get( 1 ) );
+        assertSame( filterD, list.get( 0 ) );
     }
 
     public void testRemoveMiddle()
@@ -91,12 +118,19 @@
         assertSame( filterE, list.get( 1 ) );
         assertSame( filterD, list.get( 2 ) );
         assertSame( filterB, list.get( 3 ) );
+
+        list = manager.getAllFiltersReversed();
+        assertEquals( 4, list.size() );
+        assertSame( filterC, list.get( 3 ) );
+        assertSame( filterE, list.get( 2 ) );
+        assertSame( filterD, list.get( 1 ) );
+        assertSame( filterB, list.get( 0 ) );
     }
 
     public void removeAll()
     {
-    	manager.removeAllFilters();
-    	assertEquals( 0, manager.getAllFilters().size() );
+        manager.removeAllFilters();
+        assertEquals( 0, manager.getAllFilters().size() );
     }
 
     public static void main( String[] args )



Mime
View raw message