directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r465510 [3/3] - in /directory/trunks/mina: core/src/main/java/org/apache/mina/common/ core/src/main/java/org/apache/mina/common/support/ core/src/main/java/org/apache/mina/management/ core/src/main/java/org/apache/mina/transport/socket/nio/...
Date Thu, 19 Oct 2006 06:42:11 GMT
Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/transport/vmpipe/VmPipeBindTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/transport/vmpipe/VmPipeBindTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/transport/vmpipe/VmPipeBindTest.java
(original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/transport/vmpipe/VmPipeBindTest.java
Wed Oct 18 23:42:06 2006
@@ -57,10 +57,12 @@
         SocketAddress addr = createSocketAddress( port );
      
         IoConnector connector = new VmPipeConnector();
+        connector.setRemoteAddress( addr );
+        connector.setHandler( new IoHandlerAdapter() );
         IoSession[] sessions = new IoSession[ 5 ];
         for( int i = 0; i < sessions.length; i++ )
         {
-            ConnectFuture future = connector.connect( addr, new IoHandlerAdapter() );
+            ConnectFuture future = connector.connect();
             future.join();
             sessions[ i ] = future.getSession();
             Assert.assertTrue( sessions[ i ].isConnected() );
@@ -69,7 +71,7 @@
         // Wait for the server side sessions to be created.
         Thread.sleep( 500 );
         
-        Collection managedSessions = acceptor.getManagedSessions( addr );
+        Collection managedSessions = acceptor.getManagedSessions();
         Assert.assertEquals( 5, managedSessions.size() );
         // Make sure it's the server side sessions we get when calling getManagedSessions()
         for( int i = 0; i < sessions.length; i++ )
@@ -77,7 +79,7 @@
             Assert.assertFalse( managedSessions.contains( sessions[ i ] ) );
         }
         
-        acceptor.unbind( addr );
+        acceptor.unbind();
         
         // Wait for the client side sessions to close.
         Thread.sleep( 500 );

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/transport/vmpipe/VmPipeTrafficControlTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/transport/vmpipe/VmPipeTrafficControlTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/transport/vmpipe/VmPipeTrafficControlTest.java
(original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/transport/vmpipe/VmPipeTrafficControlTest.java
Wed Oct 18 23:42:06 2006
@@ -46,7 +46,9 @@
     {
         IoConnector connector = new VmPipeConnector();
         SocketAddress addr = new VmPipeAddress( port );
-        return connector.connect( addr, handler );
+        connector.setRemoteAddress( addr );
+        connector.setHandler( handler );
+        return connector.connect();
     }
 
     protected SocketAddress createServerSocketAddress( int port )

Modified: directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/Main.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/Main.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/Main.java (original)
+++ directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/Main.java Wed
Oct 18 23:42:06 2006
@@ -22,15 +22,12 @@
 import java.net.InetSocketAddress;
 
 import org.apache.mina.common.DefaultIoFilterChainBuilder;
-import org.apache.mina.common.IoAcceptor;
-import org.apache.mina.common.IoAcceptorConfig;
 import org.apache.mina.example.echoserver.ssl.BogusSSLContextFactory;
 import org.apache.mina.filter.LoggingFilter;
 import org.apache.mina.filter.SSLFilter;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
 import org.apache.mina.filter.codec.textline.TextLineCodecFactory;
 import org.apache.mina.transport.socket.nio.SocketAcceptor;
-import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
 
 /**
  * (<b>Entry point</b>) Chat server
@@ -48,9 +45,8 @@
     
     public static void main( String[] args ) throws Exception
     {
-        IoAcceptor acceptor = new SocketAcceptor();
-        IoAcceptorConfig config = new SocketAcceptorConfig();
-        DefaultIoFilterChainBuilder chain = config.getFilterChain();
+        SocketAcceptor acceptor = new SocketAcceptor();
+        DefaultIoFilterChainBuilder chain = acceptor.getFilterChain();
         
         // Add SSL filter if SSL is enabled.
         if( USE_SSL )
@@ -63,10 +59,9 @@
         addLogger( chain );
         
         // Bind
-        acceptor.bind(
-                new InetSocketAddress( PORT ),
-                new ChatProtocolHandler(),
-                config );
+        acceptor.setLocalAddress( new InetSocketAddress( PORT ) );
+        acceptor.setHandler( new ChatProtocolHandler() );
+        acceptor.bind();
 
         System.out.println( "Listening on port " + PORT );
     }

Modified: directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/client/ChatClientSupport.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/client/ChatClientSupport.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/client/ChatClientSupport.java
(original)
+++ directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/client/ChatClientSupport.java
Wed Oct 18 23:42:06 2006
@@ -29,7 +29,6 @@
 import org.apache.mina.example.echoserver.ssl.BogusSSLContextFactory;
 import org.apache.mina.filter.SSLFilter;
 import org.apache.mina.transport.socket.nio.SocketConnector;
-import org.apache.mina.transport.socket.nio.SocketConnectorConfig;
 
 /**
  * A simple chat client for a given user.
@@ -63,16 +62,17 @@
         try
         {
             
-            SocketConnectorConfig config = new SocketConnectorConfig();
             if( useSsl )
             {
                 SSLContext sslContext = BogusSSLContextFactory.getInstance( false );
                 SSLFilter sslFilter = new SSLFilter( sslContext );
                 sslFilter.setUseClientMode( true );
-                config.getFilterChain().addLast( "sslFilter", sslFilter );
+                connector.getFilterChain().addLast( "sslFilter", sslFilter );
             }
      
-            ConnectFuture future1 = connector.connect( address, handler, config );
+            connector.setRemoteAddress( address );
+            connector.setHandler( handler );
+            ConnectFuture future1 = connector.connect();
             future1.join();
             if( ! future1.isConnected() )
             {

Modified: directory/trunks/mina/example/src/main/java/org/apache/mina/example/echoserver/Main.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/example/src/main/java/org/apache/mina/example/echoserver/Main.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/example/src/main/java/org/apache/mina/example/echoserver/Main.java
(original)
+++ directory/trunks/mina/example/src/main/java/org/apache/mina/example/echoserver/Main.java
Wed Oct 18 23:42:06 2006
@@ -23,12 +23,10 @@
 
 import org.apache.mina.common.DefaultIoFilterChainBuilder;
 import org.apache.mina.common.IoAcceptor;
-import org.apache.mina.common.IoAcceptorConfig;
 import org.apache.mina.example.echoserver.ssl.BogusSSLContextFactory;
 import org.apache.mina.filter.LoggingFilter;
 import org.apache.mina.filter.SSLFilter;
 import org.apache.mina.transport.socket.nio.SocketAcceptor;
-import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
 
 /**
  * (<b>Entry point</b>) Echo server
@@ -47,8 +45,7 @@
     public static void main( String[] args ) throws Exception
     {
         IoAcceptor acceptor = new SocketAcceptor();
-        IoAcceptorConfig config = new SocketAcceptorConfig();
-        DefaultIoFilterChainBuilder chain = config.getFilterChain();
+        DefaultIoFilterChainBuilder chain = acceptor.getFilterChain();
         
         // Add SSL filter if SSL is enabled.
         if( USE_SSL )
@@ -59,10 +56,9 @@
         addLogger( chain );
         
         // Bind
-        acceptor.bind(
-                new InetSocketAddress( PORT ),
-                new EchoProtocolHandler(),
-                config );
+        acceptor.setLocalAddress( new InetSocketAddress( PORT ) );
+        acceptor.setHandler( new EchoProtocolHandler() );
+        acceptor.bind();
 
         System.out.println( "Listening on port " + PORT );
     }

Modified: directory/trunks/mina/example/src/main/java/org/apache/mina/example/httpserver/codec/Server.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/example/src/main/java/org/apache/mina/example/httpserver/codec/Server.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/example/src/main/java/org/apache/mina/example/httpserver/codec/Server.java
(original)
+++ directory/trunks/mina/example/src/main/java/org/apache/mina/example/httpserver/codec/Server.java
Wed Oct 18 23:42:06 2006
@@ -21,11 +21,9 @@
 
 import java.net.InetSocketAddress;
 
-import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.filter.LoggingFilter;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
 import org.apache.mina.transport.socket.nio.SocketAcceptor;
-import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
 
 /**
  * (<b>Entry point</b>) HTTP server
@@ -56,17 +54,18 @@
         try
         {
             // Create an acceptor
-            IoAcceptor acceptor = new SocketAcceptor();
+            SocketAcceptor acceptor = new SocketAcceptor();
             
             // Create a service configuration
-            SocketAcceptorConfig cfg = new SocketAcceptorConfig();
-            cfg.setReuseAddress( true );
-            cfg.getFilterChain().addLast(
+            acceptor.setReuseAddress( true );
+            acceptor.getFilterChain().addLast(
                     "protocolFilter",
                     new ProtocolCodecFilter( new HttpServerProtocolCodecFactory() ) );
-            cfg.getFilterChain().addLast( "logger", new LoggingFilter() );
+            acceptor.getFilterChain().addLast( "logger", new LoggingFilter() );
 
-            acceptor.bind( new InetSocketAddress( port ), new ServerHandler(), cfg );
+            acceptor.setLocalAddress( new InetSocketAddress( port ) );
+            acceptor.setHandler( new ServerHandler() );
+            acceptor.bind();
 
             System.out.println( "Server now listening on port " + port );
         }

Modified: directory/trunks/mina/example/src/main/java/org/apache/mina/example/httpserver/stream/Main.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/example/src/main/java/org/apache/mina/example/httpserver/stream/Main.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/example/src/main/java/org/apache/mina/example/httpserver/stream/Main.java
(original)
+++ directory/trunks/mina/example/src/main/java/org/apache/mina/example/httpserver/stream/Main.java
Wed Oct 18 23:42:06 2006
@@ -23,11 +23,9 @@
 
 import org.apache.mina.common.DefaultIoFilterChainBuilder;
 import org.apache.mina.common.IoAcceptor;
-import org.apache.mina.common.IoAcceptorConfig;
 import org.apache.mina.example.echoserver.ssl.BogusSSLContextFactory;
 import org.apache.mina.filter.SSLFilter;
 import org.apache.mina.transport.socket.nio.SocketAcceptor;
-import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
 
 /**
  * (<b>Entry point</b>) HTTP server
@@ -45,8 +43,7 @@
     public static void main( String[] args ) throws Exception
     {
         IoAcceptor acceptor = new SocketAcceptor();
-        IoAcceptorConfig config = new SocketAcceptorConfig();
-        DefaultIoFilterChainBuilder chain = config.getFilterChain();
+        DefaultIoFilterChainBuilder chain = acceptor.getFilterChain();
 
         // Add SSL filter if SSL is enabled.
         if( USE_SSL )
@@ -55,10 +52,9 @@
         }
 
         // Bind
-        acceptor.bind(
-                new InetSocketAddress( PORT ),
-                new HttpProtocolHandler(),
-                config );
+        acceptor.setLocalAddress( new InetSocketAddress( PORT ) );
+        acceptor.setHandler( new HttpProtocolHandler() );
+        acceptor.bind();
 
         System.out.println( "Listening on port " + PORT );
     }

Modified: directory/trunks/mina/example/src/main/java/org/apache/mina/example/netcat/Main.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/example/src/main/java/org/apache/mina/example/netcat/Main.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/example/src/main/java/org/apache/mina/example/netcat/Main.java (original)
+++ directory/trunks/mina/example/src/main/java/org/apache/mina/example/netcat/Main.java Wed
Oct 18 23:42:06 2006
@@ -21,7 +21,6 @@
 
 import java.net.InetSocketAddress;
 
-import org.apache.mina.common.IoConnectorConfig;
 import org.apache.mina.transport.socket.nio.SocketConnector;
 
 /**
@@ -46,12 +45,12 @@
         SocketConnector connector = new SocketConnector();
 
         // Set connect timeout.
-        ( ( IoConnectorConfig ) connector.getDefaultConfig()).setConnectTimeout( 30 );
+        connector.setConnectTimeout( 30 );
         
         // Start communication.
-        connector.connect( 
-                new InetSocketAddress( args[ 0 ],
-                Integer.parseInt( args[ 1 ] ) ),
-                new NetCatProtocolHandler() );
+        connector.setRemoteAddress(
+                new InetSocketAddress( args[ 0 ], Integer.parseInt( args[ 1 ] ) ) );
+        connector.setHandler( new NetCatProtocolHandler() );
+        connector.connect();
     }
 }

Modified: directory/trunks/mina/example/src/main/java/org/apache/mina/example/proxy/ClientToProxyIoHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/example/src/main/java/org/apache/mina/example/proxy/ClientToProxyIoHandler.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/example/src/main/java/org/apache/mina/example/proxy/ClientToProxyIoHandler.java
(original)
+++ directory/trunks/mina/example/src/main/java/org/apache/mina/example/proxy/ClientToProxyIoHandler.java
Wed Oct 18 23:42:06 2006
@@ -19,8 +19,6 @@
  */
 package org.apache.mina.example.proxy;
 
-import java.net.InetSocketAddress;
-
 import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.IoConnector;
 import org.apache.mina.common.IoFuture;
@@ -38,21 +36,19 @@
  */
 public class ClientToProxyIoHandler extends AbstractProxyIoHandler
 {
-    private final ServerToProxyIoHandler connectorHandler; 
+    private final ServerToProxyIoHandler connectorHandler = new ServerToProxyIoHandler();

     private final IoConnector connector; 
-    private final InetSocketAddress address;
 
-    public ClientToProxyIoHandler( ServerToProxyIoHandler connectorHandler, 
-                        IoConnector connector, InetSocketAddress address )
+    public ClientToProxyIoHandler( IoConnector connector )
     {
-        this.connectorHandler = connectorHandler;
         this.connector = connector;
-        this.address = address;
+        connector.setHandler( connectorHandler );
     }
 
     public void sessionOpened( final IoSession session ) throws Exception 
     {
-        connector.connect( address, connectorHandler ).addListener( 
+        
+        connector.connect().addListener( 
                 new IoFutureListener()
         {
             public void operationComplete( IoFuture f )

Modified: directory/trunks/mina/example/src/main/java/org/apache/mina/example/proxy/Main.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/example/src/main/java/org/apache/mina/example/proxy/Main.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/example/src/main/java/org/apache/mina/example/proxy/Main.java (original)
+++ directory/trunks/mina/example/src/main/java/org/apache/mina/example/proxy/Main.java Wed
Oct 18 23:42:06 2006
@@ -21,11 +21,8 @@
 
 import java.net.InetSocketAddress;
 
-import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.IoConnector;
-import org.apache.mina.common.IoConnectorConfig;
 import org.apache.mina.transport.socket.nio.SocketAcceptor;
-import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
 import org.apache.mina.transport.socket.nio.SocketConnector;
 
 /**
@@ -55,22 +52,24 @@
         }
 
         // Create TCP/IP acceptor.
-        IoAcceptor acceptor = new SocketAcceptor();
-        ( ( SocketAcceptorConfig ) acceptor.getDefaultConfig() ).setReuseAddress( true );
+        SocketAcceptor acceptor = new SocketAcceptor();
+        acceptor.setReuseAddress( true );
         
         // Create TCP/IP connector.
         IoConnector connector = new SocketConnector();
 
         // Set connect timeout.
-        ( ( IoConnectorConfig ) connector.getDefaultConfig()).setConnectTimeout( 30 );
+        connector.setConnectTimeout( 30 );
         
-        ClientToProxyIoHandler handler = new ClientToProxyIoHandler( 
-                new ServerToProxyIoHandler(), connector,
-                new InetSocketAddress( args[ 1 ],
-                        Integer.parseInt( args[ 2 ] ) ) );
+        connector.setRemoteAddress(
+            new InetSocketAddress( args[ 1 ], Integer.parseInt( args[ 2 ] ) ) );
+        
+        ClientToProxyIoHandler handler = new ClientToProxyIoHandler( connector );
         
         // Start proxy.
-        acceptor.bind( new InetSocketAddress( Integer.parseInt( args[ 0 ] ) ), handler );
+        acceptor.setLocalAddress( new InetSocketAddress( Integer.parseInt( args[ 0 ] ) )
);
+        acceptor.setHandler( handler );
+        acceptor.bind();
 
         System.out.println( "Listening on port " + Integer.parseInt( args[ 0 ] ) );
     }

Modified: directory/trunks/mina/example/src/main/java/org/apache/mina/example/reverser/Main.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/example/src/main/java/org/apache/mina/example/reverser/Main.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/example/src/main/java/org/apache/mina/example/reverser/Main.java
(original)
+++ directory/trunks/mina/example/src/main/java/org/apache/mina/example/reverser/Main.java
Wed Oct 18 23:42:06 2006
@@ -22,12 +22,10 @@
 import java.net.InetSocketAddress;
 import java.nio.charset.Charset;
 
-import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.filter.LoggingFilter;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
 import org.apache.mina.filter.codec.textline.TextLineCodecFactory;
 import org.apache.mina.transport.socket.nio.SocketAcceptor;
-import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
 
 /**
  * (<b>Entry point</b>) Reverser server which reverses all text lines from
@@ -42,21 +40,20 @@
 
     public static void main( String[] args ) throws Exception
     {
-        IoAcceptor acceptor = new SocketAcceptor();
+        SocketAcceptor acceptor = new SocketAcceptor();
 
         // Prepare the configuration
-        SocketAcceptorConfig cfg = new SocketAcceptorConfig();
-        cfg.setReuseAddress( true );
-        cfg.getFilterChain().addLast( "logger", new LoggingFilter() );
-        cfg.getFilterChain().addLast(
+        acceptor.setReuseAddress( true );
+        acceptor.getFilterChain().addLast( "logger", new LoggingFilter() );
+        acceptor.getFilterChain().addLast(
                 "codec",
                 new ProtocolCodecFilter(
                         new TextLineCodecFactory( Charset.forName( "UTF-8" ) ) ) );
 
         // Bind
-        acceptor.bind(
-                new InetSocketAddress( PORT ),
-                new ReverseProtocolHandler(), cfg );
+        acceptor.setLocalAddress( new InetSocketAddress( PORT ) );
+        acceptor.setHandler( new ReverseProtocolHandler() );
+        acceptor.bind();
 
         System.out.println( "Listening on port " + PORT );
     }

Modified: directory/trunks/mina/example/src/main/java/org/apache/mina/example/sumup/Client.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/example/src/main/java/org/apache/mina/example/sumup/Client.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/example/src/main/java/org/apache/mina/example/sumup/Client.java
(original)
+++ directory/trunks/mina/example/src/main/java/org/apache/mina/example/sumup/Client.java
Wed Oct 18 23:42:06 2006
@@ -29,7 +29,6 @@
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
 import org.apache.mina.filter.codec.serialization.ObjectSerializationCodecFactory;
 import org.apache.mina.transport.socket.nio.SocketConnector;
-import org.apache.mina.transport.socket.nio.SocketConnectorConfig;
 
 /**
  * (<strong>Entry Point</strong>) Starts SumUp client.
@@ -67,31 +66,30 @@
         connector.setWorkerTimeout( 1 );
         
         // Configure the service.
-        SocketConnectorConfig cfg = new SocketConnectorConfig();
-        cfg.setConnectTimeout( CONNECT_TIMEOUT );
+        connector.setConnectTimeout( CONNECT_TIMEOUT );
         if( USE_CUSTOM_CODEC )
         {
-            cfg.getFilterChain().addLast(
+            connector.getFilterChain().addLast(
                     "codec",
                     new ProtocolCodecFilter( new SumUpProtocolCodecFactory( false ) ) );
         }
         else
         {
-            cfg.getFilterChain().addLast(
+            connector.getFilterChain().addLast(
                     "codec",
                     new ProtocolCodecFilter( new ObjectSerializationCodecFactory() ) );
         }
-        cfg.getFilterChain().addLast( "logger", new LoggingFilter() );
+        connector.getFilterChain().addLast( "logger", new LoggingFilter() );
+        
+        connector.setRemoteAddress( new InetSocketAddress( HOSTNAME, PORT ) );
+        connector.setHandler( new ClientSessionHandler( values ) );
         
         IoSession session;
         for( ;; )
         {
             try
             {
-                ConnectFuture future = connector.connect(
-                        new InetSocketAddress( HOSTNAME, PORT ),
-                        new ClientSessionHandler( values ), cfg );
-                
+                ConnectFuture future = connector.connect();
                 future.join();
                 session = future.getSession();
                 break;

Modified: directory/trunks/mina/example/src/main/java/org/apache/mina/example/sumup/Server.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/example/src/main/java/org/apache/mina/example/sumup/Server.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/example/src/main/java/org/apache/mina/example/sumup/Server.java
(original)
+++ directory/trunks/mina/example/src/main/java/org/apache/mina/example/sumup/Server.java
Wed Oct 18 23:42:06 2006
@@ -21,13 +21,11 @@
 
 import java.net.InetSocketAddress;
 
-import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.example.sumup.codec.SumUpProtocolCodecFactory;
 import org.apache.mina.filter.LoggingFilter;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
 import org.apache.mina.filter.codec.serialization.ObjectSerializationCodecFactory;
 import org.apache.mina.transport.socket.nio.SocketAcceptor;
-import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
 
 /**
  * (<strong>Entry Point</strong>) Starts SumUp server.
@@ -43,28 +41,27 @@
 
     public static void main( String[] args ) throws Throwable
     {
-        IoAcceptor acceptor = new SocketAcceptor();
+        SocketAcceptor acceptor = new SocketAcceptor();
         
         // Prepare the service configuration.
-        SocketAcceptorConfig cfg = new SocketAcceptorConfig();
-        cfg.setReuseAddress( true );
+        acceptor.setReuseAddress( true );
         if( USE_CUSTOM_CODEC )
         {
-            cfg.getFilterChain().addLast(
+            acceptor.getFilterChain().addLast(
                     "codec",
                     new ProtocolCodecFilter( new SumUpProtocolCodecFactory( true ) ) );
         }
         else
         {
-            cfg.getFilterChain().addLast(
+            acceptor.getFilterChain().addLast(
                     "codec",
                     new ProtocolCodecFilter( new ObjectSerializationCodecFactory() ) );
         }
-        cfg.getFilterChain().addLast( "logger", new LoggingFilter() );
+        acceptor.getFilterChain().addLast( "logger", new LoggingFilter() );
 
-        acceptor.bind(
-                new InetSocketAddress( SERVER_PORT ),
-                new ServerSessionHandler( ), cfg );
+        acceptor.setLocalAddress( new InetSocketAddress( SERVER_PORT ) );
+        acceptor.setHandler( new ServerSessionHandler() );
+        acceptor.bind();
 
         System.out.println( "Listening on port " + SERVER_PORT );
     }

Modified: directory/trunks/mina/example/src/main/java/org/apache/mina/example/tennis/Main.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/example/src/main/java/org/apache/mina/example/tennis/Main.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/example/src/main/java/org/apache/mina/example/tennis/Main.java (original)
+++ directory/trunks/mina/example/src/main/java/org/apache/mina/example/tennis/Main.java Wed
Oct 18 23:42:06 2006
@@ -49,12 +49,15 @@
         VmPipeAddress address = new VmPipeAddress( 8080 );
 
         // Set up server
-        acceptor.bind( address, new TennisPlayer() );
+        acceptor.setLocalAddress( address );
+        acceptor.setHandler( new TennisPlayer() );
+        acceptor.bind();
 
         // Connect to the server.
         VmPipeConnector connector = new VmPipeConnector();
-        ConnectFuture future = connector.connect( address,
-                                                  new TennisPlayer() );
+        connector.setRemoteAddress( address );
+        connector.setHandler( new TennisPlayer() );
+        ConnectFuture future = connector.connect();
         future.join();
         IoSession session = future.getSession();
 
@@ -64,6 +67,6 @@
         // Wait until the match ends.
         session.getCloseFuture().join();
         
-        acceptor.unbind( address );
+        acceptor.unbind();
     }
 }

Modified: directory/trunks/mina/example/src/test/java/org/apache/mina/example/echoserver/AbstractTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/example/src/test/java/org/apache/mina/example/echoserver/AbstractTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/example/src/test/java/org/apache/mina/example/echoserver/AbstractTest.java
(original)
+++ directory/trunks/mina/example/src/test/java/org/apache/mina/example/echoserver/AbstractTest.java
Wed Oct 18 23:42:06 2006
@@ -33,14 +33,13 @@
 import org.apache.mina.transport.socket.nio.DatagramAcceptor;
 import org.apache.mina.transport.socket.nio.DatagramSessionConfig;
 import org.apache.mina.transport.socket.nio.SocketAcceptor;
-import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
 import org.apache.mina.util.SessionLog;
 
 /**
  * Tests echo server example.
  * 
  * @author The Apache Directory Project (mina-dev@directory.apache.org)
- * @version $Rev$, $Date$
+ * @version $Rev:448075 $, $Date:2006-09-20 05:26:53Z $
  */
 public abstract class AbstractTest extends TestCase
 {
@@ -92,8 +91,8 @@
         datagramAcceptor = new DatagramAcceptor();
         socketAcceptor = new SocketAcceptor();
         
-        ( ( DatagramSessionConfig ) datagramAcceptor.getDefaultConfig().getSessionConfig()
).setReuseAddress( true );
-        ( ( SocketAcceptorConfig ) socketAcceptor.getDefaultConfig() ).setReuseAddress( true
);
+        ( ( DatagramSessionConfig ) datagramAcceptor.getSessionConfig() ).setReuseAddress(
true );
+        ( ( SocketAcceptor ) socketAcceptor ).setReuseAddress( true );
         
 
         // Find an availble test port and bind to it.
@@ -115,7 +114,8 @@
             
             try
             {
-                socketAcceptor.bind( address, new EchoProtocolHandler()
+                socketAcceptor.setLocalAddress( address );
+                socketAcceptor.setHandler( new EchoProtocolHandler()
                 {
                     public void sessionCreated( IoSession session )
                     {
@@ -152,9 +152,12 @@
                         }
                     }
                 } );
+                socketAcceptor.bind();
                 socketBound = true;
 
-                datagramAcceptor.bind( address, new EchoProtocolHandler() );
+                datagramAcceptor.setLocalAddress( address );
+                datagramAcceptor.setHandler( new EchoProtocolHandler() );
+                datagramAcceptor.bind();
                 datagramBound = true;
 
                 break;
@@ -166,11 +169,11 @@
             {
                 if( socketBound && !datagramBound )
                 {
-                    socketAcceptor.unbind( address );
+                    socketAcceptor.unbind();
                 }
                 if( datagramBound && !socketBound )
                 {
-                    datagramAcceptor.unbind( address );
+                    datagramAcceptor.unbind();
                 }
             }
         }
@@ -189,8 +192,8 @@
     {
         if( boundAddress != null )
         {
-            socketAcceptor.unbind( boundAddress );
-            datagramAcceptor.unbind( boundAddress );
+            socketAcceptor.unbind();
+            datagramAcceptor.unbind();
         }
     }
 }

Modified: directory/trunks/mina/example/src/test/java/org/apache/mina/example/echoserver/ConnectorTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/example/src/test/java/org/apache/mina/example/echoserver/ConnectorTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/example/src/test/java/org/apache/mina/example/echoserver/ConnectorTest.java
(original)
+++ directory/trunks/mina/example/src/test/java/org/apache/mina/example/echoserver/ConnectorTest.java
Wed Oct 18 23:42:06 2006
@@ -41,7 +41,7 @@
  * Tests echo server example.
  * 
  * @author The Apache Directory Project (mina-dev@directory.apache.org)
- * @version $Rev$, $Date$
+ * @version $Rev:448075 $, $Date:2006-09-20 05:26:53Z $
  */
 public class ConnectorTest extends AbstractTest
 {
@@ -76,7 +76,7 @@
         IoConnector connector = new SocketConnector();
         
         // Add an SSL filter to connector
-        connector.getDefaultConfig().getFilterChain().addLast( "SSL", connectorSSLFilter
);
+        connector.getFilterChain().addLast( "SSL", connectorSSLFilter );
         testConnector( connector );
     }
     
@@ -102,9 +102,10 @@
         IoSession session = null;
         if( !useLocalAddress )
         {
-            ConnectFuture future = connector.connect(
-                    new InetSocketAddress( "localhost", port ),
-                    handler );
+            connector.setLocalAddress( null );
+            connector.setRemoteAddress( new InetSocketAddress( "localhost", port ) );
+            connector.setHandler( handler );
+            ConnectFuture future = connector.connect();
             future.join();
             session = future.getSession();
         }
@@ -116,10 +117,10 @@
                 clientPort = AvailablePortFinder.getNextAvailable( clientPort + 1 );
                 try
                 {
-                    ConnectFuture future = connector.connect(
-                            new InetSocketAddress( "localhost", port ),
-                            new InetSocketAddress( clientPort ),
-                            handler );
+                    connector.setLocalAddress( new InetSocketAddress( clientPort ) );
+                    connector.setRemoteAddress( new InetSocketAddress( "localhost", port
) );
+                    connector.setHandler( handler );
+                    ConnectFuture future = connector.connect();
                     future.join();
                     session = future.getSession();
                     break;

Modified: directory/trunks/mina/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoServiceManager.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoServiceManager.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoServiceManager.java
(original)
+++ directory/trunks/mina/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoServiceManager.java
Wed Oct 18 23:42:06 2006
@@ -20,7 +20,6 @@
 package org.apache.mina.integration.jmx;
 
 
-import java.net.SocketAddress;
 import java.util.Iterator;
 
 import javax.management.MBeanRegistration;
@@ -67,15 +66,7 @@
 
     public int getManagedSessionCount()
     {
-
-        int count = 0;
-        for ( Iterator iter = service.getManagedServiceAddresses().iterator(); iter.hasNext();
)
-        {
-            SocketAddress element = ( SocketAddress ) iter.next();
-
-            count += service.getManagedSessions( element ).size();
-        }
-        return count;
+        return service.getManagedSessions().size();
     }
 
 
@@ -111,16 +102,11 @@
     public float getTotalByteReadThroughput()
     {
         float total = 0;
-        for ( Iterator iter = service.getManagedServiceAddresses().iterator(); iter.hasNext();
)
+        for ( Iterator iter = service.getManagedSessions().iterator(); iter.hasNext(); )
         {
-            SocketAddress element = ( SocketAddress ) iter.next();
-
-            for ( Iterator iter2 = service.getManagedSessions( element ).iterator(); iter2.hasNext();
)
-            {
-                IoSession session = ( IoSession ) iter2.next();
-                total += ( ( IoSessionStat ) session.getAttribute( StatCollector.KEY ) )
-                    .getByteReadThroughput();
-            }
+            IoSession session = ( IoSession ) iter.next();
+            total += ( ( IoSessionStat ) session.getAttribute( StatCollector.KEY ) )
+                .getByteReadThroughput();
         }
         return total;
     }
@@ -129,16 +115,11 @@
     public float getTotalByteWrittenThroughput()
     {
         float total = 0;
-        for ( Iterator iter = service.getManagedServiceAddresses().iterator(); iter.hasNext();
)
+        for ( Iterator iter = service.getManagedSessions().iterator(); iter.hasNext(); )
         {
-            SocketAddress element = ( SocketAddress ) iter.next();
-
-            for ( Iterator iter2 = service.getManagedSessions( element ).iterator(); iter2.hasNext();
)
-            {
-                IoSession session = ( IoSession ) iter2.next();
-                total += ( ( IoSessionStat ) session.getAttribute( StatCollector.KEY ) )
-                    .getByteWrittenThroughput();
-            }
+            IoSession session = ( IoSession ) iter.next();
+            total += ( ( IoSessionStat ) session.getAttribute( StatCollector.KEY ) )
+                .getByteWrittenThroughput();
         }
         return total;
     }
@@ -147,16 +128,11 @@
     public float getTotalMessageReadThroughput()
     {
         float total = 0;
-        for ( Iterator iter = service.getManagedServiceAddresses().iterator(); iter.hasNext();
)
+        for ( Iterator iter = service.getManagedSessions().iterator(); iter.hasNext(); )
         {
-            SocketAddress element = ( SocketAddress ) iter.next();
-
-            for ( Iterator iter2 = service.getManagedSessions( element ).iterator(); iter2.hasNext();
)
-            {
-                IoSession session = ( IoSession ) iter2.next();
-                total += ( ( IoSessionStat ) session.getAttribute( StatCollector.KEY ) )
-                    .getMessageReadThroughput();
-            }
+            IoSession session = ( IoSession ) iter.next();
+            total += ( ( IoSessionStat ) session.getAttribute( StatCollector.KEY ) )
+                .getMessageReadThroughput();
         }
         return total;
     }
@@ -165,16 +141,11 @@
     public float getTotalMessageWrittenThroughput()
     {
         float total = 0;
-        for ( Iterator iter = service.getManagedServiceAddresses().iterator(); iter.hasNext();
)
+        for ( Iterator iter = service.getManagedSessions().iterator(); iter.hasNext(); )
         {
-            SocketAddress element = ( SocketAddress ) iter.next();
-
-            for ( Iterator iter2 = service.getManagedSessions( element ).iterator(); iter2.hasNext();
)
-            {
-                IoSession session = ( IoSession ) iter2.next();
-                total += ( ( IoSessionStat ) session.getAttribute( StatCollector.KEY ) )
-                    .getMessageWrittenThroughput();
-            }
+            IoSession session = ( IoSession ) iter.next();
+            total += ( ( IoSessionStat ) session.getAttribute( StatCollector.KEY ) )
+                .getMessageWrittenThroughput();
         }
         return total;
     }
@@ -184,17 +155,12 @@
     {
         float total = 0;
         int count = 0;
-        for ( Iterator iter = service.getManagedServiceAddresses().iterator(); iter.hasNext();
)
+        for ( Iterator iter = service.getManagedSessions().iterator(); iter.hasNext(); )
         {
-            SocketAddress element = ( SocketAddress ) iter.next();
-
-            for ( Iterator iter2 = service.getManagedSessions( element ).iterator(); iter2.hasNext();
)
-            {
-                IoSession session = ( IoSession ) iter2.next();
-                total += ( ( IoSessionStat ) session.getAttribute( StatCollector.KEY ) )
-                    .getByteReadThroughput();
-                count++;
-            }
+            IoSession session = ( IoSession ) iter.next();
+            total += ( ( IoSessionStat ) session.getAttribute( StatCollector.KEY ) )
+                .getByteReadThroughput();
+            count++;
         }
         return total / count;
     }
@@ -204,17 +170,12 @@
     {
         float total = 0;
         int count = 0;
-        for ( Iterator iter = service.getManagedServiceAddresses().iterator(); iter.hasNext();
)
+        for ( Iterator iter = service.getManagedSessions().iterator(); iter.hasNext(); )
         {
-            SocketAddress element = ( SocketAddress ) iter.next();
-
-            for ( Iterator iter2 = service.getManagedSessions( element ).iterator(); iter2.hasNext();
)
-            {
-                IoSession session = ( IoSession ) iter2.next();
-                total += ( ( IoSessionStat ) session.getAttribute( StatCollector.KEY ) )
-                    .getByteWrittenThroughput();
-                count++;
-            }
+            IoSession session = ( IoSession ) iter.next();
+            total += ( ( IoSessionStat ) session.getAttribute( StatCollector.KEY ) )
+                .getByteWrittenThroughput();
+            count++;
         }
         return total / count;
     }
@@ -224,17 +185,12 @@
     {
         float total = 0;
         int count = 0;
-        for ( Iterator iter = service.getManagedServiceAddresses().iterator(); iter.hasNext();
)
+        for ( Iterator iter = service.getManagedSessions().iterator(); iter.hasNext(); )
         {
-            SocketAddress element = ( SocketAddress ) iter.next();
-
-            for ( Iterator iter2 = service.getManagedSessions( element ).iterator(); iter2.hasNext();
)
-            {
-                IoSession session = ( IoSession ) iter2.next();
-                total += ( ( IoSessionStat ) session.getAttribute( StatCollector.KEY ) )
-                    .getMessageReadThroughput();
-                count++;
-            }
+            IoSession session = ( IoSession ) iter.next();
+            total += ( ( IoSessionStat ) session.getAttribute( StatCollector.KEY ) )
+                .getMessageReadThroughput();
+            count++;
         }
         return total / count;
     }
@@ -244,17 +200,12 @@
     {
         float total = 0;
         int count = 0;
-        for ( Iterator iter = service.getManagedServiceAddresses().iterator(); iter.hasNext();
)
+        for ( Iterator iter = service.getManagedSessions().iterator(); iter.hasNext(); )
         {
-            SocketAddress element = ( SocketAddress ) iter.next();
-
-            for ( Iterator iter2 = service.getManagedSessions( element ).iterator(); iter2.hasNext();
)
-            {
-                IoSession session = ( IoSession ) iter2.next();
-                total += ( ( IoSessionStat ) session.getAttribute( StatCollector.KEY ) )
-                    .getMessageWrittenThroughput();
-                count++;
-            }
+            IoSession session = ( IoSession ) iter.next();
+            total += ( ( IoSessionStat ) session.getAttribute( StatCollector.KEY ) )
+                .getMessageWrittenThroughput();
+            count++;
         }
         return total / count;
     }
@@ -262,46 +213,39 @@
 
     public void closeAllSessions()
     {
-        for ( Iterator iter = service.getManagedServiceAddresses().iterator(); iter.hasNext();
)
+        for ( Iterator iter = service.getManagedSessions().iterator(); iter.hasNext(); )
         {
-            SocketAddress element = ( SocketAddress ) iter.next();
+            IoSession session = ( IoSession ) iter.next();
+            session.close();
+        }
+    }
+
+    public ObjectName preRegister( MBeanServer server, ObjectName name ) throws Exception

+    {
+        return name;
+    }
 
-            for ( Iterator iter2 = service.getManagedSessions( element ).iterator(); iter2.hasNext();
)
+    public void postRegister( Boolean registrationDone )
+    {
+        if( registrationDone.booleanValue() )
+        {
+            if( autoStartCollecting )
             {
-                IoSession session = ( IoSession ) iter2.next();
-                session.close();
+                startCollectingStats();
             }
-        }
 
+        }
     }
 
-	public ObjectName preRegister( MBeanServer server, ObjectName name ) throws Exception 
-	{
-		return name;
-	}
-
-	public void postRegister( Boolean registrationDone ) 
-	{
-		if( registrationDone ) 
-		{
-			if( autoStartCollecting ) 
-			{
-				startCollectingStats();
-			}
-				
-		}
-	}
-	
-	public void preDeregister() throws Exception 
-	{
-		if ( collector != null && collector.isRunning() ) 
-		{
-			stopCollectingStats();
-		}
-	}
-
-	public void postDeregister() 
-	{
-	}
+    public void preDeregister() throws Exception
+    {
+        if( collector != null && collector.isRunning() )
+        {
+            stopCollectingStats();
+        }
+    }
 
+    public void postDeregister()
+    {
+    }
 }



Mime
View raw message