directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r165577 - in /directory/network/trunk/src: examples/org/apache/mina/examples/echoserver/ examples/org/apache/mina/examples/httpserver/ examples/org/apache/mina/examples/netcat/ examples/org/apache/mina/examples/registry/ examples/org/apache/mina/examples/reverser/ examples/org/apache/mina/examples/tennis/ java/org/apache/mina/registry/ test/org/apache/mina/examples/echoserver/
Date Mon, 02 May 2005 04:22:34 GMT
Author: trustin
Date: Sun May  1 21:22:31 2005
New Revision: 165577

URL: http://svn.apache.org/viewcvs?rev=165577&view=rev
Log:
* Simplified examples and test cases with registry
* Updated ServiceRegistry and its implementation according to recent changes

Modified:
    directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java
    directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/Main.java
    directory/network/trunk/src/examples/org/apache/mina/examples/netcat/Main.java
    directory/network/trunk/src/examples/org/apache/mina/examples/registry/Main.java
    directory/network/trunk/src/examples/org/apache/mina/examples/reverser/Main.java
    directory/network/trunk/src/examples/org/apache/mina/examples/tennis/Main.java
    directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java
    directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
    directory/network/trunk/src/test/org/apache/mina/examples/echoserver/AbstractTest.java
    directory/network/trunk/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java
    directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java?rev=165577&r1=165576&r2=165577&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java Sun
May  1 21:22:31 2005
@@ -18,14 +18,13 @@
  */
 package org.apache.mina.examples.echoserver;
 
-import java.net.InetSocketAddress;
-
+import org.apache.mina.common.TransportType;
 import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
-import org.apache.mina.io.IoAcceptor;
-import org.apache.mina.io.datagram.DatagramAcceptor;
-import org.apache.mina.io.filter.IoThreadPoolFilter;
+import org.apache.mina.io.IoFilterChain;
 import org.apache.mina.io.filter.SSLFilter;
-import org.apache.mina.io.socket.SocketAcceptor;
+import org.apache.mina.registry.Service;
+import org.apache.mina.registry.ServiceRegistry;
+import org.apache.mina.registry.SimpleServiceRegistry;
 
 /**
  * (<b>Entry point</b>) Echo server
@@ -43,40 +42,28 @@
 
     public static void main( String[] args ) throws Exception
     {
-        // Create a I/O thread pool filter 
-        IoThreadPoolFilter threadPoolFilter = new IoThreadPoolFilter();
-        threadPoolFilter.start(); // and start it
-
-        // Create a TCP/IP acceptor
-        IoAcceptor acceptor = new SocketAcceptor();
-
-        // Add thread pool filter
-        // MINA runs in a single thread if you don't add this filter.
-        acceptor.getFilterChain().addFirst( "threadPool", threadPoolFilter );
-
+        ServiceRegistry registry = new SimpleServiceRegistry();
+        
         // Add SSL filter if SSL is enabled.
         if( USE_SSL )
         {
-            System.out.println( "SSL is enabled." );
-            SSLFilter sslFilter = new SSLFilter( BogusSSLContextFactory
-                    .getInstance( true ) );
-            acceptor.getFilterChain().addLast( "sslFilter", sslFilter );
+            addSSLSupport( registry );
         }
 
         // Bind
-        acceptor.bind( new InetSocketAddress( PORT ),
-                new EchoProtocolHandler() );
-
-        // Create a UDP/IP acceptor
-        IoAcceptor datagramAcceptor = new DatagramAcceptor();
-
-        // Add thread pool filter
-        datagramAcceptor.getFilterChain().addFirst( "threadPool", threadPoolFilter );
-
-        // Bind
-        datagramAcceptor.bind( new InetSocketAddress( PORT ),
-                new EchoProtocolHandler() );
+        Service service = new Service( "echo", TransportType.SOCKET, PORT );
+        registry.bind( service, new EchoProtocolHandler() );
 
         System.out.println( "Listening on port " + PORT );
+    }
+
+    private static void addSSLSupport( ServiceRegistry registry )
+        throws Exception
+    {
+        System.out.println( "SSL is enabled." );
+        SSLFilter sslFilter =
+            new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
+        IoFilterChain filters = registry.getIoFilterChain( TransportType.SOCKET );
+        filters.addLast( "sslFilter", sslFilter );
     }
 }

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/Main.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/Main.java?rev=165577&r1=165576&r2=165577&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/Main.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/Main.java Sun
May  1 21:22:31 2005
@@ -18,13 +18,13 @@
  */
 package org.apache.mina.examples.httpserver;
 
-import java.net.InetSocketAddress;
-
+import org.apache.mina.common.TransportType;
 import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
-import org.apache.mina.io.IoAcceptor;
-import org.apache.mina.io.filter.IoThreadPoolFilter;
+import org.apache.mina.io.IoFilterChain;
 import org.apache.mina.io.filter.SSLFilter;
-import org.apache.mina.io.socket.SocketAcceptor;
+import org.apache.mina.registry.Service;
+import org.apache.mina.registry.ServiceRegistry;
+import org.apache.mina.registry.SimpleServiceRegistry;
 
 /**
  * (<b>Entry point</b>) HTTP server
@@ -35,37 +35,35 @@
 public class Main
 {
     /** Choose your favorite port number. */
-    private static final int PORT = 8080;
+    private static final int PORT = 8081;
     
-    /** Set this to true if you want to make the server SSL */
-    private static final boolean USE_SSL = false;
+    private static final boolean USE_SSL = true;
 
     public static void main( String[] args ) throws Exception
     {
-        // Create a I/O thread pool filter 
-        IoThreadPoolFilter threadPoolFilter = new IoThreadPoolFilter();
-        threadPoolFilter.start(); // and start it
-
-        // Create a TCP/IP acceptor
-        IoAcceptor acceptor = new SocketAcceptor();
-
-        // Add thread pool filter
-        // MINA runs in a single thread if you don't add this filter.
-        acceptor.getFilterChain().addFirst( "threadPool", threadPoolFilter );
-
+        ServiceRegistry registry = new SimpleServiceRegistry();
+        
         // Add SSL filter if SSL is enabled.
         if( USE_SSL )
         {
-            System.out.println( "SSL is enabled." );
-            SSLFilter sslFilter = new SSLFilter( BogusSSLContextFactory
-                    .getInstance( true ) );
-            acceptor.getFilterChain().addLast( "sslFilter", sslFilter );
+            addSSLSupport( registry );
         }
 
         // Bind
-        acceptor.bind( new InetSocketAddress( PORT ),
-                new HttpProtocolHandler() );
+        Service service = new Service( "http", TransportType.SOCKET, PORT );
+        registry.bind( service, new HttpProtocolHandler() );
 
         System.out.println( "Listening on port " + PORT );
+    }
+
+
+    private static void addSSLSupport( ServiceRegistry registry )
+        throws Exception
+    {
+        System.out.println( "SSL is enabled." );
+        SSLFilter sslFilter =
+            new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
+        IoFilterChain filters = registry.getIoFilterChain( TransportType.SOCKET );
+        filters.addLast( "sslFilter", sslFilter );
     }
 }

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/netcat/Main.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/netcat/Main.java?rev=165577&r1=165576&r2=165577&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/netcat/Main.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/netcat/Main.java Sun May
 1 21:22:31 2005
@@ -20,7 +20,6 @@
 
 import java.net.InetSocketAddress;
 
-import org.apache.mina.io.filter.IoThreadPoolFilter;
 import org.apache.mina.io.socket.SocketConnector;
 
 /**
@@ -43,11 +42,6 @@
 
         // Create TCP/IP connector.
         SocketConnector connector = new SocketConnector();
-
-        // Add I/O thread pool filter.
-        // MINA runs in a single thread if you don't add this filter.
-        connector.getFilterChain().addFirst(
-                "threadPool", new IoThreadPoolFilter() );
 
         // Start communication.
         connector.connect( new InetSocketAddress( args[ 0 ], Integer

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/registry/Main.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/registry/Main.java?rev=165577&r1=165576&r2=165577&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/registry/Main.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/registry/Main.java Sun May
 1 21:22:31 2005
@@ -3,12 +3,9 @@
  */
 package org.apache.mina.examples.registry;
 
-import java.net.InetSocketAddress;
-
 import org.apache.mina.common.TransportType;
 import org.apache.mina.examples.echoserver.EchoProtocolHandler;
 import org.apache.mina.examples.reverser.ReverseProtocolProvider;
-import org.apache.mina.protocol.vmpipe.VmPipeAddress;
 import org.apache.mina.registry.Service;
 import org.apache.mina.registry.ServiceRegistry;
 import org.apache.mina.registry.SimpleServiceRegistry;
@@ -29,27 +26,20 @@
         ServiceRegistry registry = new SimpleServiceRegistry();
 
         // Register echo service
-        registry.bind( new Service( "echo", TransportType.SOCKET,
-                                    new InetSocketAddress( 8080 ) ),
+        registry.bind( new Service( "echo", TransportType.SOCKET, 8080 ),
                        new EchoProtocolHandler() );
 
-        registry.bind( new Service( "echo", TransportType.DATAGRAM,
-                                    new InetSocketAddress( 8080 ) ),
+        registry.bind( new Service( "echo", TransportType.DATAGRAM, 8080 ),
                        new EchoProtocolHandler() );
 
         // Register reverse service
-        registry.bind( new Service( "reverse", TransportType.SOCKET,
-                                    new InetSocketAddress( 8081 ) ),
+        registry.bind( new Service( "reverse", TransportType.SOCKET, 8081 ),
                        new ReverseProtocolProvider() );
 
-        registry.bind( new Service( "reverse", TransportType.DATAGRAM,
-                                    new InetSocketAddress( 8081 ) ),
+        registry.bind( new Service( "reverse", TransportType.DATAGRAM, 8081 ),
                        new ReverseProtocolProvider() );
 
-        registry.bind( new Service( "reverse", TransportType.VM_PIPE,
-                                    new VmPipeAddress( 8081 ) ),
+        registry.bind( new Service( "reverse", TransportType.VM_PIPE, 8081 ),
                        new ReverseProtocolProvider() );
-        
-        System.out.println( registry.getAllServices() );
     }
 }

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/reverser/Main.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/reverser/Main.java?rev=165577&r1=165576&r2=165577&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/reverser/Main.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/reverser/Main.java Sun May
 1 21:22:31 2005
@@ -18,12 +18,10 @@
  */
 package org.apache.mina.examples.reverser;
 
-import java.net.InetSocketAddress;
-
-import org.apache.mina.io.filter.IoThreadPoolFilter;
-import org.apache.mina.io.socket.SocketAcceptor;
-import org.apache.mina.protocol.filter.ProtocolThreadPoolFilter;
-import org.apache.mina.protocol.io.IoProtocolAcceptor;
+import org.apache.mina.common.TransportType;
+import org.apache.mina.registry.Service;
+import org.apache.mina.registry.ServiceRegistry;
+import org.apache.mina.registry.SimpleServiceRegistry;
 
 /**
  * (<b>Entry point</b>) Reverser server which reverses all text lines from
@@ -38,29 +36,11 @@
 
     public static void main( String[] args ) throws Exception
     {
-        // Create I/O and Protocol thread pool filter.
-        // I/O thread pool performs encoding and decoding of messages.
-        // Protocol thread pool performs actual protocol flow.
-        IoThreadPoolFilter ioThreadPoolFilter = new IoThreadPoolFilter();
-        ProtocolThreadPoolFilter protocolThreadPoolFilter = new ProtocolThreadPoolFilter();
-
-        // and start both.
-        ioThreadPoolFilter.start();
-        protocolThreadPoolFilter.start();
-
-        // Create a TCP/IP acceptor.
-        IoProtocolAcceptor acceptor = new IoProtocolAcceptor(
-                new SocketAcceptor() );
-
-        // Add both thread pool filters.
-        acceptor.getIoAcceptor().getFilterChain().addFirst(
-                "threadPool", ioThreadPoolFilter );
-        acceptor.getFilterChain().addFirst(
-                "threadPool", protocolThreadPoolFilter );
+        ServiceRegistry registry = new SimpleServiceRegistry();
 
         // Bind
-        acceptor.bind( new InetSocketAddress( PORT ),
-                new ReverseProtocolProvider() );
+        Service service = new Service( "reverse", TransportType.SOCKET, PORT );
+        registry.bind( service, new ReverseProtocolProvider() );
 
         System.out.println( "Listening on port " + PORT );
     }

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/tennis/Main.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/tennis/Main.java?rev=165577&r1=165576&r2=165577&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/tennis/Main.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/tennis/Main.java Sun May
 1 21:22:31 2005
@@ -3,11 +3,13 @@
  */
 package org.apache.mina.examples.tennis;
 
+import org.apache.mina.common.TransportType;
 import org.apache.mina.protocol.ProtocolSession;
-import org.apache.mina.protocol.filter.ProtocolThreadPoolFilter;
-import org.apache.mina.protocol.vmpipe.VmPipeAcceptor;
 import org.apache.mina.protocol.vmpipe.VmPipeAddress;
 import org.apache.mina.protocol.vmpipe.VmPipeConnector;
+import org.apache.mina.registry.Service;
+import org.apache.mina.registry.ServiceRegistry;
+import org.apache.mina.registry.SimpleServiceRegistry;
 
 /**
  * (<b>Entry point</b>) An 'in-VM pipe' example which simulates a tennis game
@@ -28,20 +30,16 @@
 
     public static void main( String[] args ) throws Exception
     {
-        VmPipeAddress address = new VmPipeAddress( 8080 );
+        ServiceRegistry registry = new SimpleServiceRegistry();
 
-        // Prepare thread pool
-        ProtocolThreadPoolFilter threadPool = new ProtocolThreadPoolFilter();
-        threadPool.start();
+        VmPipeAddress address = new VmPipeAddress( 8080 );
 
         // Set up server
-        VmPipeAcceptor acceptor = new VmPipeAcceptor();
-        acceptor.bind( address, new TennisPlayer() );
-        acceptor.getFilterChain().addFirst( "threadPool", threadPool );
+        Service service = new Service( "tennis", TransportType.VM_PIPE, address );
+        registry.bind( service, new TennisPlayer() );
 
         // Connect to the server.
         VmPipeConnector connector = new VmPipeConnector();
-        connector.getFilterChain().addFirst( "threadPool", threadPool );
         ProtocolSession session = connector.connect( address,
                                                      new TennisPlayer() );
 
@@ -53,8 +51,7 @@
         {
             Thread.sleep( 100 );
         }
-
-        // Stop the thread pool
-        threadPool.stop();
+        
+        registry.unbind( service );
     }
 }

Modified: directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java?rev=165577&r1=165576&r2=165577&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java Sun May
 1 21:22:31 2005
@@ -21,9 +21,10 @@
 import java.io.IOException;
 import java.util.Set;
 
+import org.apache.mina.common.SessionInitializer;
 import org.apache.mina.common.TransportType;
-import org.apache.mina.io.IoHandler;
 import org.apache.mina.io.IoFilterChain;
+import org.apache.mina.io.IoHandler;
 import org.apache.mina.protocol.ProtocolFilterChain;
 import org.apache.mina.protocol.ProtocolProvider;
 
@@ -48,12 +49,29 @@
     void bind( Service service, ProtocolProvider protocolProvider )
             throws IOException;
 
-    
+    /**
+     * Binds the specified I/O handler to the specified service.
+     */
+    void bind( Service service,
+               IoHandler ioHandler, SessionInitializer initializer ) throws IOException;
+
+    /**
+     * Binds the specified protocol provider to the specified service.
+     */
+    void bind( Service service, ProtocolProvider protocolProvider,
+               SessionInitializer initializer ) throws IOException;
+
     /**
      * Unbinds the specified service (and its aggregated I/O handler or
      * protocol provider). 
      */
     void unbind( Service service );
+    
+    /**
+     * Unbinds all services (and their aggregated I/O handlers or
+     * protocol providers). 
+     */
+    void unbindAll();
 
     IoFilterChain getIoFilterChain( TransportType transportType );
     

Modified: directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java?rev=165577&r1=165576&r2=165577&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java Sun
May  1 21:22:31 2005
@@ -10,6 +10,7 @@
 import java.util.Iterator;
 import java.util.Set;
 
+import org.apache.mina.common.SessionInitializer;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.io.IoAcceptor;
 import org.apache.mina.io.IoHandler;
@@ -63,22 +64,33 @@
         vmPipeAcceptor.getFilterChain().addFirst( "threadPool", protocolThreadPoolFilter
);
     }
 
-    public synchronized void bind( Service service, IoHandler ioHandler )
-            throws IOException
+    public void bind( Service service, IoHandler ioHandler ) throws IOException
+    {
+        bind( service, ioHandler, null );
+    }
+
+    public synchronized void bind( Service service,
+                                   ProtocolProvider protocolProvider ) throws IOException
+    {
+        bind( service, protocolProvider, null );
+    }
+    
+    public synchronized void bind( Service service,
+                                   IoHandler ioHandler,
+                                   SessionInitializer initializer ) throws IOException
     {
         IoAcceptor acceptor = findIoAcceptor( service.getTransportType() );
-        acceptor.bind( service.getAddress(), ioHandler );
+        acceptor.bind( service.getAddress(), ioHandler, initializer );
         startThreadPools();
         services.add( service );
     }
 
     public synchronized void bind( Service service,
-                                  ProtocolProvider protocolProvider )
-            throws IOException
+                                   ProtocolProvider protocolProvider,
+                                   SessionInitializer initializer ) throws IOException
     {
-        ProtocolAcceptor acceptor = findProtocolAcceptor( service
-                .getTransportType() );
-        acceptor.bind( service.getAddress(), protocolProvider );
+        ProtocolAcceptor acceptor = findProtocolAcceptor( service.getTransportType() );
+        acceptor.bind( service.getAddress(), protocolProvider, initializer );
         startThreadPools();
         services.add( service );
     }
@@ -107,6 +119,16 @@
 
         services.remove( service );
         stopThreadPools();
+    }
+    
+    public synchronized void unbindAll()
+    {
+        Iterator it = new HashSet( services ).iterator();
+        while( it.hasNext() )
+        {
+            Service s = ( Service ) it.next();
+            unbind( s );
+        }
     }
 
     public IoFilterChain getIoFilterChain(TransportType transportType) {

Modified: directory/network/trunk/src/test/org/apache/mina/examples/echoserver/AbstractTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/examples/echoserver/AbstractTest.java?rev=165577&r1=165576&r2=165577&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/examples/echoserver/AbstractTest.java
(original)
+++ directory/network/trunk/src/test/org/apache/mina/examples/echoserver/AbstractTest.java
Sun May  1 21:22:31 2005
@@ -19,7 +19,6 @@
 package org.apache.mina.examples.echoserver;
 
 import java.io.IOException;
-import java.net.InetSocketAddress;
 
 import junit.framework.Assert;
 import junit.framework.TestCase;
@@ -27,10 +26,10 @@
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.Session;
 import org.apache.mina.common.SessionInitializer;
-import org.apache.mina.io.IoAcceptor;
-import org.apache.mina.io.datagram.DatagramAcceptor;
-import org.apache.mina.io.filter.IoThreadPoolFilter;
-import org.apache.mina.io.socket.SocketAcceptor;
+import org.apache.mina.common.TransportType;
+import org.apache.mina.registry.Service;
+import org.apache.mina.registry.ServiceRegistry;
+import org.apache.mina.registry.SimpleServiceRegistry;
 
 /**
  * Tests echo server example.
@@ -46,11 +45,7 @@
 
     protected int port;
 
-    protected IoAcceptor acceptor;
-
-    protected IoAcceptor datagramAcceptor;
-
-    protected IoThreadPoolFilter threadPoolFilter;
+    protected ServiceRegistry registry;
     
     protected AbstractTest( boolean testInitializer )
     {
@@ -85,8 +80,7 @@
 
     protected void setUp() throws Exception
     {
-        acceptor = new SocketAcceptor();
-        datagramAcceptor = new DatagramAcceptor();
+        registry = new SimpleServiceRegistry();
         
         if( testInitializer )
         {
@@ -104,15 +98,19 @@
         {
             socketBound = false;
             datagramBound = false;
+            
+            Service socketService = new Service( "echo", TransportType.SOCKET, port );
+            Service datagramService = new Service( "echo", TransportType.DATAGRAM, port );
+            
             try
             {
-                acceptor.bind( new InetSocketAddress( port ),
+                registry.bind( socketService,
                                new EchoProtocolHandler(), initializer );
                 socketBound = true;
 
-                datagramAcceptor.bind( new InetSocketAddress( port ),
-                                       new EchoProtocolHandler(),
-                                       initializer );
+                registry.bind( datagramService,
+                               new EchoProtocolHandler(),
+                               initializer );
                 datagramBound = true;
 
                 break;
@@ -124,15 +122,7 @@
             {
                 if( !socketBound || !datagramBound )
                 {
-                    if( socketBound )
-                    {
-                        acceptor.unbind( new InetSocketAddress( port ) );
-                    }
-                    if( datagramBound )
-                    {
-                        datagramAcceptor
-                                .unbind( new InetSocketAddress( port ) );
-                    }
+                    registry.unbindAll();
                 }
             }
         }
@@ -144,20 +134,11 @@
         }
 
         System.out.println( "Using port " + port + " for testing." );
-
-        threadPoolFilter = new IoThreadPoolFilter();
-        threadPoolFilter.start();
-
-        acceptor.getFilterChain().addFirst( "threadPool", threadPoolFilter );
-        datagramAcceptor.getFilterChain().addFirst( "threadPool", threadPoolFilter );
     }
 
     protected void tearDown() throws Exception
     {
-        acceptor.unbind( new InetSocketAddress( port ) );
-        datagramAcceptor.unbind( new InetSocketAddress( port ) );
-        threadPoolFilter.stop();
-        
+        registry.unbindAll();
         if( initializer != null  )
         {
             Assert.assertTrue( initializer.executed );

Modified: directory/network/trunk/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java?rev=165577&r1=165576&r2=165577&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java
(original)
+++ directory/network/trunk/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java
Sun May  1 21:22:31 2005
@@ -30,6 +30,7 @@
 
 import org.apache.commons.net.EchoTCPClient;
 import org.apache.commons.net.EchoUDPClient;
+import org.apache.mina.common.TransportType;
 import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
 import org.apache.mina.examples.echoserver.ssl.SSLServerSocketFactory;
 import org.apache.mina.examples.echoserver.ssl.SSLSocketFactory;
@@ -60,7 +61,7 @@
         SSLFilter sslFilter =
             new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
         //sslFilter.setDebug( SSLFilter.Debug.ON );
-        acceptor.getFilterChain().addLast( "SSL", sslFilter );
+        registry.getIoFilterChain( TransportType.SOCKET ).addLast( "SSL", sslFilter );
         
         // Create a commons-net socket factory
         SSLSocketFactory.setSslEnabled(true);

Modified: directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java?rev=165577&r1=165576&r2=165577&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java
(original)
+++ directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java
Sun May  1 21:22:31 2005
@@ -28,6 +28,7 @@
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.Session;
 import org.apache.mina.common.SessionInitializer;
+import org.apache.mina.common.TransportType;
 import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
 import org.apache.mina.io.IoConnector;
 import org.apache.mina.io.IoHandlerAdapter;
@@ -63,7 +64,6 @@
     public void testTCP() throws Exception
     {
         IoConnector connector = new SocketConnector();
-        connector.getFilterChain().addFirst( "threadPool", super.threadPoolFilter );
         testConnector( connector );
     }
     
@@ -76,11 +76,10 @@
         SSLFilter acceptorSSLFilter =
             new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
         //acceptorSSLFilter.setDebug( SSLFilter.Debug.ON );
-        acceptor.getFilterChain().addLast( "SSL", acceptorSSLFilter );
+        registry.getIoFilterChain( TransportType.SOCKET ).addLast( "SSL", acceptorSSLFilter
);
 
         // Create a connector
         IoConnector connector = new SocketConnector();
-        connector.getFilterChain().addFirst( "threadPool", super.threadPoolFilter );
         
         // Add an SSL filter to connector
         SSLFilter connectorSSLFilter =
@@ -95,7 +94,6 @@
     public void testUDP() throws Exception
     {
         IoConnector connector = new DatagramConnector();
-        connector.getFilterChain().addFirst( "threadPool", super.threadPoolFilter );
         testConnector( connector );
     }
     



Mime
View raw message