directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r349899 - in /directory/network: branches/0.8/src/java/org/apache/mina/io/ branches/0.8/src/java/org/apache/mina/protocol/ branches/0.8/src/test/org/apache/mina/io/ branches/0.8/src/test/org/apache/mina/protocol/ branches/chain_refactor/src...
Date Wed, 30 Nov 2005 06:54:44 GMT
Author: trustin
Date: Tue Nov 29 22:54:01 2005
New Revision: 349899

URL: http://svn.apache.org/viewcvs?rev=349899&view=rev
Log:
* Added IoFilterChain.Entry interface
* Revised IoFilterChain interface
* Fixed DIRMINA-134: IoFilterChain.addBefore() and addAfter() behaves wrong.


Modified:
    directory/network/branches/0.8/src/java/org/apache/mina/io/AbstractIoFilterChain.java
    directory/network/branches/0.8/src/java/org/apache/mina/protocol/AbstractProtocolFilterChain.java
    directory/network/branches/0.8/src/test/org/apache/mina/io/IoFilterChainTest.java
    directory/network/branches/0.8/src/test/org/apache/mina/protocol/ProtocolFilterChainTest.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoFilterChain.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/AbstractIoFilterChain.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/SSLFilter.java
    directory/network/branches/chain_refactor/src/test/org/apache/mina/common/IoFilterChainTest.java
    directory/network/branches/chain_refactor/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
    directory/network/branches/chain_refactor/src/test/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java
    directory/network/trunk/src/java/org/apache/mina/handler/StreamIoHandler.java

Modified: directory/network/branches/0.8/src/java/org/apache/mina/io/AbstractIoFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.8/src/java/org/apache/mina/io/AbstractIoFilterChain.java?rev=349899&r1=349898&r2=349899&view=diff
==============================================================================
--- directory/network/branches/0.8/src/java/org/apache/mina/io/AbstractIoFilterChain.java
(original)
+++ directory/network/branches/0.8/src/java/org/apache/mina/io/AbstractIoFilterChain.java
Tue Nov 29 22:54:01 2005
@@ -214,7 +214,7 @@
     {
         Entry baseEntry = checkOldName( baseName );
         checkAddable( name );
-        register( baseEntry, name, filter );
+        register( baseEntry.prevEntry, name, filter );
     }
 
 
@@ -228,7 +228,7 @@
     {
         Entry baseEntry = checkOldName( baseName );
         checkAddable( name );
-        register( baseEntry.prevEntry, name, filter );
+        register( baseEntry, name, filter );
     }
 
 

Modified: directory/network/branches/0.8/src/java/org/apache/mina/protocol/AbstractProtocolFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.8/src/java/org/apache/mina/protocol/AbstractProtocolFilterChain.java?rev=349899&r1=349898&r2=349899&view=diff
==============================================================================
--- directory/network/branches/0.8/src/java/org/apache/mina/protocol/AbstractProtocolFilterChain.java
(original)
+++ directory/network/branches/0.8/src/java/org/apache/mina/protocol/AbstractProtocolFilterChain.java
Tue Nov 29 22:54:01 2005
@@ -206,7 +206,7 @@
     {
         Entry baseEntry = checkOldName( baseName );
         checkAddable( name );
-        register( baseEntry, name, filter );
+        register( baseEntry.prevEntry, name, filter );
     }
 
 
@@ -220,7 +220,7 @@
     {
         Entry baseEntry = checkOldName( baseName );
         checkAddable( name );
-        register( baseEntry.prevEntry, name, filter );
+        register( baseEntry, name, filter );
     }
 
 

Modified: directory/network/branches/0.8/src/test/org/apache/mina/io/IoFilterChainTest.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.8/src/test/org/apache/mina/io/IoFilterChainTest.java?rev=349899&r1=349898&r2=349899&view=diff
==============================================================================
--- directory/network/branches/0.8/src/test/org/apache/mina/io/IoFilterChainTest.java (original)
+++ directory/network/branches/0.8/src/test/org/apache/mina/io/IoFilterChainTest.java Tue
Nov 29 22:54:01 2005
@@ -19,6 +19,7 @@
 package org.apache.mina.io;
 
 import java.net.SocketAddress;
+import java.util.Iterator;
 
 import junit.framework.Assert;
 import junit.framework.TestCase;
@@ -50,6 +51,57 @@
     
     public void tearDown()
     {
+    }
+    
+    public void testAdd() throws Exception
+    {
+        chain.addFirst( "A", new TestFilter( 'A' ) );
+        chain.addLast( "B", new TestFilter( 'B' ) );
+        chain.addFirst( "C", new TestFilter( 'C' ) );
+        chain.addLast( "D", new TestFilter( 'D' ) );
+        chain.addBefore( "B", "E", new TestFilter( 'E' ) );
+        chain.addBefore( "C", "F", new TestFilter( 'F' ) );
+        chain.addAfter( "B", "G", new TestFilter( 'G' ) );
+        chain.addAfter( "D", "H", new TestFilter( 'H' ) );
+        
+        String actual = "";
+        for( Iterator i = chain.getChildren().iterator(); i.hasNext(); ) 
+        {
+            TestFilter f = ( TestFilter ) i.next();
+            actual += f.id;
+        }
+        
+        Assert.assertEquals( "FCAEBGDH", actual );
+    }
+    
+    public void testRemove() throws Exception
+    {
+        chain.addLast( "A", new TestFilter( 'A' ) );
+        chain.addLast( "B", new TestFilter( 'B' ) );
+        chain.addLast( "C", new TestFilter( 'C' ) );
+        chain.addLast( "D", new TestFilter( 'D' ) );
+        chain.addLast( "E", new TestFilter( 'E' ) );
+        
+        chain.remove( "A" );
+        chain.remove( "E" );
+        chain.remove( "C" );
+        chain.remove( "B" );
+        chain.remove( "D" );
+        
+        Assert.assertEquals( 0, chain.getChildren().size() );
+    }
+    
+    public void testClear() throws Exception
+    {
+        chain.addLast( "A", new TestFilter( 'A' ) );
+        chain.addLast( "B", new TestFilter( 'B' ) );
+        chain.addLast( "C", new TestFilter( 'C' ) );
+        chain.addLast( "D", new TestFilter( 'D' ) );
+        chain.addLast( "E", new TestFilter( 'E' ) );
+        
+        chain.clear();
+        
+        Assert.assertEquals( 0, chain.getChildren().size() );
     }
     
     public void testDefault()

Modified: directory/network/branches/0.8/src/test/org/apache/mina/protocol/ProtocolFilterChainTest.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.8/src/test/org/apache/mina/protocol/ProtocolFilterChainTest.java?rev=349899&r1=349898&r2=349899&view=diff
==============================================================================
--- directory/network/branches/0.8/src/test/org/apache/mina/protocol/ProtocolFilterChainTest.java
(original)
+++ directory/network/branches/0.8/src/test/org/apache/mina/protocol/ProtocolFilterChainTest.java
Tue Nov 29 22:54:01 2005
@@ -19,6 +19,7 @@
 package org.apache.mina.protocol;
 
 import java.net.SocketAddress;
+import java.util.Iterator;
 
 import junit.framework.Assert;
 import junit.framework.TestCase;
@@ -49,6 +50,57 @@
     
     public void tearDown()
     {
+    }
+    
+    public void testAdd() throws Exception
+    {
+        chain.addFirst( "A", new TestFilter( 'A' ) );
+        chain.addLast( "B", new TestFilter( 'B' ) );
+        chain.addFirst( "C", new TestFilter( 'C' ) );
+        chain.addLast( "D", new TestFilter( 'D' ) );
+        chain.addBefore( "B", "E", new TestFilter( 'E' ) );
+        chain.addBefore( "C", "F", new TestFilter( 'F' ) );
+        chain.addAfter( "B", "G", new TestFilter( 'G' ) );
+        chain.addAfter( "D", "H", new TestFilter( 'H' ) );
+        
+        String actual = "";
+        for( Iterator i = chain.getChildren().iterator(); i.hasNext(); ) 
+        {
+            TestFilter f = ( TestFilter ) i.next();
+            actual += f.id;
+        }
+        
+        Assert.assertEquals( "FCAEBGDH", actual );
+    }
+    
+    public void testRemove() throws Exception
+    {
+        chain.addLast( "A", new TestFilter( 'A' ) );
+        chain.addLast( "B", new TestFilter( 'B' ) );
+        chain.addLast( "C", new TestFilter( 'C' ) );
+        chain.addLast( "D", new TestFilter( 'D' ) );
+        chain.addLast( "E", new TestFilter( 'E' ) );
+        
+        chain.remove( "A" );
+        chain.remove( "E" );
+        chain.remove( "C" );
+        chain.remove( "B" );
+        chain.remove( "D" );
+        
+        Assert.assertEquals( 0, chain.getChildren().size() );
+    }
+    
+    public void testClear() throws Exception
+    {
+        chain.addLast( "A", new TestFilter( 'A' ) );
+        chain.addLast( "B", new TestFilter( 'B' ) );
+        chain.addLast( "C", new TestFilter( 'C' ) );
+        chain.addLast( "D", new TestFilter( 'D' ) );
+        chain.addLast( "E", new TestFilter( 'E' ) );
+        
+        chain.clear();
+        
+        Assert.assertEquals( 0, chain.getChildren().size() );
     }
     
     public void testDefault()

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoFilterChain.java?rev=349899&r1=349898&r2=349899&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoFilterChain.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoFilterChain.java
Tue Nov 29 22:54:01 2005
@@ -37,35 +37,24 @@
     IoSession getSession();
     
     /**
-     * Returns the {@link IoFilter} with the specified <tt>name</tt> in this
chain.
-     * @return <tt>null</tt> if there's no such filter in this chain
+     * Returns the {@link Entry} with the specified <tt>name</tt> in this chain.
+     * @return <tt>null</tt> if there's no such name in this chain
      */
-    IoFilter get( String name );
+    Entry get( String name );
     
     /**
-     * Returns the name of the specified {@link IoFilter} in this chain.
+     * Returns the {@link Entry} with the specified {@link IoFilter} in this chain.
      * @return <tt>null</tt> if there's no such filter in this chain.
      */
-    String getName( IoFilter filter );
+    Entry get( IoFilter filter );
     
     /**
-     * Returns the {@link NextFilter} of the {@link IoFilter} with the specified
-     * <tt>name</tt> in this chain.
-     */
-    NextFilter getNextFilter( String name );
-
-    /**
-     * Returns the {@link NextFilter} of the specified <tt>filter</tt> in this
chain.
-     */
-    NextFilter getNextFilter( IoFilter filter );
-
-    /**
-     * Returns the list of all filters this chain contains.
+     * Returns the list of all {@link Entry}s this chain contains.
      */
     List getAll();
     
     /**
-     * Returns the reversed list of all filters this chain contains.
+     * Returns the reversed list of all {@link Entry}s this chain contains.
      */
     List getAllReversed();
 
@@ -117,13 +106,40 @@
 
     /**
      * Removes the specifiec <tt>filter</tt> from this chain.
+     * @return the name of the removed {@link IoFilter}
      * @throws Exception if {@link IoFilter#destroy(IoFilterChain, NextFilter)} thrown an
exception.
      */
-    void remove( IoFilter filter ) throws Exception;
+    String remove( IoFilter filter ) throws Exception;
 
     /**
      * Removes all filters added to this chain.
      * @throws Exception if {@link IoFilter#destroy(IoFilterChain, NextFilter)} thrown an
exception.
      */
     void clear() throws Exception;
+    
+    /**
+     * Represents a name-filter pair that an {@link IoFilterChain} contains.
+     *
+     * @author The Apache Directory Project (dev@directory.apache.org)
+     * @version $Rev$, $Date$
+     */
+    public interface Entry
+    {
+        /**
+         * Returns the name of the filter.
+         */
+        String getName();
+        
+        /**
+         * Returns the filter.
+         */
+        IoFilter getFilter();
+        
+        /**
+         * Returns the {@link NextFilter} of the filter.
+         * 
+         * @throws IllegalStateException if the {@link NextFilter} is not available
+         */
+        NextFilter getNextFilter();
+    }
 }

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/AbstractIoFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/AbstractIoFilterChain.java?rev=349899&r1=349898&r2=349899&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/AbstractIoFilterChain.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/AbstractIoFilterChain.java
Tue Nov 29 22:54:01 2005
@@ -50,24 +50,24 @@
  */
 public abstract class AbstractIoFilterChain implements IoFilterChain
 {
-    private final IoSession parent;
+    private final IoSession session;
 
     private final Map name2entry = new HashMap();
     private final Map filter2entry = new IdentityHashMap();
     
-    private final Entry head;
-    private final Entry tail;
+    private final EntryImpl head;
+    private final EntryImpl tail;
 
-    protected AbstractIoFilterChain( IoSession parent )
+    protected AbstractIoFilterChain( IoSession session )
     {
-        if( parent == null )
+        if( session == null )
         {
-            throw new NullPointerException( "parent" );
+            throw new NullPointerException( "session" );
         }
         
-        this.parent = parent;
-        head = new Entry( null, null, "head", createHeadFilter() );
-        tail = new Entry( head, null, "tail", createTailFilter() );
+        this.session = session;
+        head = new EntryImpl( null, null, "head", createHeadFilter() );
+        tail = new EntryImpl( head, null, "tail", createTailFilter() );
         head.nextEntry = tail;
     }
     
@@ -238,20 +238,20 @@
     
     public IoSession getSession()
     {
-        return parent;
+        return session;
     }
     
-    public IoFilter get( String name )
+    public Entry get( String name )
     {
         Entry e = ( Entry ) name2entry.get( name );
         if ( e == null )
         {
             return null;
         }
-        return e.filter;
+        return e;
     }
     
-    public String getName( IoFilter filter )
+    public Entry get( IoFilter filter )
     {
         Entry e = ( Entry ) filter2entry.get( filter );
         if( e == null )
@@ -259,30 +259,9 @@
             return null;
         }
         
-        return e.name;
+        return e;
     }
     
-    public NextFilter getNextFilter( String name )
-    {
-        Entry e = ( Entry ) name2entry.get( name );
-        if ( e == null )
-        {
-            return null;
-        }
-        return e.nextFilter;
-    }
-
-    public NextFilter getNextFilter( IoFilter filter )
-    {
-        Entry e = ( Entry ) filter2entry.get( filter );
-        if( e == null )
-        {
-            return null;
-        }
-        
-        return e.nextFilter;
-    }
-
     public synchronized void addFirst( String name,
                                        IoFilter filter ) throws Exception
     {
@@ -301,49 +280,50 @@
                                         String name,
                                         IoFilter filter ) throws Exception
     {
-        Entry baseEntry = checkOldName( baseName );
+        EntryImpl baseEntry = checkOldName( baseName );
         checkAddable( name );
-        register( baseEntry, name, filter );
+        register( baseEntry.prevEntry, name, filter );
     }
 
     public synchronized void addBefore( IoFilter baseFilter,
                                         String name,
                                         IoFilter filter ) throws Exception
     {
-        Entry baseEntry = getEntry( baseFilter );
+        EntryImpl baseEntry = getEntry( baseFilter );
         checkAddable( name );
-        register( baseEntry, name, filter );
+        register( baseEntry.prevEntry, name, filter );
     }
 
     public synchronized void addAfter( String baseName,
                                        String name,
                                        IoFilter filter ) throws Exception
     {
-        Entry baseEntry = checkOldName( baseName );
+        EntryImpl baseEntry = checkOldName( baseName );
         checkAddable( name );
-        register( baseEntry.prevEntry, name, filter );
+        register( baseEntry, name, filter );
     }
 
     public synchronized void addAfter( IoFilter baseFilter,
                                        String name,
                                        IoFilter filter ) throws Exception
     {
-        Entry baseEntry = getEntry( baseFilter );
+        EntryImpl baseEntry = getEntry( baseFilter );
         checkAddable( name );
-        register( baseEntry.prevEntry, name, filter );
+        register( baseEntry, name, filter );
     }
 
     public synchronized IoFilter remove( String name ) throws Exception
     {
-        Entry entry = checkOldName( name );
+        EntryImpl entry = checkOldName( name );
         deregister( entry );
-        return entry.filter;
+        return entry.getFilter();
     }
 
-    public synchronized void remove( IoFilter filter ) throws Exception
+    public synchronized String remove( IoFilter filter ) throws Exception
     {
-        Entry entry = getEntry( filter );
+        EntryImpl entry = getEntry( filter );
         deregister( entry );
+        return entry.name;
     }
 
     public synchronized void clear() throws Exception
@@ -355,11 +335,11 @@
         }
     }
 
-    private void register( Entry prevEntry, String name, IoFilter filter ) throws Exception
+    private void register( EntryImpl prevEntry, String name, IoFilter filter ) throws Exception
     {
-        Entry newEntry = new Entry( prevEntry, prevEntry.nextEntry, name, filter );
+        EntryImpl newEntry = new EntryImpl( prevEntry, prevEntry.nextEntry, name, filter
);
 
-        filter.init( this, newEntry.nextFilter );
+        filter.init( this, newEntry.getNextFilter() );
         
         prevEntry.nextEntry.prevEntry = newEntry;
         prevEntry.nextEntry = newEntry;
@@ -367,23 +347,23 @@
         filter2entry.put( filter, newEntry );
     }
     
-    private void deregister( Entry entry ) throws Exception
+    private void deregister( EntryImpl entry ) throws Exception
     {
-        Entry prevEntry = entry.prevEntry;
-        Entry nextEntry = entry.nextEntry;
+        EntryImpl prevEntry = entry.prevEntry;
+        EntryImpl nextEntry = entry.nextEntry;
         prevEntry.nextEntry = nextEntry;
         nextEntry.prevEntry = prevEntry;
 
         name2entry.remove( entry.name );
-        IoFilter filter = entry.filter;
+        IoFilter filter = entry.getFilter();
         filter2entry.remove( filter );
         
-        filter.destroy( this, entry.nextFilter );
+        filter.destroy( this, entry.getNextFilter() );
     }
 
-    private Entry getEntry( IoFilter filter )
+    private EntryImpl getEntry( IoFilter filter )
     {
-        Entry entry = ( Entry ) filter2entry.get( filter );
+        EntryImpl entry = ( EntryImpl ) filter2entry.get( filter );
         if( entry == null )
         {
             throw new IllegalArgumentException(
@@ -398,9 +378,9 @@
      *
      * @return An filter entry with the specified name.
      */
-    private Entry checkOldName( String baseName )
+    private EntryImpl checkOldName( String baseName )
     {
-        Entry e = ( Entry ) name2entry.get( baseName );
+        EntryImpl e = ( EntryImpl ) name2entry.get( baseName );
         if ( e == null )
         {
             throw new IllegalArgumentException( "Unknown filter name:" +
@@ -431,7 +411,7 @@
     {
         try
         {
-            entry.filter.sessionCreated( entry.nextFilter, session );
+            entry.getFilter().sessionCreated( entry.getNextFilter(), session );
         }
         catch( Throwable e )
         {
@@ -450,7 +430,7 @@
     {
         try
         {
-            entry.filter.sessionOpened( entry.nextFilter, session );
+            entry.getFilter().sessionOpened( entry.getNextFilter(), session );
         }
         catch( Throwable e )
         {
@@ -469,7 +449,7 @@
     {
         try
         {
-            entry.filter.sessionClosed( entry.nextFilter, session );
+            entry.getFilter().sessionClosed( entry.getNextFilter(), session );
                 
         }
         catch( Throwable e )
@@ -490,7 +470,7 @@
     {
         try
         {
-            entry.filter.sessionIdle( entry.nextFilter, session, status );
+            entry.getFilter().sessionIdle( entry.getNextFilter(), session, status );
         }
         catch( Throwable e )
         {
@@ -510,7 +490,7 @@
     {
         try
         {
-            entry.filter.messageReceived( entry.nextFilter, session, message );
+            entry.getFilter().messageReceived( entry.getNextFilter(), session, message );
         }
         catch( Throwable e )
         {
@@ -530,7 +510,7 @@
     {
         try
         {
-            entry.filter.messageSent( entry.nextFilter, session, message );
+            entry.getFilter().messageSent( entry.getNextFilter(), session, message );
         }
         catch( Throwable e )
         {
@@ -550,7 +530,7 @@
     {
         try
         {
-            entry.filter.exceptionCaught( entry.nextFilter, session, cause );
+            entry.getFilter().exceptionCaught( entry.getNextFilter(), session, cause );
         }
         catch( Throwable e )
         {
@@ -572,7 +552,7 @@
     {
         try
         {
-            entry.filter.filterWrite( entry.nextFilter, session, writeRequest );
+            entry.getFilter().filterWrite( entry.getNextFilter(), session, writeRequest );
         }
         catch( Throwable e )
         {
@@ -592,7 +572,7 @@
     {
         try
         {
-            entry.filter.filterClose( entry.nextFilter, session, closeFuture );
+            entry.getFilter().filterClose( entry.getNextFilter(), session, closeFuture );
         }
         catch( Throwable e )
         {
@@ -603,10 +583,10 @@
     public List getAll()
     {
         List list = new ArrayList();
-        Entry e = head.nextEntry;
+        EntryImpl e = head.nextEntry;
         while( e != tail )
         {
-            list.add( e.filter );
+            list.add( e );
             e = e.nextEntry;
         }
 
@@ -616,10 +596,10 @@
     public List getAllReversed()
     {
         List list = new ArrayList();
-        Entry e = tail.prevEntry;
+        EntryImpl e = tail.prevEntry;
         while( e != head )
         {
-            list.add( e.filter );
+            list.add( e );
             e = e.prevEntry;
         }
         return list;
@@ -641,11 +621,11 @@
     
     protected abstract void doClose( IoSession session, CloseFuture closeFuture ) throws
Exception;
 
-    private class Entry
+    private class EntryImpl implements Entry
     {
-        private Entry prevEntry;
+        private EntryImpl prevEntry;
 
-        private Entry nextEntry;
+        private EntryImpl nextEntry;
 
         private final String name;
         
@@ -653,7 +633,7 @@
 
         private final NextFilter nextFilter;
         
-        private Entry( Entry prevEntry, Entry nextEntry,
+        private EntryImpl( EntryImpl prevEntry, EntryImpl nextEntry,
                        String name, IoFilter filter )
         {
             if( filter == null )
@@ -673,56 +653,56 @@
             {
                 public void sessionCreated( IoSession session )
                 {
-                    Entry nextEntry = Entry.this.nextEntry;
+                    Entry nextEntry = EntryImpl.this.nextEntry;
                     callNextSessionCreated( nextEntry, session );
                 }
 
                 public void sessionOpened( IoSession session )
                 {
-                    Entry nextEntry = Entry.this.nextEntry;
+                    Entry nextEntry = EntryImpl.this.nextEntry;
                     callNextSessionOpened( nextEntry, session );
                 }
 
                 public void sessionClosed( IoSession session )
                 {
-                    Entry nextEntry = Entry.this.nextEntry;
+                    Entry nextEntry = EntryImpl.this.nextEntry;
                     callNextSessionClosed( nextEntry, session );
                 }
 
                 public void sessionIdle( IoSession session, IdleStatus status )
                 {
-                    Entry nextEntry = Entry.this.nextEntry;
+                    Entry nextEntry = EntryImpl.this.nextEntry;
                     callNextSessionIdle( nextEntry, session, status );
                 }
 
                 public void exceptionCaught( IoSession session,
                                             Throwable cause )
                 {
-                    Entry nextEntry = Entry.this.nextEntry;
+                    Entry nextEntry = EntryImpl.this.nextEntry;
                     callNextExceptionCaught( nextEntry, session, cause );
                 }
 
                 public void messageReceived( IoSession session, Object message )
                 {
-                    Entry nextEntry = Entry.this.nextEntry;
+                    Entry nextEntry = EntryImpl.this.nextEntry;
                     callNextMessageReceived( nextEntry, session, message );
                 }
 
                 public void messageSent( IoSession session, Object message )
                 {
-                    Entry nextEntry = Entry.this.nextEntry;
+                    Entry nextEntry = EntryImpl.this.nextEntry;
                     callNextMessageSent( nextEntry, session, message );
                 }
                 
                 public void filterWrite( IoSession session, WriteRequest writeRequest )
                 {
-                    Entry nextEntry = Entry.this.prevEntry;
+                    Entry nextEntry = EntryImpl.this.prevEntry;
                     callPreviousFilterWrite( nextEntry, session, writeRequest );
                 }
 
                 public void filterClose( IoSession session, CloseFuture closeFuture )
                 {
-                    Entry nextEntry = Entry.this.prevEntry;
+                    Entry nextEntry = EntryImpl.this.prevEntry;
                     callPreviousFilterClose( nextEntry, session, closeFuture );
                 }
             };
@@ -736,6 +716,11 @@
         public IoFilter getFilter()
         {
             return filter;
+        }
+        
+        public NextFilter getNextFilter()
+        {
+            return nextFilter;
         }
     }
 }

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/SSLFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/SSLFilter.java?rev=349899&r1=349898&r2=349899&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/SSLFilter.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/SSLFilter.java
Tue Nov 29 22:54:01 2005
@@ -179,7 +179,7 @@
                 }
             }
             
-            createSSLSessionHandler( parent.getNextFilter( this ), session );
+            createSSLSessionHandler( parent.get( this ).getNextFilter(), session );
             return true;
         }
     }
@@ -228,7 +228,7 @@
                 throw new IllegalArgumentException( "Not managed by this filter." );
             }
             
-            NextFilter nextFilter = parent.getNextFilter( this );
+            NextFilter nextFilter = parent.get( this ).getNextFilter();
             return initiateClosure( nextFilter, session );
         }
     }

Modified: directory/network/branches/chain_refactor/src/test/org/apache/mina/common/IoFilterChainTest.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/test/org/apache/mina/common/IoFilterChainTest.java?rev=349899&r1=349898&r2=349899&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/test/org/apache/mina/common/IoFilterChainTest.java
(original)
+++ directory/network/branches/chain_refactor/src/test/org/apache/mina/common/IoFilterChainTest.java
Tue Nov 29 22:54:01 2005
@@ -19,11 +19,13 @@
 package org.apache.mina.common;
 
 import java.net.SocketAddress;
+import java.util.Iterator;
 
 import junit.framework.Assert;
 import junit.framework.TestCase;
 
 import org.apache.mina.common.IoFilter.WriteRequest;
+import org.apache.mina.common.IoFilterChain.Entry;
 import org.apache.mina.common.support.AbstractIoFilterChain;
 import org.apache.mina.common.support.BaseIoSession;
 
@@ -50,6 +52,57 @@
     {
     }
     
+    public void testAdd() throws Exception
+    {
+        chain.addFirst( "A", new EventOrderTestFilter( 'A' ) );
+        chain.addLast( "B", new EventOrderTestFilter( 'A' ) );
+        chain.addFirst( "C", new EventOrderTestFilter( 'A' ) );
+        chain.addLast( "D", new EventOrderTestFilter( 'A' ) );
+        chain.addBefore( "B", "E", new EventOrderTestFilter( 'A' ) );
+        chain.addBefore( "C", "F", new EventOrderTestFilter( 'A' ) );
+        chain.addAfter( "B", "G", new EventOrderTestFilter( 'A' ) );
+        chain.addAfter( "D", "H", new EventOrderTestFilter( 'A' ) );
+        
+        String actual = "";
+        for( Iterator i = chain.getAll().iterator(); i.hasNext(); ) 
+        {
+            Entry e = ( Entry ) i.next();
+            actual += e.getName();
+        }
+        
+        Assert.assertEquals( "FCAEBGDH", actual );
+    }
+    
+    public void testRemove() throws Exception
+    {
+        chain.addLast( "A", new EventOrderTestFilter( 'A' ) );
+        chain.addLast( "B", new EventOrderTestFilter( 'A' ) );
+        chain.addLast( "C", new EventOrderTestFilter( 'A' ) );
+        chain.addLast( "D", new EventOrderTestFilter( 'A' ) );
+        chain.addLast( "E", new EventOrderTestFilter( 'A' ) );
+        
+        chain.remove( "A" );
+        chain.remove( "E" );
+        chain.remove( "C" );
+        chain.remove( "B" );
+        chain.remove( "D" );
+        
+        Assert.assertEquals( 0, chain.getAll().size() );
+    }
+    
+    public void testClear() throws Exception
+    {
+        chain.addLast( "A", new EventOrderTestFilter( 'A' ) );
+        chain.addLast( "B", new EventOrderTestFilter( 'A' ) );
+        chain.addLast( "C", new EventOrderTestFilter( 'A' ) );
+        chain.addLast( "D", new EventOrderTestFilter( 'A' ) );
+        chain.addLast( "E", new EventOrderTestFilter( 'A' ) );
+        
+        chain.clear();
+        
+        Assert.assertEquals( 0, chain.getAll().size() );
+    }
+    
     public void testDefault()
     {
         run( "HS0 HSO HMR HMS HSI HEC HSC" );
@@ -205,6 +258,11 @@
         {
             return false;
         }
+
+        public IoSessionManager getManager()
+        {
+            return null;
+        }
     }
 
     private class EventOrderTestFilter implements IoFilter
@@ -289,7 +347,47 @@
     {
         protected IoFilterChainImpl()
         {
-            super( new Object() );
+            super( new BaseIoSession()
+            {
+                protected void updateTrafficMask()
+                {
+                }
+
+                public IoSessionManager getManager()
+                {
+                    return null;
+                }
+
+                public IoHandler getHandler()
+                {
+                    return null;
+                }
+
+                public IoFilterChain getFilterChain()
+                {
+                    return null;
+                }
+
+                public TransportType getTransportType()
+                {
+                    return null;
+                }
+
+                public SocketAddress getRemoteAddress()
+                {
+                    return null;
+                }
+
+                public SocketAddress getLocalAddress()
+                {
+                    return null;
+                }
+
+                public int getScheduledWriteRequests()
+                {
+                    return 0;
+                }
+            } );
         }
 
         protected void doWrite( IoSession session, WriteRequest writeRequest )

Modified: directory/network/branches/chain_refactor/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java?rev=349899&r1=349898&r2=349899&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
(original)
+++ directory/network/branches/chain_refactor/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
Tue Nov 29 22:54:01 2005
@@ -10,6 +10,7 @@
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoSession;
+import org.apache.mina.common.IoSessionManager;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.common.WriteFuture;
 import org.apache.mina.common.IoFilter.NextFilter;
@@ -19,7 +20,7 @@
 
 public class ThreadPoolFilterRegressionTest extends TestCase
 {
-    private static final IoFilterChain FILTER_PARENT = new AbstractIoFilterChain( new Object()
)
+    private static final IoFilterChain FILTER_PARENT = new AbstractIoFilterChain( new DummySession()
)
     {
         protected void doWrite( IoSession session, WriteRequest writeRequest )
         {
@@ -194,6 +195,11 @@
         {
             return false;
         }
+
+        public IoSessionManager getManager()
+        {
+            return null;
+        }
     }
     
     private static class EventOrderChecker implements NextFilter
@@ -302,6 +308,11 @@
         public boolean isClosing()
         {
             return false;
+        }
+
+        public IoSessionManager getManager()
+        {
+            return null;
         }
     }
     

Modified: directory/network/branches/chain_refactor/src/test/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/test/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java?rev=349899&r1=349898&r2=349899&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/test/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java
(original)
+++ directory/network/branches/chain_refactor/src/test/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java
Tue Nov 29 22:54:01 2005
@@ -30,6 +30,7 @@
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoSession;
+import org.apache.mina.common.IoSessionManager;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.common.WriteFuture;
 import org.apache.mina.common.support.BaseIoSession;
@@ -234,6 +235,11 @@
         public boolean isClosing()
         {
             return false;
+        }
+
+        public IoSessionManager getManager()
+        {
+            return null;
         }
     }
 }

Modified: directory/network/trunk/src/java/org/apache/mina/handler/StreamIoHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/handler/StreamIoHandler.java?rev=349899&r1=349898&r2=349899&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/handler/StreamIoHandler.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/handler/StreamIoHandler.java Tue Nov
29 22:54:01 2005
@@ -1,4 +1,4 @@
-/*
+ /*
  *   @(#) $Id$
  *
  *   Copyright 2004 The Apache Software Foundation



Mime
View raw message