directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r465515 - in /directory/trunks/mina/core/src/main/java/org/apache/mina/common: IoConnector.java support/BaseIoConnector.java
Date Thu, 19 Oct 2006 07:04:38 GMT
Author: trustin
Date: Thu Oct 19 00:04:34 2006
New Revision: 465515

URL: http://svn.apache.org/viewvc?view=rev&rev=465515
Log:
Restricted IoConnector.setRemoteAddress() not to be called once after connect() is invoked.

Modified:
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/IoConnector.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoConnector.java

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/IoConnector.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/common/IoConnector.java?view=diff&rev=465515&r1=465514&r2=465515
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/IoConnector.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/IoConnector.java Thu Oct
19 00:04:34 2006
@@ -55,12 +55,16 @@
     void setLocalAddress( SocketAddress localAddress );
     
     /**
-     * Returns the address of the remote peer to connect to.
+     * Returns the address of the remote peer to connect to.  This property can't
+     * be changed once after {@link #connect()} method is called.
      */
     SocketAddress getRemoteAddress();
     
     /**
-     * Sets the address of the remote peer to connect to.
+     * Sets the address of the remote peer to connect to.  This property can't be
+     * changed once after {@link #connect()} method is called.
+     * 
+     * @throws IllegalStateException if {@link #connect()} method is already called
      */
     void setRemoteAddress( SocketAddress remoteAddress );
     

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoConnector.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoConnector.java?view=diff&rev=465515&r1=465514&r2=465515
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoConnector.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/support/BaseIoConnector.java
Thu Oct 19 00:04:34 2006
@@ -35,6 +35,7 @@
     private SocketAddress localAddress;
     private SocketAddress remoteAddress;
     private int connectTimeout = 60; // 1 minute
+    private boolean calledConnect;
 
     protected BaseIoConnector()
     {
@@ -80,6 +81,12 @@
                     "remoteAddress type: " + remoteAddress.getClass() + 
                     " (expected: " + getAddressType() + ")");
         }
+        
+        if( calledConnect )
+        {
+            throw new IllegalStateException(
+                    "remoteAddress property can't be set after connect() is called." );
+        }
 
         this.remoteAddress = remoteAddress;
     }
@@ -110,6 +117,8 @@
         if( getHandler() == null )
             throw new IllegalStateException( "handler is not set." );
 
+        calledConnect = true;
+        
         return doConnect();
     }
 



Mime
View raw message