directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r349943 - in /directory/network/branches/chain_refactor/src: examples/org/apache/mina/examples/echoserver/ examples/org/apache/mina/examples/httpserver/ examples/org/apache/mina/examples/sumup/ java/org/apache/mina/common/ java/org/apache/m...
Date Wed, 30 Nov 2005 13:27:20 GMT
Author: trustin
Date: Wed Nov 30 05:27:01 2005
New Revision: 349943

URL: http://svn.apache.org/viewcvs?rev=349943&view=rev
Log:
* Renamed IoFilterChain.get() to getEntry()
* Added IoFilterChain.getFilter()
* Added IoFilterChain.getNextFilter()

These changes are also applied to DefaultIoFilterChainBuilder.

Modified:
    directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/echoserver/Main.java
    directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/httpserver/Main.java
    directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/Client.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/DefaultIoFilterChainBuilder.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/integration/spring/support/AbstractIoSessionManagerFactoryBean.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
    directory/network/branches/chain_refactor/src/test/org/apache/mina/common/DefaultIoFilterChainBuilderTest.java
    directory/network/branches/chain_refactor/src/test/org/apache/mina/common/IoFilterChainTest.java
    directory/network/branches/chain_refactor/src/test/org/apache/mina/examples/echoserver/AbstractTest.java
    directory/network/branches/chain_refactor/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java
    directory/network/branches/chain_refactor/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java

Modified: directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/echoserver/Main.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/echoserver/Main.java?rev=349943&r1=349942&r2=349943&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/echoserver/Main.java
(original)
+++ directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/echoserver/Main.java
Wed Nov 30 05:27:01 2005
@@ -18,7 +18,6 @@
  */
 package org.apache.mina.examples.echoserver;
 
-import org.apache.mina.common.DefaultIoFilterChainBuilder;
 import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
@@ -67,14 +66,14 @@
         SSLFilter sslFilter =
             new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
         IoAcceptor acceptor = registry.getAcceptor( TransportType.SOCKET );
-        ( ( DefaultIoFilterChainBuilder ) acceptor.getFilterChainBuilder() ).addLast( "sslFilter",
sslFilter );
+        acceptor.getFilterChain().addLast( "sslFilter", sslFilter );
         System.out.println( "SSL ON" );
     }
     
     private static void addLogger( ServiceRegistry registry ) throws Exception
     {
         IoAcceptor acceptor = registry.getAcceptor( TransportType.SOCKET );
-        ( ( DefaultIoFilterChainBuilder ) acceptor.getFilterChainBuilder() ).addLast( "logger",
new LoggingFilter() );
+        acceptor.getFilterChain().addLast( "logger", new LoggingFilter() );
         System.out.println( "Logging ON" );
     }
 }

Modified: directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/httpserver/Main.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/httpserver/Main.java?rev=349943&r1=349942&r2=349943&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/httpserver/Main.java
(original)
+++ directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/httpserver/Main.java
Wed Nov 30 05:27:01 2005
@@ -18,7 +18,6 @@
  */
 package org.apache.mina.examples.httpserver;
 
-import org.apache.mina.common.DefaultIoFilterChainBuilder;
 import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
@@ -65,6 +64,6 @@
         SSLFilter sslFilter =
             new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
         IoAcceptor acceptor = registry.getAcceptor( TransportType.SOCKET );
-        ( ( DefaultIoFilterChainBuilder ) acceptor.getFilterChainBuilder() ).addLast( "sslFilter",
sslFilter );
+        acceptor.getFilterChain().addLast( "sslFilter", sslFilter );
     }
 }

Modified: directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/Client.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/Client.java?rev=349943&r1=349942&r2=349943&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/Client.java
(original)
+++ directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/Client.java
Wed Nov 30 05:27:01 2005
@@ -22,7 +22,6 @@
 import java.net.InetSocketAddress;
 
 import org.apache.mina.common.ConnectFuture;
-import org.apache.mina.common.DefaultIoFilterChainBuilder;
 import org.apache.mina.common.IoConnector;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.filter.ThreadPoolFilter;
@@ -63,9 +62,9 @@
         ThreadPoolFilter ioThreadPoolFilter = new ThreadPoolFilter();
         ThreadPoolFilter protocolThreadPoolFilter = new ThreadPoolFilter();
         IoConnector connector = new SocketConnector();
-        ( ( DefaultIoFilterChainBuilder ) connector.getFilterChainBuilder() ).addFirst(
+        connector.getFilterChain().addFirst(
                 "ioThreadPool", ioThreadPoolFilter );
-        ( ( DefaultIoFilterChainBuilder ) connector.getFilterChainBuilder() ).addLast(
+        connector.getFilterChain().addLast(
                 "protocolThreadPool", protocolThreadPoolFilter );
 
         // Set connect timeout.

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/DefaultIoFilterChainBuilder.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/DefaultIoFilterChainBuilder.java?rev=349943&r1=349942&r2=349943&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/DefaultIoFilterChainBuilder.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/DefaultIoFilterChainBuilder.java
Wed Nov 30 05:27:01 2005
@@ -21,7 +21,6 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.IdentityHashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
@@ -40,7 +39,6 @@
 {
     private List entries = new ArrayList();
     private final Map entriesByName = new HashMap();
-    private final Map entriesByFilter = new IdentityHashMap();
     
     /**
      * Creates a new instance with an empty filter list.
@@ -55,18 +53,20 @@
      * 
      * @return <tt>null</tt> if there's no such filter in the filter list
      */
-    public synchronized Entry get( String name )
+    public synchronized Entry getEntry( String name )
     {
         return ( Entry ) entriesByName.get( name );
     }
     
-    /**
-     * Returns the name of the specified {@link IoFilter} in the filter list.
-     * @return <tt>null</tt> if there's no such filter in the filter list.
-     */
-    public synchronized Entry get( IoFilter filter )
+    public synchronized IoFilter getFilter( String name )
     {
-        return ( Entry ) entriesByFilter.get( filter );
+        Entry e = getEntry( name );
+        if( e == null )
+        {
+            return null;
+        }
+        
+        return e.getFilter();
     }
     
     /**
@@ -169,36 +169,12 @@
     }
 
     /**
-     * Removes the specifiec <tt>filter</tt> from this chain.
-     * 
-     * @return the name of the removed {@link IoFilter}
-     */
-    public synchronized String remove( IoFilter filter )
-    {
-        if( filter == null )
-        {
-            throw new NullPointerException( "filter" );
-        }
-        
-        Entry e = get( filter );
-        if( e == null )
-        {
-            throw new IllegalArgumentException( "The specified filter doesn't belong to this
builder." );
-        }
-        
-        String name = e.getName();
-        remove( name );
-        return name;
-    }
-
-    /**
      * Removes all filters added to this chain.
      */
     public synchronized void clear() throws Exception
     {
         entries = new ArrayList();
         entriesByName.clear();
-        entriesByFilter.clear();
     }
     
     public void buildFilterChain( IoFilterChain chain ) throws Exception
@@ -269,7 +245,6 @@
         newEntries.add( index, e );
         this.entries = newEntries;
         entriesByName.put( e.getName(), e );
-        entriesByFilter.put( e.getFilter(), e );
     }
     
     private void deregister( int index, Entry e )
@@ -278,7 +253,6 @@
         newEntries.remove( index );
         this.entries = newEntries;
         entriesByName.remove( e.getName() );
-        entriesByFilter.remove( e.getFilter() );
     }
 
     private static class EntryImpl implements Entry

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=349943&r1=349942&r2=349943&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
Wed Nov 30 05:27:01 2005
@@ -40,7 +40,20 @@
      * 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
      */
-    Entry get( String name );
+    Entry getEntry( String name );
+    
+    /**
+     * Returns the {@link IoFilter} with the specified <tt>name</tt> in this
chain.
+     * @return <tt>null</tt> if there's no such name in this chain
+     */
+    IoFilter getFilter( String name );
+    
+    /**
+     * Returns the {@link NextFilter} of the {@link IoFilter} with the
+     * specified <tt>name</tt> in this chain.
+     * @return <tt>null</tt> if there's no such name in this chain
+     */
+    NextFilter getNextFilter( String name );
     
     /**
      * Returns the list of all {@link Entry}s this chain contains.

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=349943&r1=349942&r2=349943&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
Wed Nov 30 05:27:01 2005
@@ -241,7 +241,7 @@
         return session;
     }
     
-    public Entry get( String name )
+    public Entry getEntry( String name )
     {
         Entry e = ( Entry ) name2entry.get( name );
         if ( e == null )
@@ -249,6 +249,28 @@
             return null;
         }
         return e;
+    }
+    
+    public IoFilter getFilter( String name )
+    {
+        Entry e = getEntry( name );
+        if( e == null )
+        {
+            return null;
+        }
+        
+        return e.getFilter();
+    }
+    
+    public NextFilter getNextFilter( String name )
+    {
+        Entry e = getEntry( name );
+        if( e == null )
+        {
+            return null;
+        }
+        
+        return e.getNextFilter();
     }
     
     public synchronized void addFirst( String name,

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/integration/spring/support/AbstractIoSessionManagerFactoryBean.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/integration/spring/support/AbstractIoSessionManagerFactoryBean.java?rev=349943&r1=349942&r2=349943&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/integration/spring/support/AbstractIoSessionManagerFactoryBean.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/integration/spring/support/AbstractIoSessionManagerFactoryBean.java
Wed Nov 30 05:27:01 2005
@@ -72,7 +72,7 @@
         /*
          * Add filters to the end of the filter chain.
          */
-        DefaultIoFilterChainBuilder builder = ( DefaultIoFilterChainBuilder ) sessionManager.getFilterChainBuilder();
+        DefaultIoFilterChainBuilder builder = sessionManager.getFilterChain();
         for( int i = 0; i < filterMappings.length; i++ )
         {
             builder.addLast( filterMappings[ i ].getName(),
@@ -94,8 +94,7 @@
         /*
          * Remove all filters.
          */
-        DefaultIoFilterChainBuilder builder = ( DefaultIoFilterChainBuilder ) sessionManager.getFilterChainBuilder();
-        builder.clear();
+        sessionManager.getFilterChain().clear();
     }
 
     /**

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/registry/SimpleServiceRegistry.java?rev=349943&r1=349942&r2=349943&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
Wed Nov 30 05:27:01 2005
@@ -11,6 +11,7 @@
 import java.util.Set;
 
 import org.apache.mina.common.IoAcceptor;
+import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoFilterChainBuilder;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.TransportType;
@@ -57,8 +58,9 @@
         {
             filterChainBuilder = IoFilterChainBuilder.NOOP;
         }
-        acceptor.bind( service.getAddress(), handler, filterChainBuilder );
-        startThreadPools();
+        acceptor.bind(
+                service.getAddress(), handler,
+                new IoFilterChainBuilderWrapper( filterChainBuilder ) );
         services.add( service );
     }
 
@@ -76,7 +78,6 @@
         }
         
         services.remove( service );
-        stopThreadPools();
     }
     
     public synchronized void unbindAll()
@@ -170,50 +171,26 @@
             return vmPipeAcceptor;
 
     }
-
-    private void startThreadPools()
-    {
-        // Start thread pools only when the first service is bound.
-        // If any services are bound, it means that thread pools are started
-        // already.
-        if( !services.isEmpty() )
-            return;
-
-        try
-        {
-            // FIXME HERE
-            /*
-            socketIoAcceptor.getFilterChain().addFirst( "threadPool", threadPoolFilter );
-            datagramIoAcceptor.getFilterChain().addFirst( "threadPool", threadPoolFilter
);
-            vmPipeAcceptor.getFilterChain().addFirst( "threadPool", threadPoolFilter );
-            */
-        }
-        catch( Exception e )
-        {
-            throw ( InternalError ) new InternalError( "Unexpected exception." ).initCause(
e );
-        }
-    }
-
-    private void stopThreadPools()
+    
+    private class IoFilterChainBuilderWrapper implements IoFilterChainBuilder
     {
-        // Stop thread pools only when all services are unbound.
-        if( !services.isEmpty() )
-            return;
-
-        try
+        private final IoFilterChainBuilder originalBuilder;
+        
+        private IoFilterChainBuilderWrapper( IoFilterChainBuilder originalBuilder )
         {
-            // FIXME HERE
-            /*
-            socketIoAcceptor.getFilterChain().remove( "threadPool" );
-            datagramIoAcceptor.getFilterChain().remove( "threadPool" );
-            vmPipeAcceptor.getFilterChain().remove( "threadPool" );
-            */
+            this.originalBuilder = originalBuilder;
         }
-        catch( Exception e )
+        
+        public void buildFilterChain( IoFilterChain chain ) throws Exception
         {
-            throw ( InternalError ) new InternalError( "Unexpected exception." ).initCause(
e );
+            try
+            {
+                originalBuilder.buildFilterChain( chain );
+            }
+            finally
+            {
+                chain.addFirst( "threadPool", threadPoolFilter );
+            }
         }
     }
-    
-    private class IoFilterChainBuilderImpl 
 }

Modified: directory/network/branches/chain_refactor/src/test/org/apache/mina/common/DefaultIoFilterChainBuilderTest.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/test/org/apache/mina/common/DefaultIoFilterChainBuilderTest.java?rev=349943&r1=349942&r2=349943&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/test/org/apache/mina/common/DefaultIoFilterChainBuilderTest.java
(original)
+++ directory/network/branches/chain_refactor/src/test/org/apache/mina/common/DefaultIoFilterChainBuilderTest.java
Wed Nov 30 05:27:01 2005
@@ -83,10 +83,10 @@
         builder.addBefore( "B", "C", filterC );
         builder.addAfter( "A", "D", filterD );
         
-        Assert.assertSame( filterA, builder.get( "A" ).getFilter() );
-        Assert.assertSame( filterB, builder.get( "B" ).getFilter() );
-        Assert.assertSame( filterC, builder.get( "C" ).getFilter() );
-        Assert.assertSame( filterD, builder.get( "D" ).getFilter() );
+        Assert.assertSame( filterA, builder.getFilter( "A" ) );
+        Assert.assertSame( filterB, builder.getFilter( "B" ) );
+        Assert.assertSame( filterC, builder.getFilter( "C" ) );
+        Assert.assertSame( filterD, builder.getFilter( "D" ) );
     }
     
     public void testRemove() throws Exception

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=349943&r1=349942&r2=349943&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
Wed Nov 30 05:27:01 2005
@@ -85,10 +85,10 @@
         chain.addBefore( "B", "C", filterC );
         chain.addAfter( "A", "D", filterD );
         
-        Assert.assertSame( filterA, chain.get( "A" ).getFilter() );
-        Assert.assertSame( filterB, chain.get( "B" ).getFilter() );
-        Assert.assertSame( filterC, chain.get( "C" ).getFilter() );
-        Assert.assertSame( filterD, chain.get( "D" ).getFilter() );
+        Assert.assertSame( filterA, chain.getFilter( "A" ) );
+        Assert.assertSame( filterB, chain.getFilter( "B" ) );
+        Assert.assertSame( filterC, chain.getFilter( "C" ) );
+        Assert.assertSame( filterD, chain.getFilter( "D" ) );
     }
     
     public void testRemove() throws Exception

Modified: directory/network/branches/chain_refactor/src/test/org/apache/mina/examples/echoserver/AbstractTest.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/test/org/apache/mina/examples/echoserver/AbstractTest.java?rev=349943&r1=349942&r2=349943&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/test/org/apache/mina/examples/echoserver/AbstractTest.java
(original)
+++ directory/network/branches/chain_refactor/src/test/org/apache/mina/examples/echoserver/AbstractTest.java
Wed Nov 30 05:27:01 2005
@@ -23,7 +23,6 @@
 import junit.framework.TestCase;
 
 import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.DefaultIoFilterChainBuilder;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.filter.LoggingFilter;
@@ -114,7 +113,7 @@
                         if( buf.remaining() == 1 && buf.get() == ( byte ) '.' )
                         {
                             SessionLog.info( session, "TLS Reentrance" );
-                            ( ( SSLFilter ) ( ( DefaultIoFilterChainBuilder ) acceptor.getFilterChainBuilder()
).get( "SSL" ).getFilter() ).startSSL( session );
+                            ( ( SSLFilter ) acceptor.getFilterChain().getFilter( "SSL" )
).startSSL( session );
 
                             // Send a response
                             buf = ByteBuffer.allocate( 1 );
@@ -154,8 +153,8 @@
             throw new IOException( "Cannot bind any test port." );
         }
 
-        ( ( DefaultIoFilterChainBuilder ) registry.getAcceptor( TransportType.SOCKET ).getFilterChainBuilder()
).addLast( "logger", new LoggingFilter() );
-        ( ( DefaultIoFilterChainBuilder ) registry.getAcceptor( TransportType.DATAGRAM ).getFilterChainBuilder()
).addLast( "logger", new LoggingFilter() );
+        registry.getAcceptor( TransportType.SOCKET ).getFilterChain().addLast( "logger",
new LoggingFilter() );
+        registry.getAcceptor( TransportType.DATAGRAM ).getFilterChain().addLast( "logger",
new LoggingFilter() );
 
         System.out.println( "Using port " + port + " for testing." );
     }
@@ -163,7 +162,7 @@
     protected void tearDown() throws Exception
     {
         registry.unbindAll();
-        ( ( DefaultIoFilterChainBuilder ) registry.getAcceptor( TransportType.SOCKET ).getFilterChainBuilder()
).remove( "logger" );
-        ( ( DefaultIoFilterChainBuilder ) registry.getAcceptor( TransportType.DATAGRAM ).getFilterChainBuilder()
).remove( "logger" );
+        registry.getAcceptor( TransportType.SOCKET ).getFilterChain().remove( "logger" );
+        registry.getAcceptor( TransportType.DATAGRAM ).getFilterChain().remove( "logger"
);
     }
 }

Modified: directory/network/branches/chain_refactor/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java?rev=349943&r1=349942&r2=349943&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java
(original)
+++ directory/network/branches/chain_refactor/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java
Wed Nov 30 05:27:01 2005
@@ -30,7 +30,6 @@
 
 import org.apache.commons.net.EchoTCPClient;
 import org.apache.commons.net.EchoUDPClient;
-import org.apache.mina.common.DefaultIoFilterChainBuilder;
 import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
@@ -62,7 +61,7 @@
         SSLFilter sslFilter =
             new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
         IoAcceptor acceptor = registry.getAcceptor( TransportType.SOCKET );
-        ( ( DefaultIoFilterChainBuilder ) acceptor.getFilterChainBuilder() ).addLast( "SSL",
sslFilter );
+        acceptor.getFilterChain().addLast( "SSL", sslFilter );
         
         // Create a commons-net socket factory
         SSLSocketFactory.setSslEnabled(true);

Modified: directory/network/branches/chain_refactor/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java?rev=349943&r1=349942&r2=349943&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java
(original)
+++ directory/network/branches/chain_refactor/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java
Wed Nov 30 05:27:01 2005
@@ -26,14 +26,12 @@
 
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.ConnectFuture;
-import org.apache.mina.common.DefaultIoFilterChainBuilder;
 import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.IoConnector;
 import org.apache.mina.common.IoHandlerAdapter;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.common.WriteFuture;
-import org.apache.mina.common.IoFilterChain.Entry;
 import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
 import org.apache.mina.filter.LoggingFilter;
 import org.apache.mina.filter.SSLFilter;
@@ -70,7 +68,7 @@
         SSLFilter acceptorSSLFilter =
             new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
         IoAcceptor acceptor = registry.getAcceptor( TransportType.SOCKET );
-        ( ( DefaultIoFilterChainBuilder ) acceptor.getFilterChainBuilder() ).addLast( "SSL",
acceptorSSLFilter );
+        acceptor.getFilterChain().addLast( "SSL", acceptorSSLFilter );
         
         // Create a connector
         IoConnector connector = new SocketConnector();
@@ -79,7 +77,7 @@
         SSLFilter connectorSSLFilter =
             new SSLFilter( BogusSSLContextFactory.getInstance( false ) );
         connectorSSLFilter.setUseClientMode( true ); // set client mode
-        ( ( DefaultIoFilterChainBuilder ) connector.getFilterChainBuilder() ).addLast( "SSL",
connectorSSLFilter );
+        connector.getFilterChain().addLast( "SSL", connectorSSLFilter );
 
         testConnector( connector );
     }
@@ -144,11 +142,10 @@
         testConnector0( session );
         
         // Send closeNotify to test TLS closure if it is TLS connection.
-        Entry sslFilterEntry = ( ( DefaultIoFilterChainBuilder ) connector.getFilterChainBuilder()
).get( "SSL" );
-        if( sslFilterEntry != null )
+        SSLFilter sslf = ( SSLFilter ) connector.getFilterChain().getFilter( "SSL" );
+        if( sslf != null )
         {
-            SSLFilter sslf = ( SSLFilter ) sslFilterEntry .getFilter();
-            ( ( DefaultIoFilterChainBuilder ) connector.getFilterChainBuilder() ).addFirst(
"log", new LoggingFilter() );
+            connector.getFilterChain().addFirst( "log", new LoggingFilter() );
             sslf.stopSSL( session ).join();
             
             System.out.println( "-------------------------------------------------------------------------------"
);
@@ -175,7 +172,7 @@
             // Now start TLS connection
             Assert.assertTrue( sslf.startSSL( session ) );
             testConnector0( session );
-            ( ( DefaultIoFilterChainBuilder ) connector.getFilterChainBuilder() ).remove(
"log" );
+            connector.getFilterChain().remove( "log" );
         }
         
         session.close().join();



Mime
View raw message