directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r151670 - in incubator/directory/network/mina/trunk: ./ src/examples/org/apache/mina/examples/echoserver/ src/examples/org/apache/mina/examples/netcat/ src/examples/org/apache/mina/examples/reverser/ src/examples/org/apache/mina/examples/sumup/ src/java/org/apache/mina/io/ src/java/org/apache/mina/io/datagram/ src/java/org/apache/mina/io/socket/ src/java/org/apache/mina/protocol/ src/java/org/apache/mina/protocol/io/ src/java/org/apache/mina/protocol/vmpipe/ src/java/org/apache/mina/util/ src/test/org/apache/mina/examples/echoserver/ src/test/org/apache/mina/util/
Date Mon, 07 Feb 2005 03:16:08 GMT
Author: trustin
Date: Sun Feb  6 19:16:04 2005
New Revision: 151670

URL: http://svn.apache.org/viewcvs?view=rev&rev=151670
Log:
Fixed DIRMINA-7: FilterManagers are not thread-safe.

I limited the range of filter priorities and used array to store filter entries to make synchronization easy.

Removed:
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/util/SyncUtil.java
Modified:
    incubator/directory/network/mina/trunk/project.xml
    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/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/project.xml
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/project.xml?view=diff&r1=151669&r2=151670
==============================================================================
--- incubator/directory/network/mina/trunk/project.xml (original)
+++ incubator/directory/network/mina/trunk/project.xml Sun Feb  6 19:16:04 2005
@@ -77,13 +77,6 @@
 
 	<dependencies>
 
-		<dependency>
-			<groupId>concurrent</groupId>
-			<artifactId>concurrent</artifactId>
-			<version>1.3.4</version>
-			<url>http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html</url>
-		</dependency>
-
 		<!-- ================================================================== -->
 		<!-- Compatibility dependencies for ProtocolEncoder and ProtocolDecoder -->
 		<!-- ================================================================== -->

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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -21,6 +21,7 @@
 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;
@@ -46,22 +47,23 @@
 
         // Add thread pool filter
         // MINA runs in a single thread if you don't add this filter.
-        acceptor.addFilter( Integer.MAX_VALUE, threadPoolFilter );
+        acceptor.addFilter( IoHandlerFilter.MAX_PRIORITY, threadPoolFilter );
 
         // Bind
         acceptor.bind( new InetSocketAddress( PORT ),
-                       new EchoProtocolHandler() );
+                new EchoProtocolHandler() );
 
         // Create a UDP/IP acceptor
         IoAcceptor datagramAcceptor = new DatagramAcceptor();
 
         // Add thread pool filter
-        datagramAcceptor.addFilter( Integer.MAX_VALUE, threadPoolFilter );
+        datagramAcceptor.addFilter( IoHandlerFilter.MAX_PRIORITY,
+                threadPoolFilter );
 
         // Bind
         datagramAcceptor.bind( new InetSocketAddress( PORT ),
-                               new EchoProtocolHandler() );
+                new EchoProtocolHandler() );
 
         System.out.println( "Listening on port " + PORT );
     }
-}
\ No newline at end of file
+}

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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -20,6 +20,7 @@
 
 import java.net.InetSocketAddress;
 
+import org.apache.mina.io.IoHandlerFilter;
 import org.apache.mina.io.filter.IoThreadPoolFilter;
 import org.apache.mina.io.socket.SocketConnector;
 
@@ -46,10 +47,11 @@
 
         // Add I/O thread pool filter.
         // MINA runs in a single thread if you don't add this filter.
-        connector.addFilter( Integer.MAX_VALUE, new IoThreadPoolFilter() );
+        connector.addFilter( IoHandlerFilter.MAX_PRIORITY,
+                new IoThreadPoolFilter() );
 
         // Start communication.
         connector.connect( new InetSocketAddress( args[ 0 ], Integer
                 .parseInt( args[ 1 ] ) ), 60, new NetCatProtocolHandler() );
     }
-}
\ No newline at end of file
+}

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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -20,8 +20,10 @@
 
 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;
 
@@ -50,17 +52,18 @@
 
         // Create a TCP/IP acceptor.
         IoProtocolAcceptor acceptor = new IoProtocolAcceptor(
-                                                              new SocketAcceptor() );
+                new SocketAcceptor() );
 
         // Add both thread pool filters.
-        acceptor.getIoAcceptor().addFilter( Integer.MAX_VALUE,
-                                            ioThreadPoolFilter );
-        acceptor.addFilter( Integer.MAX_VALUE, protocolThreadPoolFilter );
+        acceptor.getIoAcceptor().addFilter( IoHandlerFilter.MAX_PRIORITY,
+                ioThreadPoolFilter );
+        acceptor.addFilter( ProtocolHandlerFilter.MAX_PRIORITY,
+                protocolThreadPoolFilter );
 
         // Bind
         acceptor.bind( new InetSocketAddress( PORT ),
-                       new ReverseProtocolProvider() );
+                new ReverseProtocolProvider() );
 
         System.out.println( "Listening on port " + PORT );
     }
-}
\ No newline at end of file
+}

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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -6,8 +6,10 @@
 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;
@@ -37,7 +39,7 @@
 
         // prepare values to sum up
         int[] values = new int[ args.length ];
-        for( int i = 0; i < args.length; i++ )
+        for( int i = 0; i < args.length; i ++ )
         {
             values[ i ] = Integer.parseInt( args[ i ] );
         }
@@ -53,20 +55,21 @@
         protocolThreadPoolFilter.start();
 
         IoProtocolConnector connector = new IoProtocolConnector(
-                                                                 new SocketConnector() );
-        connector.getIoConnector().addFilter( Integer.MAX_VALUE,
-                                              ioThreadPoolFilter );
-        connector.addFilter( Integer.MAX_VALUE, protocolThreadPoolFilter );
+                new SocketConnector() );
+        connector.getIoConnector().addFilter( IoHandlerFilter.MAX_PRIORITY,
+                ioThreadPoolFilter );
+        connector.addFilter( ProtocolHandlerFilter.MAX_PRIORITY,
+                protocolThreadPoolFilter );
 
-        ProtocolProvider protocolProvider = new ClientProtocolProvider( values );
+        ProtocolProvider protocolProvider = new ClientProtocolProvider(
+                values );
         ProtocolSession session;
         for( ;; )
         {
             try
             {
-                session = connector
-                        .connect( new InetSocketAddress( HOSTNAME, PORT ),
-                                  CONNECT_TIMEOUT, protocolProvider );
+                session = connector.connect( new InetSocketAddress( HOSTNAME,
+                        PORT ), CONNECT_TIMEOUT, protocolProvider );
                 break;
             }
             catch( IOException e )
@@ -86,4 +89,4 @@
         ioThreadPoolFilter.stop();
         protocolThreadPoolFilter.stop();
     }
-}
\ No newline at end of file
+}

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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -5,8 +5,10 @@
 
 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;
 
@@ -33,14 +35,15 @@
         protocolThreadPoolFilter.start();
 
         IoProtocolAcceptor acceptor = new IoProtocolAcceptor(
-                                                              new SocketAcceptor() );
+                new SocketAcceptor() );
 
-        acceptor.getIoAcceptor().addFilter( Integer.MAX_VALUE,
-                                            ioThreadPoolFilter );
-        acceptor.addFilter( Integer.MAX_VALUE, protocolThreadPoolFilter );
+        acceptor.getIoAcceptor().addFilter( IoHandlerFilter.MAX_PRIORITY,
+                ioThreadPoolFilter );
+        acceptor.addFilter( ProtocolHandlerFilter.MAX_PRIORITY,
+                protocolThreadPoolFilter );
 
         acceptor.bind( new InetSocketAddress( SERVER_PORT ),
-                       new ServerProtocolProvider() );
+                new ServerProtocolProvider() );
         System.out.println( "Listening on port " + SERVER_PORT );
     }
-}
\ No newline at end of file
+}

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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -48,6 +48,12 @@
  */
 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.
      */
@@ -84,4 +90,4 @@
      * Filters {@link IoSession#write(ByteBuffer, Object)} method invocation.
      */
     ByteBuffer filterWrite( IoSession session, ByteBuffer buf );
-}
\ No newline at end of file
+}

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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -440,7 +440,7 @@
 
     public List getAllFilters()
     {
-        return filterManager.filters();
+        return filterManager.getAllFilters();
     }
 
     private static class RegistrationRequest

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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -438,7 +438,7 @@
 
     public List getAllFilters()
     {
-        return filterManager.filters();
+        return filterManager.getAllFilters();
     }
 
     private static class RegistrationRequest

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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -303,7 +303,7 @@
 
     public List getAllFilters()
     {
-        return filterManager.filters();
+        return filterManager.getAllFilters();
     }
 
     private static class RegistrationRequest

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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -300,7 +300,7 @@
 
     public List getAllFilters()
     {
-    	return filterManager.filters();
+    	return filterManager.getAllFilters();
     }
 
     public ExceptionMonitor getExceptionMonitor()

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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -19,6 +19,7 @@
 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
@@ -45,6 +46,12 @@
  */
 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.
      */
@@ -87,4 +94,4 @@
      * Filters {@link ProtocolSession#write(Object)} method invocation.
      */
     Object filterWrite( ProtocolSession session, Object message );
-}
\ No newline at end of file
+}

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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -91,7 +91,7 @@
 
     public List getAllFilters()
     {
-        return filterManager.filters();
+        return filterManager.getAllFilters();
     }
 
     /**

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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -26,14 +26,16 @@
 {
     static final Map boundHandlers = new HashMap();
 
-    private final ProtocolHandlerFilterManager filterManager = new ProtocolHandlerFilterManager();
+    private final ProtocolHandlerFilterManager filterManager = new ProtocolHandlerFilterManager(
+            ProtocolHandlerFilter.MIN_PRIORITY - 1,
+            ProtocolHandlerFilter.MAX_PRIORITY );
 
     /**
      * Creates a new instance.
      */
     public VmPipeAcceptor()
     {
-        filterManager.addFilter( Integer.MIN_VALUE - 1, new VmPipeFilter() );
+        filterManager.addFilter( -1, new VmPipeFilter() );
     }
 
     public void bind( SocketAddress address, ProtocolProvider protocolProvider )
@@ -43,9 +45,9 @@
             throw new NullPointerException( "address" );
         if( protocolProvider == null )
             throw new NullPointerException( "protocolProvider" );
-        if( ! ( address instanceof VmPipeAddress ) )
+        if( !( address instanceof VmPipeAddress ) )
             throw new IllegalArgumentException(
-                                                "address must be VmPipeAddress." );
+                    "address must be VmPipeAddress." );
 
         synchronized( boundHandlers )
         {
@@ -55,9 +57,7 @@
             }
 
             boundHandlers.put( address, new Entry( ( VmPipeAddress ) address,
-                                                   filterManager,
-                                                   protocolProvider
-                                                           .getHandler() ) );
+                    filterManager, protocolProvider.getHandler() ) );
         }
     }
 
@@ -81,15 +81,15 @@
     {
         filterManager.removeFilter( filter );
     }
-    
+
     public List getAllFilters()
     {
-    	return filterManager.filters();
+        return filterManager.getAllFilters();
     }
 
     public void removeAllFilters()
     {
-    	filterManager.removeAllFilters();
+        filterManager.removeAllFilters();
     }
 
     static class Entry
@@ -109,4 +109,4 @@
             this.handler = handler;
         }
     }
-}
\ No newline at end of file
+}

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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -50,7 +50,7 @@
 
     public List getAllFilters()
     {
-    	return filterManager.filters();
+    	return filterManager.getAllFilters();
     }
 
     public ProtocolSession connect( SocketAddress address,

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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -19,6 +19,7 @@
 package org.apache.mina.util;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.mina.common.ByteBuffer;
@@ -85,96 +86,88 @@
         }
     };
 
-    private Entry head = new Entry( null, null, Integer.MIN_VALUE,
-            FINAL_FILTER );
+    private final Entry[] entries;
 
-    private final Entry tail = head;
+    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 );
+    }
 
     public IoHandlerFilterManager()
     {
+        this( IoHandlerFilter.MIN_PRIORITY, IoHandlerFilter.MAX_PRIORITY );
     }
 
     public synchronized void addFilter( int priority, IoHandlerFilter filter )
     {
-        Entry e = head;
-        Entry prevEntry = null;
-        for( ;; )
+        if( priority < minPriority || priority > maxPriority )
         {
-            if( e.priority < priority )
-            {
-                Entry newEntry = new Entry( prevEntry, e, priority, filter );
-                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;
+            throw new IllegalArgumentException( "priority: " + priority
+                    + " (should be " + minPriority + '~' + maxPriority + ')' );
         }
-    }
 
-    public synchronized void removeFilter( IoHandlerFilter filter )
-    {
-        if( filter == tail )
+        if( entries[ priority - minPriority + 1 ] == null )
+        {
+            entries[ priority - minPriority + 1 ] = new Entry( priority,
+                    filter );
+        }
+        else
         {
             throw new IllegalArgumentException(
-                    "Cannot remove the internal filter." );
+                    "Other filter is registered with priority " + priority
+                            + " already." );
         }
+    }
 
-        Entry e = head;
-        Entry prevEntry = null;
-        for( ;; )
+    public synchronized boolean removeFilter( IoHandlerFilter filter )
+    {
+        for( int i = entries.length - 1; i > 0; i -- )
         {
-            if( e.nextEntry == null )
+            if( entries[ i ] != null && filter == entries[ i ].filter )
             {
-                break;
+                entries[ i ] = null;
+                return true;
             }
-            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()
     {
-        tail.prevEntry = null;
-        tail.nextEntry = null;
-        head = tail;
+        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();
     }
 
     public void fireSessionOpened( IoSession session )
     {
-        Entry head = this.head;
+        Entry entry = findNextEntry( maxPriority + 1 );
         try
         {
-            head.filter.sessionOpened( head.nextHandler, session );
+            entry.filter.sessionOpened( entry.nextHandler, session );
         }
         catch( Throwable e )
         {
@@ -184,10 +177,10 @@
 
     public void fireSessionClosed( IoSession session )
     {
-        Entry head = this.head;
+        Entry entry = findNextEntry( maxPriority + 1 );
         try
         {
-            head.filter.sessionClosed( head.nextHandler, session );
+            entry.filter.sessionClosed( entry.nextHandler, session );
         }
         catch( Throwable e )
         {
@@ -197,10 +190,10 @@
 
     public void fireSessionIdle( IoSession session, IdleStatus status )
     {
-        Entry head = this.head;
+        Entry entry = findNextEntry( maxPriority + 1 );
         try
         {
-            head.filter.sessionIdle( head.nextHandler, session, status );
+            entry.filter.sessionIdle( entry.nextHandler, session, status );
         }
         catch( Throwable e )
         {
@@ -210,10 +203,10 @@
 
     public void fireDataRead( IoSession session, ByteBuffer buf )
     {
-        Entry head = this.head;
+        Entry entry = findNextEntry( maxPriority + 1 );
         try
         {
-            head.filter.dataRead( head.nextHandler, session, buf );
+            entry.filter.dataRead( entry.nextHandler, session, buf );
         }
         catch( Throwable e )
         {
@@ -223,10 +216,10 @@
 
     public void fireDataWritten( IoSession session, Object marker )
     {
-        Entry head = this.head;
+        Entry entry = findNextEntry( maxPriority + 1 );
         try
         {
-            head.filter.dataWritten( head.nextHandler, session, marker );
+            entry.filter.dataWritten( entry.nextHandler, session, marker );
         }
         catch( Throwable e )
         {
@@ -236,10 +229,10 @@
 
     public void fireExceptionCaught( IoSession session, Throwable cause )
     {
-        Entry head = this.head;
+        Entry entry = findNextEntry( maxPriority + 1 );
         try
         {
-            head.filter.exceptionCaught( head.nextHandler, session, cause );
+            entry.filter.exceptionCaught( entry.nextHandler, session, cause );
         }
         catch( Throwable e )
         {
@@ -250,81 +243,62 @@
     public void write( IoSession session, WriteCommand cmd, ByteBuffer buf,
                       Object marker )
     {
-        Entry e = tail;
         ByteBuffer newBuf;
-        do
+        for( int i = 0; i < entries.length; i ++ )
         {
+            Entry e = entries[ i ];
+            if( e == null )
+            {
+                continue;
+            }
+
             newBuf = e.filter.filterWrite( session, buf );
             if( buf != newBuf )
             {
                 // Original buffer is replaced with new filtered buffer;
                 // let's release the old one.
-                try
-                {
-                    ByteBuffer.release( buf );
-                }
-                catch( IllegalStateException ex )
-                {
-                    fireExceptionCaught( session, ex );
-                    // abort the write operation.
-                    return;
-                }
+                ByteBuffer.release( buf );
+            }
+            else if( newBuf == null )
+            {
+                return;
             }
             buf = newBuf;
-            e = e.prevEntry;
         }
-        while( e != null );
 
         cmd.execute( buf, marker );
     }
 
-    public List filters()
+    public List getAllFilters()
     {
-        List list = new ArrayList();
-        Entry e = head;
-        do
+        List list = new ArrayList( maxPriority - minPriority + 1 );
+        for( int priority = maxPriority + 1;; )
         {
-            list.add( e.filter );
-            e = e.nextEntry;
-        }
-        while( e != null );
-
-        return list;
-    }
+            Entry e = findNextEntry( priority );
+            if( e.priority < minPriority )
+            {
+                break;
+            }
 
-    public List filtersReversed()
-    {
-        List list = new ArrayList();
-        Entry e = tail;
-        do
-        {
+            priority = e.priority;
             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 IoHandlerFilter filter;
 
         private final IoHandler nextHandler;
 
-        private Entry( Entry prevEntry, Entry nextEntry, int priority,
-                      IoHandlerFilter filter )
+        private Entry( int priority, IoHandlerFilter filter )
         {
             if( filter == null )
                 throw new NullPointerException( "filter" );
-            this.prevEntry = prevEntry;
-            this.nextEntry = nextEntry;
             this.priority = priority;
             this.filter = filter;
             this.nextHandler = new IoHandler()
@@ -332,10 +306,11 @@
 
                 public void sessionOpened( IoSession session )
                 {
+                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        Entry.this.nextEntry.filter.sessionOpened(
-                                Entry.this.nextEntry.nextHandler, session );
+                        nextEntry.filter.sessionOpened(
+                                nextEntry.nextHandler, session );
                     }
                     catch( Throwable e )
                     {
@@ -346,10 +321,11 @@
 
                 public void sessionClosed( IoSession session )
                 {
+                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        Entry.this.nextEntry.filter.sessionClosed(
-                                Entry.this.nextEntry.nextHandler, session );
+                        nextEntry.filter.sessionClosed(
+                                nextEntry.nextHandler, session );
                     }
                     catch( Throwable e )
                     {
@@ -360,11 +336,11 @@
 
                 public void sessionIdle( IoSession session, IdleStatus status )
                 {
+                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        Entry.this.nextEntry.filter.sessionIdle(
-                                Entry.this.nextEntry.nextHandler, session,
-                                status );
+                        nextEntry.filter.sessionIdle( nextEntry.nextHandler,
+                                session, status );
                     }
                     catch( Throwable e )
                     {
@@ -376,11 +352,11 @@
                 public void exceptionCaught( IoSession session,
                                             Throwable cause )
                 {
+                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        Entry.this.nextEntry.filter.exceptionCaught(
-                                Entry.this.nextEntry.nextHandler, session,
-                                cause );
+                        nextEntry.filter.exceptionCaught(
+                                nextEntry.nextHandler, session, cause );
                     }
                     catch( Throwable e )
                     {
@@ -390,11 +366,11 @@
 
                 public void dataRead( IoSession session, ByteBuffer buf )
                 {
+                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        Entry.this.nextEntry.filter.dataRead(
-                                Entry.this.nextEntry.nextHandler, session,
-                                buf );
+                        nextEntry.filter.dataRead( nextEntry.nextHandler,
+                                session, buf );
                     }
                     catch( Throwable e )
                     {
@@ -405,11 +381,11 @@
 
                 public void dataWritten( IoSession session, Object marker )
                 {
+                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        Entry.this.nextEntry.filter.dataWritten(
-                                Entry.this.nextEntry.nextHandler, session,
-                                marker );
+                        nextEntry.filter.dataWritten( 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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -19,6 +19,7 @@
 package org.apache.mina.util;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.mina.common.IdleStatus;
@@ -79,96 +80,89 @@
         }
     };
 
-    private Entry head = new Entry( null, null, Integer.MIN_VALUE,
-                                    FINAL_FILTER );
+    private final Entry[] entries;
 
-    private Entry tail = head;
+    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 );
+    }
 
     public ProtocolHandlerFilterManager()
     {
+        this( ProtocolHandlerFilter.MIN_PRIORITY,
+                ProtocolHandlerFilter.MAX_PRIORITY );
     }
 
     public synchronized void addFilter( int priority,
                                        ProtocolHandlerFilter filter )
     {
-        Entry e = head;
-        Entry prevEntry = null;
-        for( ;; )
+        if( priority < minPriority || priority > maxPriority )
         {
-            if( e.priority < priority )
-            {
-                Entry newEntry = new Entry( prevEntry, e, priority, filter );
-                if( prevEntry == null )
-                {
-                    head = newEntry;
-                }
-                else
-                {
-                    prevEntry.nextEntry.prevEntry = newEntry;
-                    prevEntry.nextEntry = newEntry;
-                }
-                break;
-            }
-            else if( e.priority == priority )
+            throw new IllegalArgumentException( "priority: " + priority
+                    + " (should be " + minPriority + '~' + maxPriority + ')' );
+        }
+
+        if( entries[ priority - minPriority + 1 ] == null )
+        {
+            entries[ priority - minPriority + 1 ] = new Entry( priority, filter );
+        }
+        else
+        {
+            throw new IllegalArgumentException(
+                    "Other filter is registered with priority " + priority
+                            + " already." );
+        }
+    }
+
+    public synchronized boolean removeFilter( ProtocolHandlerFilter filter )
+    {
+        for( int i = entries.length - 1; i > 0; i -- )
+        {
+            if( entries[ i ] != null && filter == entries[ i ].filter )
             {
-                throw new IllegalArgumentException(
-                                                    "Other filter is registered with priority "
-                                                                                                                                                                                                                + priority
-                                                                                                                                                                                                                + " already." );
+                entries[ i ] = null;
+                return true;
             }
-            prevEntry = e;
-            e = e.nextEntry;
         }
+
+        return false;
+    }
+
+    public synchronized void removeAllFilters()
+    {
+        Arrays.fill( entries, 1, entries.length, null );
     }
 
-    public synchronized void removeFilter( ProtocolHandlerFilter filter )
+    private Entry findNextEntry( int currentPriority )
     {
-    	if( filter == tail )
-    	{
-    		throw new IllegalArgumentException(
-    				"Cannot remove the internal filter.");
-    	}
+        currentPriority -= minPriority;
 
-        Entry e = head;
-        Entry prevEntry = null;
-        for( ;; )
+        for( ; currentPriority >= 0; currentPriority -- )
         {
-            if( e.nextEntry == null )
+            Entry e = entries[ currentPriority ];
+            if( e != null )
             {
-                break;
+                return e;
             }
-            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;
         }
-    }
 
-    public synchronized void removeAllFilters() {
-    	tail.prevEntry = null;
-    	tail.nextEntry = null;
-    	head = tail;
+        throw new InternalError();
     }
 
     public void fireSessionOpened( ProtocolSession session )
     {
-        Entry head = this.head;
+        Entry entry = findNextEntry( maxPriority + 1 );
         try
         {
-            head.filter.sessionOpened( head.nextHandler, session );
+            entry.filter.sessionOpened( entry.nextHandler, session );
         }
         catch( Throwable e )
         {
@@ -178,10 +172,10 @@
 
     public void fireSessionClosed( ProtocolSession session )
     {
-        Entry head = this.head;
+        Entry entry = findNextEntry( maxPriority + 1 );
         try
         {
-            head.filter.sessionClosed( head.nextHandler, session );
+            entry.filter.sessionClosed( entry.nextHandler, session );
         }
         catch( Throwable e )
         {
@@ -191,10 +185,10 @@
 
     public void fireSessionIdle( ProtocolSession session, IdleStatus status )
     {
-        Entry head = this.head;
+        Entry entry = findNextEntry( maxPriority + 1 );
         try
         {
-            head.filter.sessionIdle( head.nextHandler, session, status );
+            entry.filter.sessionIdle( entry.nextHandler, session, status );
         }
         catch( Throwable e )
         {
@@ -204,10 +198,10 @@
 
     public void fireMessageSent( ProtocolSession session, Object message )
     {
-        Entry head = this.head;
+        Entry entry = findNextEntry( maxPriority + 1 );
         try
         {
-            head.filter.messageSent( head.nextHandler, session, message );
+            entry.filter.messageSent( entry.nextHandler, session, message );
         }
         catch( Throwable e )
         {
@@ -217,10 +211,11 @@
 
     public void fireMessageReceived( ProtocolSession session, Object message )
     {
-        Entry head = this.head;
+        Entry entry = findNextEntry( maxPriority + 1 );
         try
         {
-            head.filter.messageReceived( head.nextHandler, session, message );
+            entry.filter
+                    .messageReceived( entry.nextHandler, session, message );
         }
         catch( Throwable e )
         {
@@ -230,10 +225,10 @@
 
     public void fireExceptionCaught( ProtocolSession session, Throwable cause )
     {
-        Entry head = this.head;
+        Entry entry = findNextEntry( maxPriority + 1 );
         try
         {
-            head.filter.exceptionCaught( head.nextHandler, session, cause );
+            entry.filter.exceptionCaught( entry.nextHandler, session, cause );
         }
         catch( Throwable e )
         {
@@ -241,66 +236,57 @@
         }
     }
 
-    public void write( ProtocolSession session, WriteCommand cmd, Object message )
+    public void write( ProtocolSession session, WriteCommand cmd,
+                      Object message )
     {
-        Entry e = tail;
-        do
+        for( int i = 0; i < entries.length; i ++ )
         {
+            Entry e = entries[ i ];
+            if( e == null )
+            {
+                continue;
+            }
+
             message = e.filter.filterWrite( session, message );
-            e = e.prevEntry;
+            if( message == null )
+            {
+                return;
+            }
         }
-        while( e != null );
 
         cmd.execute( message );
     }
 
-    public List filters()
+    public List getAllFilters()
     {
-        List list = new ArrayList();
-        Entry e = head;
-        do
+        List list = new ArrayList( maxPriority - minPriority + 1 );
+        for( int priority = maxPriority + 1;; )
         {
-            list.add( e.filter );
-            e = e.nextEntry;
-        }
-        while( e != null );
-
-        return list;
-    }
+            Entry e = findNextEntry( priority );
+            if( e.priority < minPriority )
+            {
+                break;
+            }
 
-    public List filtersReversed()
-    {
-        List list = new ArrayList();
-        Entry e = tail;
-        do
-        {
+            priority = e.priority;
             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 ProtocolHandlerFilter filter;
 
         private final ProtocolHandler nextHandler;
 
-        private Entry( Entry prevEntry, Entry nextEntry, int priority,
-                      ProtocolHandlerFilter filter )
+        private Entry( int priority, ProtocolHandlerFilter filter )
         {
             if( filter == null )
                 throw new NullPointerException( "filter" );
-            this.prevEntry = prevEntry;
-            this.nextEntry = nextEntry;
             this.priority = priority;
             this.filter = filter;
             this.nextHandler = new ProtocolHandler()
@@ -308,59 +294,58 @@
 
                 public void sessionOpened( ProtocolSession session )
                 {
+                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        Entry.this.nextEntry.filter
-                                .sessionOpened(
-                                                Entry.this.nextEntry.nextHandler,
-                                                session );
+                        nextEntry.filter.sessionOpened(
+                                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
                     {
-                        Entry.this.nextEntry.filter
-                                .sessionClosed(
-                                                Entry.this.nextEntry.nextHandler,
-                                                session );
+                        nextEntry.filter.sessionClosed(
+                                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
                     {
-                        Entry.this.nextEntry.filter
-                                .sessionIdle(
-                                              Entry.this.nextEntry.nextHandler,
-                                              session, status );
+                        nextEntry.filter.sessionIdle( 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
                     {
-                        Entry.this.nextEntry.filter
-                                .exceptionCaught(
-                                                  Entry.this.nextEntry.nextHandler,
-                                                  session, cause );
+                        nextEntry.filter.exceptionCaught(
+                                nextEntry.nextHandler, session, cause );
                     }
                     catch( Throwable e )
                     {
@@ -371,32 +356,32 @@
                 public void messageReceived( ProtocolSession session,
                                             Object message )
                 {
+                    Entry nextEntry = findNextEntry( Entry.this.priority );
                     try
                     {
-                        Entry.this.nextEntry.filter
-                                .messageReceived(
-                                                  Entry.this.nextEntry.nextHandler,
-                                                  session, message );
+                        nextEntry.filter.messageReceived(
+                                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
                     {
-                        Entry.this.nextEntry.filter
-                                .messageSent(
-                                              Entry.this.nextEntry.nextHandler,
-                                              session, message );
+                        nextEntry.filter.messageSent( nextEntry.nextHandler,
+                                session, message );
                     }
                     catch( Throwable e )
                     {
-                        ProtocolHandlerFilterManager.this.fireExceptionCaught( session, e );
+                        ProtocolHandlerFilterManager.this
+                                .fireExceptionCaught( session, e );
                     }
                 }
             };
@@ -407,4 +392,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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -98,14 +98,16 @@
         {
             throw new IOException( "Cannot bind any test port." );
         }
-        
-        System.out.println("Using port " + port + " for testing.");
+
+        System.out.println( "Using port " + port + " for testing." );
 
         threadPoolFilter = new IoThreadPoolFilter();
         threadPoolFilter.start();
 
-        acceptor.addFilter( Integer.MAX_VALUE, threadPoolFilter );
-        datagramAcceptor.addFilter( Integer.MAX_VALUE, threadPoolFilter );
+        acceptor
+                .addFilter( IoThreadPoolFilter.MAX_PRIORITY, threadPoolFilter );
+        datagramAcceptor.addFilter( IoThreadPoolFilter.MAX_PRIORITY,
+                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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -29,7 +29,7 @@
 
     public void setUp()
     {
-        manager = new IoHandlerFilterManager();
+        manager = new IoHandlerFilterManager(-10, 10);
         filterA = new IoHandlerFilterImpl( 'A' );
         filterB = new IoHandlerFilterImpl( 'B' );
         filterC = new IoHandlerFilterImpl( 'C' );
@@ -45,21 +45,13 @@
     public void testAdd()
     {
         List list;
-        list = manager.filters();
-        assertEquals( 6, list.size() );
+        list = manager.getAllFilters();
+        assertEquals( 5, list.size() );
         assertSame( filterC, list.get( 0 ) );
         assertSame( filterE, list.get( 1 ) );
         assertSame( filterA, list.get( 2 ) );
         assertSame( filterD, list.get( 3 ) );
         assertSame( filterB, list.get( 4 ) );
-
-        list = manager.filtersReversed();
-        assertEquals( 6, list.size() );
-        assertSame( filterC, list.get( 5 ) );
-        assertSame( filterE, list.get( 4 ) );
-        assertSame( filterA, list.get( 3 ) );
-        assertSame( filterD, list.get( 2 ) );
-        assertSame( filterB, list.get( 1 ) );
     }
 
     public void testRemoveFirst()
@@ -67,19 +59,12 @@
         manager.removeFilter( filterC );
 
         List list;
-        list = manager.filters();
-        assertEquals( 5, list.size() );
+        list = manager.getAllFilters();
+        assertEquals( 4, list.size() );
         assertSame( filterE, list.get( 0 ) );
         assertSame( filterA, list.get( 1 ) );
         assertSame( filterD, list.get( 2 ) );
         assertSame( filterB, list.get( 3 ) );
-
-        list = manager.filtersReversed();
-        assertEquals( 5, list.size() );
-        assertSame( filterE, list.get( 4 ) );
-        assertSame( filterA, list.get( 3 ) );
-        assertSame( filterD, list.get( 2 ) );
-        assertSame( filterB, list.get( 1 ) );
     }
 
     public void testRemoveLast()
@@ -87,19 +72,12 @@
         manager.removeFilter( filterB );
 
         List list;
-        list = manager.filters();
-        assertEquals( 5, list.size() );
+        list = manager.getAllFilters();
+        assertEquals( 4, list.size() );
         assertSame( filterC, list.get( 0 ) );
         assertSame( filterE, list.get( 1 ) );
         assertSame( filterA, list.get( 2 ) );
         assertSame( filterD, list.get( 3 ) );
-
-        list = manager.filtersReversed();
-        assertEquals( 5, list.size() );
-        assertSame( filterC, list.get( 4 ) );
-        assertSame( filterE, list.get( 3 ) );
-        assertSame( filterA, list.get( 2 ) );
-        assertSame( filterD, list.get( 1 ) );
     }
 
     public void testRemoveMiddle()
@@ -107,25 +85,18 @@
         manager.removeFilter( filterA );
 
         List list;
-        list = manager.filters();
-        assertEquals( 5, list.size() );
+        list = manager.getAllFilters();
+        assertEquals( 4, list.size() );
         assertSame( filterC, list.get( 0 ) );
         assertSame( filterE, list.get( 1 ) );
         assertSame( filterD, list.get( 2 ) );
         assertSame( filterB, list.get( 3 ) );
-
-        list = manager.filtersReversed();
-        assertEquals( 5, list.size() );
-        assertSame( filterC, list.get( 4 ) );
-        assertSame( filterE, list.get( 3 ) );
-        assertSame( filterD, list.get( 2 ) );
-        assertSame( filterB, list.get( 1 ) );
     }
     
     public void removeAll()
     {
     	manager.removeAllFilters();
-    	assertEquals( 1, manager.filters().size() );
+    	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=151669&r2=151670
==============================================================================
--- 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 Sun Feb  6 19:16:04 2005
@@ -29,7 +29,7 @@
 
     public void setUp()
     {
-        manager = new ProtocolHandlerFilterManager();
+        manager = new ProtocolHandlerFilterManager(-10, 10);
         filterA = new ProtocolHandlerFilterImpl( 'A' );
         filterB = new ProtocolHandlerFilterImpl( 'B' );
         filterC = new ProtocolHandlerFilterImpl( 'C' );
@@ -45,21 +45,13 @@
     public void testAdd()
     {
         List list;
-        list = manager.filters();
-        assertEquals( 6, list.size() );
+        list = manager.getAllFilters();
+        assertEquals( 5, list.size() );
         assertSame( filterC, list.get( 0 ) );
         assertSame( filterE, list.get( 1 ) );
         assertSame( filterA, list.get( 2 ) );
         assertSame( filterD, list.get( 3 ) );
         assertSame( filterB, list.get( 4 ) );
-
-        list = manager.filtersReversed();
-        assertEquals( 6, list.size() );
-        assertSame( filterC, list.get( 5 ) );
-        assertSame( filterE, list.get( 4 ) );
-        assertSame( filterA, list.get( 3 ) );
-        assertSame( filterD, list.get( 2 ) );
-        assertSame( filterB, list.get( 1 ) );
     }
 
     public void testRemoveFirst()
@@ -67,19 +59,12 @@
         manager.removeFilter( filterC );
 
         List list;
-        list = manager.filters();
-        assertEquals( 5, list.size() );
+        list = manager.getAllFilters();
+        assertEquals( 4, list.size() );
         assertSame( filterE, list.get( 0 ) );
         assertSame( filterA, list.get( 1 ) );
         assertSame( filterD, list.get( 2 ) );
         assertSame( filterB, list.get( 3 ) );
-
-        list = manager.filtersReversed();
-        assertEquals( 5, list.size() );
-        assertSame( filterE, list.get( 4 ) );
-        assertSame( filterA, list.get( 3 ) );
-        assertSame( filterD, list.get( 2 ) );
-        assertSame( filterB, list.get( 1 ) );
     }
 
     public void testRemoveLast()
@@ -87,19 +72,12 @@
         manager.removeFilter( filterB );
 
         List list;
-        list = manager.filters();
-        assertEquals( 5, list.size() );
+        list = manager.getAllFilters();
+        assertEquals( 4, list.size() );
         assertSame( filterC, list.get( 0 ) );
         assertSame( filterE, list.get( 1 ) );
         assertSame( filterA, list.get( 2 ) );
         assertSame( filterD, list.get( 3 ) );
-
-        list = manager.filtersReversed();
-        assertEquals( 5, list.size() );
-        assertSame( filterC, list.get( 4 ) );
-        assertSame( filterE, list.get( 3 ) );
-        assertSame( filterA, list.get( 2 ) );
-        assertSame( filterD, list.get( 1 ) );
     }
 
     public void testRemoveMiddle()
@@ -107,25 +85,18 @@
         manager.removeFilter( filterA );
 
         List list;
-        list = manager.filters();
-        assertEquals( 5, list.size() );
+        list = manager.getAllFilters();
+        assertEquals( 4, list.size() );
         assertSame( filterC, list.get( 0 ) );
         assertSame( filterE, list.get( 1 ) );
         assertSame( filterD, list.get( 2 ) );
         assertSame( filterB, list.get( 3 ) );
-
-        list = manager.filtersReversed();
-        assertEquals( 5, list.size() );
-        assertSame( filterC, list.get( 4 ) );
-        assertSame( filterE, list.get( 3 ) );
-        assertSame( filterD, list.get( 2 ) );
-        assertSame( filterB, list.get( 1 ) );
     }
 
     public void removeAll()
     {
     	manager.removeAllFilters();
-    	assertEquals( 1, manager.filters().size() );
+    	assertEquals( 0, manager.getAllFilters().size() );
     }
 
     public static void main( String[] args )



Mime
View raw message