directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r124903 - in incubator/directory/network/trunk/mina/src: examples/org/apache/mina/examples/sumup java/org/apache/mina/io java/org/apache/mina/io/datagram java/org/apache/mina/io/socket
Date Tue, 11 Jan 2005 08:49:39 GMT
Author: trustin
Date: Tue Jan 11 00:49:37 2005
New Revision: 124903

URL: http://svn.apache.org/viewcvs?view=rev&rev=124903
Log:
 * Modified Connector not to retuen IoSession
Modified:
   incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/sumup/Client.java
   incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramConnector.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketConnector.java

Modified: incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/sumup/Client.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/sumup/Client.java?view=diff&rev=124903&p1=incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/sumup/Client.java&r1=124902&p2=incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/sumup/Client.java&r2=124903
==============================================================================
--- incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/sumup/Client.java
(original)
+++ incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/sumup/Client.java
Tue Jan 11 00:49:37 2005
@@ -7,7 +7,6 @@
 import java.net.InetSocketAddress;
 
 import org.apache.mina.io.Connector;
-import org.apache.mina.io.IoSession;
 import org.apache.mina.io.filter.IoThreadPoolFilter;
 import org.apache.mina.io.socket.SocketConnector;
 import org.apache.mina.protocol.IoAdapter;
@@ -54,10 +53,9 @@
 		adapter.addFilter(Integer.MAX_VALUE, protocolThreadPoolFilter);
 		
 		ProtocolProvider protocolProvider = new ClientProtocolProvider(values);
-		IoSession session;
 		for ( ;; ) {
 			try {
-				session = connector.connect(new InetSocketAddress(HOSTNAME, PORT), CONNECT_TIMEOUT, adapter.adapt(protocolProvider));
+				connector.connect(new InetSocketAddress(HOSTNAME, PORT), CONNECT_TIMEOUT, adapter.adapt(protocolProvider));
 				break;
 			} catch (IOException e) {
 				System.err.println("Failed to connect.");
@@ -67,7 +65,8 @@
 		}
 		
 		// wait until the summation is done
-		while ( session.isConnected() ) {
+		ClientSessionHandler sessionHandler = (ClientSessionHandler) protocolProvider.getHandler();
+		while ( sessionHandler.isFinished() ) {
 			Thread.sleep(100);
 		}
 		

Modified: incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java?view=diff&rev=124903&p1=incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java&r1=124902&p2=incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java&r2=124903
==============================================================================
--- incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java
(original)
+++ incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java
Tue Jan 11 00:49:37 2005
@@ -15,14 +15,14 @@
  */
 public class ClientSessionHandler implements ProtocolHandler {
 	private final int[] values;
-	private boolean complete;
+	private boolean finished;
 
 	public ClientSessionHandler(int[] values) {
 		this.values = values;
 	}
 
-	public boolean isComplete() {
-		return complete;
+	public boolean isFinished() {
+		return finished;
 	}
 
 	public void sessionOpened(ProtocolSession session) {
@@ -54,13 +54,13 @@
 				// print the sum and disconnect.
 				System.out.println("The sum: " + rm.getValue());
 				session.close();
-				complete = true;
+				finished = true;
 			}
 		} else {
 			// seever returned error code because of overflow, etc.
 			System.err.println("Server error, disconnecting...");
 			session.close();
-			complete = true;
+			finished = true;
 		}
 	}
 

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java?view=diff&rev=124903&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java&r1=124902&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java&r2=124903
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java	Tue
Jan 11 00:49:37 2005
@@ -56,7 +56,7 @@
      * 
      * @throws IOException if failed to connect
      */
-    IoSession connect( SocketAddress address, IoHandler defaultHandler )
+    void connect( SocketAddress address, IoHandler defaultHandler )
             throws IOException;
 
     /**
@@ -66,7 +66,7 @@
      * 
      * @throws IOException if failed to connect
      */
-    IoSession connect( SocketAddress address, int timeout,
+    void connect( SocketAddress address, int timeout,
                       IoHandler defaultHandler ) throws IOException;
 
     /**

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramConnector.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramConnector.java?view=diff&rev=124903&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramConnector.java&r1=124902&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramConnector.java&r2=124903
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramConnector.java
(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramConnector.java
Tue Jan 11 00:49:37 2005
@@ -34,7 +34,6 @@
 import org.apache.mina.io.ExceptionMonitor;
 import org.apache.mina.io.IoHandler;
 import org.apache.mina.io.IoHandlerFilter;
-import org.apache.mina.io.IoSession;
 import org.apache.mina.util.IoHandlerFilterManager;
 import org.apache.mina.util.Queue;
 
@@ -74,7 +73,7 @@
         selector = Selector.open();
     }
 
-    public IoSession connect( SocketAddress address, IoHandler defaultHandler )
+    public void connect( SocketAddress address, IoHandler defaultHandler )
             throws IOException
     {
         if( address == null )
@@ -121,14 +120,12 @@
                 }
             }
         }
-
-        return request.session;
     }
 
-    public IoSession connect( SocketAddress address, int timeout,
+    public void connect( SocketAddress address, int timeout,
                              IoHandler defaultHandler ) throws IOException
     {
-        return connect( address, defaultHandler );
+        connect( address, defaultHandler );
     }
 
     public void closeSession( DatagramSession session )

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketConnector.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketConnector.java?view=diff&rev=124903&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketConnector.java&r1=124902&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketConnector.java&r2=124903
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketConnector.java
(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketConnector.java
Tue Jan 11 00:49:37 2005
@@ -33,7 +33,6 @@
 import org.apache.mina.io.ExceptionMonitor;
 import org.apache.mina.io.IoHandler;
 import org.apache.mina.io.IoHandlerFilter;
-import org.apache.mina.io.IoSession;
 import org.apache.mina.util.IoHandlerFilterManager;
 
 /**
@@ -66,13 +65,13 @@
         selector = Selector.open();
     }
 
-    public IoSession connect( SocketAddress address, IoHandler defaultHandler )
+    public void connect( SocketAddress address, IoHandler defaultHandler )
             throws IOException
     {
-        return connect( address, Integer.MAX_VALUE, defaultHandler );
+        connect( address, Integer.MAX_VALUE, defaultHandler );
     }
 
-    public IoSession connect( SocketAddress address, int timeout,
+    public void connect( SocketAddress address, int timeout,
                              IoHandler defaultHandler ) throws IOException
     {
         if( address == null )
@@ -92,7 +91,7 @@
 
         if( ch.connect( address ) )
         {
-            return newSession( ch, defaultHandler );
+            newSession( ch, defaultHandler );
         }
         else
         {
@@ -125,8 +124,6 @@
 
             if( entry.exception != null )
                 throw entry.exception;
-            else
-                return entry.session;
         }
     }
 
@@ -147,8 +144,9 @@
             try
             {
                 ch.finishConnect();
-                SocketSession session = newSession( ch, entry.handler );
-                entry.session = session;
+                newSession( ch, entry.handler );
+//                SocketSession session = newSession( ch, entry.handler );
+//                entry.session = session;
                 entry.done = true;
 
                 synchronized( entry )
@@ -265,7 +263,7 @@
 
         private final IoHandler handler;
 
-        private SocketSession session;
+//        private SocketSession session;
 
         private boolean done;
 

Mime
View raw message