directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r345893 - in /directory/network/trunk/src: examples/org/apache/mina/examples/sumup/ examples/org/apache/mina/examples/tennis/ java/org/apache/mina/common/ java/org/apache/mina/common/support/ java/org/apache/mina/transport/socket/nio/suppor...
Date Mon, 21 Nov 2005 11:11:48 GMT
Author: trustin
Date: Mon Nov 21 03:11:35 2005
New Revision: 345893

URL: http://svn.apache.org/viewcvs?rev=345893&view=rev
Log:
Added IoSession.getCloseFuture() to let users wait for the connection to get closed.

Modified:
    directory/network/trunk/src/examples/org/apache/mina/examples/sumup/Client.java
    directory/network/trunk/src/examples/org/apache/mina/examples/tennis/Main.java
    directory/network/trunk/src/java/org/apache/mina/common/IoSession.java
    directory/network/trunk/src/java/org/apache/mina/common/support/BaseIoSession.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketIoProcessor.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java
    directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/sumup/Client.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/sumup/Client.java?rev=345893&r1=345892&r2=345893&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/sumup/Client.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/sumup/Client.java Mon Nov
21 03:11:35 2005
@@ -90,10 +90,7 @@
         }
 
         // wait until the summation is done
-        while( session.isConnected() )
-        {
-            Thread.sleep( 100 );
-        }
+        session.getCloseFuture().join();
         
         // Clear the filter chain so that they are deinitialized.
         connector.getFilterChain().clear();

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=345893&r1=345892&r2=345893&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 Mon Nov
21 03:11:35 2005
@@ -50,10 +50,7 @@
         session.write( new TennisBall( 10 ) );
 
         // Wait until the match ends.
-        while( session.isConnected() )
-        {
-            Thread.sleep( 100 );
-        }
+        session.getCloseFuture().join();
         
         registry.unbind( service );
     }

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoSession.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoSession.java?rev=345893&r1=345892&r2=345893&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoSession.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoSession.java Mon Nov 21 03:11:35
2005
@@ -140,6 +140,12 @@
      * (but not disconnected yet) or is closed.
      */
     boolean isClosing();
+    
+    /**
+     * Returns the {@link CloseFuture} of this session.  This method returns
+     * the same instance whenever user calls it.
+     */
+    CloseFuture getCloseFuture();
 
     /**
      * Returns the socket address of remote peer. 

Modified: directory/network/trunk/src/java/org/apache/mina/common/support/BaseIoSession.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/support/BaseIoSession.java?rev=345893&r1=345892&r2=345893&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/support/BaseIoSession.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/support/BaseIoSession.java Mon
Nov 21 03:11:35 2005
@@ -50,7 +50,7 @@
     /** 
      * A future that will be set 'closed' when the connection is closed.
      */
-    protected final CloseFuture closeFuture = new CloseFuture();
+    private final CloseFuture closeFuture = new CloseFuture();
     private boolean closing;
 
     // Configuration variables
@@ -95,6 +95,11 @@
         {
             return closing;
         }
+    }
+    
+    public CloseFuture getCloseFuture()
+    {
+        return closeFuture;
     }
     
     public CloseFuture close()

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java?rev=345893&r1=345892&r2=345893&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
Mon Nov 21 03:11:35 2005
@@ -474,7 +474,7 @@
                 {
                     exceptionMonitor.exceptionCaught( this, e );
                 }
-                session.notifyClose();
+                session.getCloseFuture().setClosed();
                 key.cancel();
                 selector.wakeup(); // wake up again to trigger thread death
             }

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java?rev=345893&r1=345892&r2=345893&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
Mon Nov 21 03:11:35 2005
@@ -97,11 +97,6 @@
         return handler;
     }
     
-    void notifyClose()
-    {
-        closeFuture.setClosed();
-    }
-    
     protected void close0( CloseFuture closeFuture )
     {
         managerFilterChain.filterClose( this, closeFuture );

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketIoProcessor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketIoProcessor.java?rev=345893&r1=345892&r2=345893&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketIoProcessor.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketIoProcessor.java
Mon Nov 21 03:11:35 2005
@@ -214,7 +214,7 @@
                 releaseWriteBuffers( session );
 
                 session.getManagerFilterChain().sessionClosed( session );
-                session.notifyClose();
+                session.getCloseFuture().setClosed();
             }
         }
     }

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java?rev=345893&r1=345892&r2=345893&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java
Mon Nov 21 03:11:35 2005
@@ -109,11 +109,6 @@
         return handler;
     }
     
-    void notifyClose()
-    {
-        closeFuture.setClosed();
-    }
-    
     protected void close0( CloseFuture closeFuture )
     {
         filterChain.filterClose( this, closeFuture );

Modified: directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java?rev=345893&r1=345892&r2=345893&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java
Mon Nov 21 03:11:35 2005
@@ -118,11 +118,6 @@
         return null;
     }
     
-    CloseFuture getCloseFuture()
-    {
-        return closeFuture;
-    }
-
     protected void close0( CloseFuture closeFuture )
     {
         managerFilterChain.filterClose( this, closeFuture );



Mime
View raw message