directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r370975 - in /directory/sandbox/trustin/mina-spi/examples/src: main/java/org/apache/mina/examples/echoserver/ main/java/org/apache/mina/examples/httpserver/ main/java/org/apache/mina/examples/netcat/ main/java/org/apache/mina/examples/rever...
Date Sat, 21 Jan 2006 04:22:25 GMT
Author: trustin
Date: Fri Jan 20 20:22:16 2006
New Revision: 370975

URL: http://svn.apache.org/viewcvs?rev=370975&view=rev
Log:
Fixing compilation errors...


Modified:
    directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/echoserver/EchoProtocolHandler.java
    directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/echoserver/Main.java
    directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/httpserver/Main.java
    directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/netcat/Main.java
    directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/reverser/Main.java
    directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/tennis/Main.java
    directory/sandbox/trustin/mina-spi/examples/src/test/java/org/apache/mina/examples/echoserver/AbstractTest.java
    directory/sandbox/trustin/mina-spi/examples/src/test/java/org/apache/mina/examples/echoserver/ConnectorTest.java

Modified: directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/echoserver/EchoProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/echoserver/EchoProtocolHandler.java?rev=370975&r1=370974&r2=370975&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/echoserver/EchoProtocolHandler.java
(original)
+++ directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/echoserver/EchoProtocolHandler.java
Fri Jan 20 20:22:16 2006
@@ -24,7 +24,6 @@
 import org.apache.mina.common.IoHandlerAdapter;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.filter.SSLFilter;
-import org.apache.mina.transport.socket.nio.SocketSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -40,10 +39,13 @@
 
     public void sessionCreated( IoSession session )
     {
+        /*
+         * FIXME ... 
         if( session instanceof SocketSession )
         {
             ( ( SocketSession ) session ).setSessionReceiveBufferSize( 2048 );
         }
+         */
         
         session.setIdleTime( IdleStatus.BOTH_IDLE, 10 );
         

Modified: directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/echoserver/Main.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/echoserver/Main.java?rev=370975&r1=370974&r2=370975&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/echoserver/Main.java
(original)
+++ directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/echoserver/Main.java
Fri Jan 20 20:22:16 2006
@@ -18,14 +18,12 @@
  */
 package org.apache.mina.examples.echoserver;
 
-import org.apache.mina.common.IoAcceptor;
-import org.apache.mina.common.TransportType;
+import org.apache.mina.common.DefaultIoFilterChainBuilder;
+import org.apache.mina.common.IoAddress;
+import org.apache.mina.common.MINA;
 import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
 import org.apache.mina.filter.LoggingFilter;
 import org.apache.mina.filter.SSLFilter;
-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,37 +41,34 @@
 
     public static void main( String[] args ) throws Exception
     {
-        ServiceRegistry registry = new SimpleServiceRegistry();
+        DefaultIoFilterChainBuilder chain = new DefaultIoFilterChainBuilder();
         
         // Add SSL filter if SSL is enabled.
         if( USE_SSL )
         {
-            addSSLSupport( registry );
+            addSSLSupport( chain );
         }
         
-        addLogger( registry );
+        addLogger( chain );
         
         // Bind
-        Service service = new Service( "echo", TransportType.SOCKET, PORT );
-        registry.bind( service, new EchoProtocolHandler() );
+        MINA.bind( new IoAddress( "nio:socket:*:" + PORT ), new EchoProtocolHandler(), chain
);
 
         System.out.println( "Listening on port " + PORT );
     }
 
-    private static void addSSLSupport( ServiceRegistry registry )
+    private static void addSSLSupport( DefaultIoFilterChainBuilder chain )
         throws Exception
     {
         SSLFilter sslFilter =
             new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
-        IoAcceptor acceptor = registry.getAcceptor( TransportType.SOCKET );
-        acceptor.getFilterChain().addLast( "sslFilter", sslFilter );
+        chain.addLast( "sslFilter", sslFilter );
         System.out.println( "SSL ON" );
     }
     
-    private static void addLogger( ServiceRegistry registry ) throws Exception
+    private static void addLogger( DefaultIoFilterChainBuilder chain ) throws Exception
     {
-        IoAcceptor acceptor = registry.getAcceptor( TransportType.SOCKET );
-        acceptor.getFilterChain().addLast( "logger", new LoggingFilter() );
+        chain.addLast( "logger", new LoggingFilter() );
         System.out.println( "Logging ON" );
     }
 }

Modified: directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/httpserver/Main.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/httpserver/Main.java?rev=370975&r1=370974&r2=370975&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/httpserver/Main.java
(original)
+++ directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/httpserver/Main.java
Fri Jan 20 20:22:16 2006
@@ -18,13 +18,11 @@
  */
 package org.apache.mina.examples.httpserver;
 
-import org.apache.mina.common.IoAcceptor;
-import org.apache.mina.common.TransportType;
+import org.apache.mina.common.DefaultIoFilterChainBuilder;
+import org.apache.mina.common.IoAddress;
+import org.apache.mina.common.MINA;
 import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
 import org.apache.mina.filter.SSLFilter;
-import org.apache.mina.registry.Service;
-import org.apache.mina.registry.ServiceRegistry;
-import org.apache.mina.registry.SimpleServiceRegistry;
 
 /**
  * (<b>Entry point</b>) HTTP server
@@ -41,29 +39,26 @@
 
     public static void main( String[] args ) throws Exception
     {
-        ServiceRegistry registry = new SimpleServiceRegistry();
+        DefaultIoFilterChainBuilder chain = new DefaultIoFilterChainBuilder();
         
         // Add SSL filter if SSL is enabled.
         if( USE_SSL )
         {
-            addSSLSupport( registry );
+            addSSLSupport( chain );
         }
 
         // Bind
-        Service service = new Service( "http", TransportType.SOCKET, PORT );
-        registry.bind( service, new HttpProtocolHandler() );
-
+        MINA.bind( new IoAddress( "nio:socket:*:" + PORT ), new HttpProtocolHandler(), chain
);
         System.out.println( "Listening on port " + PORT );
     }
 
 
-    private static void addSSLSupport( ServiceRegistry registry )
+    private static void addSSLSupport( DefaultIoFilterChainBuilder chain )
         throws Exception
     {
-        System.out.println( "SSL is enabled." );
         SSLFilter sslFilter =
             new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
-        IoAcceptor acceptor = registry.getAcceptor( TransportType.SOCKET );
-        acceptor.getFilterChain().addLast( "sslFilter", sslFilter );
+        chain.addLast( "sslFilter", sslFilter );
+        System.out.println( "SSL is enabled." );
     }
 }

Modified: directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/netcat/Main.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/netcat/Main.java?rev=370975&r1=370974&r2=370975&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/netcat/Main.java
(original)
+++ directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/netcat/Main.java
Fri Jan 20 20:22:16 2006
@@ -18,9 +18,8 @@
  */
 package org.apache.mina.examples.netcat;
 
-import java.net.InetSocketAddress;
-
-import org.apache.mina.transport.socket.nio.SocketConnector;
+import org.apache.mina.common.IoAddress;
+import org.apache.mina.common.MINA;
 
 /**
  * (<b>Entry point</b>) NetCat client.  NetCat client connects to the specified
@@ -40,16 +39,10 @@
             return;
         }
 
-        // Create TCP/IP connector.
-        SocketConnector connector = new SocketConnector();
-
-        // Set connect timeout.
-        connector.setConnectTimeout( 30 );
         
         // Start communication.
-        connector.connect( 
-                new InetSocketAddress( args[ 0 ],
-                Integer.parseInt( args[ 1 ] ) ),
+        MINA.connect( 
+                new IoAddress( "nio:socket:" + args[0] + ':' + args[1] ),
                 new NetCatProtocolHandler() );
     }
 }

Modified: directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/reverser/Main.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/reverser/Main.java?rev=370975&r1=370974&r2=370975&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/reverser/Main.java
(original)
+++ directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/reverser/Main.java
Fri Jan 20 20:22:16 2006
@@ -18,10 +18,8 @@
  */
 package org.apache.mina.examples.reverser;
 
-import org.apache.mina.common.TransportType;
-import org.apache.mina.registry.Service;
-import org.apache.mina.registry.ServiceRegistry;
-import org.apache.mina.registry.SimpleServiceRegistry;
+import org.apache.mina.common.IoAddress;
+import org.apache.mina.common.MINA;
 
 /**
  * (<b>Entry point</b>) Reverser server which reverses all text lines from
@@ -36,11 +34,10 @@
 
     public static void main( String[] args ) throws Exception
     {
-        ServiceRegistry registry = new SimpleServiceRegistry();
-
         // Bind
-        Service service = new Service( "reverse", TransportType.SOCKET, PORT );
-        registry.bind( service, new ReverseProtocolHandler() );
+        MINA.bind(
+                new IoAddress( "nio:socket:*:" + PORT ),
+                new ReverseProtocolHandler() );
 
         System.out.println( "Listening on port " + PORT );
     }

Modified: directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/tennis/Main.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/tennis/Main.java?rev=370975&r1=370974&r2=370975&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/tennis/Main.java
(original)
+++ directory/sandbox/trustin/mina-spi/examples/src/main/java/org/apache/mina/examples/tennis/Main.java
Fri Jan 20 20:22:16 2006
@@ -4,13 +4,9 @@
 package org.apache.mina.examples.tennis;
 
 import org.apache.mina.common.ConnectFuture;
+import org.apache.mina.common.IoAddress;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.common.TransportType;
-import org.apache.mina.registry.Service;
-import org.apache.mina.registry.ServiceRegistry;
-import org.apache.mina.registry.SimpleServiceRegistry;
-import org.apache.mina.transport.vmpipe.VmPipeAddress;
-import org.apache.mina.transport.vmpipe.VmPipeConnector;
+import org.apache.mina.common.MINA;
 
 /**
  * (<b>Entry point</b>) An 'in-VM pipe' example which simulates a tennis game
@@ -31,18 +27,14 @@
 
     public static void main( String[] args ) throws Exception
     {
-        ServiceRegistry registry = new SimpleServiceRegistry();
-
-        VmPipeAddress address = new VmPipeAddress( 8080 );
-
         // Set up server
-        Service service = new Service( "tennis", TransportType.VM_PIPE, address );
-        registry.bind( service, new TennisPlayer() );
+        MINA.bind( new IoAddress( "vm:pipe:8080" ), new TennisPlayer() );
 
         // Connect to the server.
-        VmPipeConnector connector = new VmPipeConnector();
-        ConnectFuture future = connector.connect( address,
-                                                  new TennisPlayer() );
+        ConnectFuture future = MINA.connect(
+                new IoAddress( "vm:pipe:8080" ),
+                new TennisPlayer() );
+        
         future.join();
         IoSession session = future.getSession();
 
@@ -52,6 +44,6 @@
         // Wait until the match ends.
         session.getCloseFuture().join();
         
-        registry.unbind( service );
+        MINA.unbind( new IoAddress( "vm:pipe:8080" ) );
     }
 }

Modified: directory/sandbox/trustin/mina-spi/examples/src/test/java/org/apache/mina/examples/echoserver/AbstractTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/examples/src/test/java/org/apache/mina/examples/echoserver/AbstractTest.java?rev=370975&r1=370974&r2=370975&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/examples/src/test/java/org/apache/mina/examples/echoserver/AbstractTest.java
(original)
+++ directory/sandbox/trustin/mina-spi/examples/src/test/java/org/apache/mina/examples/echoserver/AbstractTest.java
Fri Jan 20 20:22:16 2006
@@ -23,14 +23,11 @@
 import junit.framework.TestCase;
 
 import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IoAddress;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.common.TransportType;
+import org.apache.mina.common.MINA;
 import org.apache.mina.filter.LoggingFilter;
 import org.apache.mina.filter.SSLFilter;
-import org.apache.mina.registry.Service;
-import org.apache.mina.registry.ServiceRegistry;
-import org.apache.mina.registry.SimpleServiceRegistry;
-import org.apache.mina.transport.socket.nio.SocketAcceptor;
 import org.apache.mina.util.SessionLog;
 
 /**
@@ -43,8 +40,6 @@
 {
     protected int port;
 
-    protected ServiceRegistry registry;
-    
     protected AbstractTest()
     {
     }
@@ -77,14 +72,11 @@
 
     protected void setUp() throws Exception
     {
-        registry = new SimpleServiceRegistry();
-
         // Find an availble test port and bind to it.
         boolean socketBound = false;
         boolean datagramBound = false;
 
-        final SocketAcceptor acceptor = ( SocketAcceptor ) registry.getAcceptor( TransportType.SOCKET
);
-        acceptor.setReuseAddress( true );
+        //acceptor.setReuseAddress( true );
 
         // Let's start from port #1 to detect possible resource leak
         // because test will fail in port 1-1023 if user run this test
@@ -94,12 +86,9 @@
             socketBound = false;
             datagramBound = false;
             
-            Service socketService = new Service( "echo", TransportType.SOCKET, port );
-            Service datagramService = new Service( "echo", TransportType.DATAGRAM, port );
-            
             try
             {
-                registry.bind( socketService, new EchoProtocolHandler()
+                MINA.bind( new IoAddress( "nio:socket:*:" + port ), new EchoProtocolHandler()
                 {
                     // This is for TLS reentrance test
                     public void messageReceived( IoSession session, Object message ) throws
Exception
@@ -130,7 +119,7 @@
                 } );
                 socketBound = true;
 
-                registry.bind( datagramService, new EchoProtocolHandler() );
+                MINA.bind( new IoAddress( "nio:datagram:*:" + port ), new EchoProtocolHandler()
);
                 datagramBound = true;
 
                 break;
@@ -142,7 +131,8 @@
             {
                 if( !socketBound || !datagramBound )
                 {
-                    registry.unbindAll();
+                    MINA.unbind( new IoAddress( "nio:socket:*:" + port ) );
+                    MINA.unbind( new IoAddress( "nio:datagram:*:" + port ) );
                 }
             }
         }

Modified: directory/sandbox/trustin/mina-spi/examples/src/test/java/org/apache/mina/examples/echoserver/ConnectorTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/examples/src/test/java/org/apache/mina/examples/echoserver/ConnectorTest.java?rev=370975&r1=370974&r2=370975&view=diff
==============================================================================
--- directory/sandbox/trustin/mina-spi/examples/src/test/java/org/apache/mina/examples/echoserver/ConnectorTest.java
(original)
+++ directory/sandbox/trustin/mina-spi/examples/src/test/java/org/apache/mina/examples/echoserver/ConnectorTest.java
Fri Jan 20 20:22:16 2006
@@ -25,17 +25,12 @@
 
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.ConnectFuture;
-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.examples.echoserver.ssl.BogusSSLContextFactory;
 import org.apache.mina.filter.LoggingFilter;
 import org.apache.mina.filter.SSLFilter;
-import org.apache.mina.transport.socket.nio.DatagramConnector;
-import org.apache.mina.transport.socket.nio.SocketConnector;
 import org.apache.mina.util.AvailablePortFinder;
 import org.apache.mina.util.SessionLog;
 



Mime
View raw message