directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r209223 - in /directory/network/trunk/src: examples/org/apache/mina/examples/netcat/ java/org/apache/mina/common/ java/org/apache/mina/transport/socket/nio/ java/org/apache/mina/transport/vmpipe/
Date Tue, 05 Jul 2005 05:33:15 GMT
Author: trustin
Date: Mon Jul  4 22:33:13 2005
New Revision: 209223

URL: http://svn.apache.org/viewcvs?rev=209223&view=rev
Log:
Fix for DIRMINA-64

* Added: IoSessionManagerConfig, IoAcceptorConfig and IoConnectorConfig
* Added: IoSessionManager.getConfig()
* Added: SocketAcceptorConfig which implements IoAcceptorConfig so that users can configure
ServerSocket parameters.
* Removed: Two IoConnector.connect() methods because you can configure connect timeout using
IoConnectorConfig.
* Removed: SocketAcceptor.backlog peroperty because you can configure backlog using SocketAcceptorConfig.

Added:
    directory/network/trunk/src/java/org/apache/mina/common/BaseIoAcceptorConfig.java   (with
props)
    directory/network/trunk/src/java/org/apache/mina/common/BaseIoConnectorConfig.java   (with
props)
    directory/network/trunk/src/java/org/apache/mina/common/IoAcceptorConfig.java   (with
props)
    directory/network/trunk/src/java/org/apache/mina/common/IoConnectorConfig.java   (with
props)
    directory/network/trunk/src/java/org/apache/mina/common/IoSessionManagerConfig.java  
(with props)
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptorConfig.java
  (with props)
Modified:
    directory/network/trunk/src/examples/org/apache/mina/examples/netcat/Main.java
    directory/network/trunk/src/java/org/apache/mina/common/IoConnector.java
    directory/network/trunk/src/java/org/apache/mina/common/IoSessionManager.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramSessionConfig.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketConnector.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketSessionConfig.java
    directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/netcat/Main.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/netcat/Main.java?rev=209223&r1=209222&r2=209223&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/netcat/Main.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/netcat/Main.java Mon Jul
 4 22:33:13 2005
@@ -20,6 +20,7 @@
 
 import java.net.InetSocketAddress;
 
+import org.apache.mina.common.IoConnectorConfig;
 import org.apache.mina.transport.socket.nio.SocketConnector;
 
 /**
@@ -43,8 +44,13 @@
         // Create TCP/IP connector.
         SocketConnector connector = new SocketConnector();
 
+        // Set connect timeout.
+        ( ( IoConnectorConfig ) connector.getConfig() ).setDefaultConnectTimeout( 30 );
+        
         // Start communication.
-        connector.connect( new InetSocketAddress( args[ 0 ], Integer
-                .parseInt( args[ 1 ] ) ), 60, new NetCatProtocolHandler() );
+        connector.connect( 
+                new InetSocketAddress( args[ 0 ],
+                Integer.parseInt( args[ 1 ] ) ),
+                new NetCatProtocolHandler() );
     }
 }

Added: directory/network/trunk/src/java/org/apache/mina/common/BaseIoAcceptorConfig.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/BaseIoAcceptorConfig.java?rev=209223&view=auto
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/BaseIoAcceptorConfig.java (added)
+++ directory/network/trunk/src/java/org/apache/mina/common/BaseIoAcceptorConfig.java Mon
Jul  4 22:33:13 2005
@@ -0,0 +1,32 @@
+/*
+ *   @(#) $Id$
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.mina.common;
+
+/**
+ * Base implementation of {@link IoAcceptorConfig}s.
+ * 
+ * @author Trustin Lee (trustin@apache.org)
+ * @version $Rev$, $Date$
+ */
+public class BaseIoAcceptorConfig implements IoAcceptorConfig
+{
+    public BaseIoAcceptorConfig()
+    {
+    }
+}

Propchange: directory/network/trunk/src/java/org/apache/mina/common/BaseIoAcceptorConfig.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Added: directory/network/trunk/src/java/org/apache/mina/common/BaseIoConnectorConfig.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/BaseIoConnectorConfig.java?rev=209223&view=auto
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/BaseIoConnectorConfig.java (added)
+++ directory/network/trunk/src/java/org/apache/mina/common/BaseIoConnectorConfig.java Mon
Jul  4 22:33:13 2005
@@ -0,0 +1,53 @@
+/*
+ *   @(#) $Id$
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.mina.common;
+
+/**
+ * Base implementation of {@link IoConnectorConfig}s.
+ * 
+ * @author Trustin Lee (trustin@apache.org)
+ * @version $Rev$, $Date$
+ */
+public class BaseIoConnectorConfig implements IoConnectorConfig
+{
+    private int defaultConnectTimeout = 60; // 1 minute
+
+    public BaseIoConnectorConfig()
+    {
+    }
+
+    public int getDefaultConnectTimeout()
+    {
+        return defaultConnectTimeout;
+    }
+
+    public long getDefaultConnectTimeoutMillis()
+    {
+        return defaultConnectTimeout * 1000L;
+    }
+
+    public void setDefaultConnectTimeout( int defaultConnectTimeout )
+    {
+        if( defaultConnectTimeout <= 0 )
+        {
+            throw new IllegalArgumentException( "defaultConnectTimeout: " + defaultConnectTimeout
);
+        }
+        this.defaultConnectTimeout = defaultConnectTimeout;
+    }
+}

Propchange: directory/network/trunk/src/java/org/apache/mina/common/BaseIoConnectorConfig.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Added: directory/network/trunk/src/java/org/apache/mina/common/IoAcceptorConfig.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoAcceptorConfig.java?rev=209223&view=auto
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoAcceptorConfig.java (added)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoAcceptorConfig.java Mon Jul
 4 22:33:13 2005
@@ -0,0 +1,34 @@
+/*
+ *   @(#) $Id$
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.mina.common;
+
+import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
+
+/**
+ * Provides a configuration for {@link IoSessionManager}.
+ * <p>
+ * It is currently an empty marker interface.  Please refer to
+ * {@link TransportType}-specific settings such as {@link SocketAcceptorConfig}.
+ *
+ * @author The Apache Directory Project
+ * @version $Rev$, $Date$
+ */
+public interface IoAcceptorConfig extends IoSessionManagerConfig
+{
+}

Propchange: directory/network/trunk/src/java/org/apache/mina/common/IoAcceptorConfig.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoConnector.java?rev=209223&r1=209222&r2=209223&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoConnector.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoConnector.java Mon Jul  4 22:33:13
2005
@@ -62,25 +62,4 @@
      */
     ConnectFuture connect( SocketAddress address, SocketAddress localAddress,
                            IoHandler handler ) throws IOException;
-
-    /**
-     * Connects to the specified <code>address</code> with timeout.  If
-     * communication starts successfully, events are fired to the specified
-     * <code>handler</code>.  This method blocks.
-     * 
-     * @throws IOException if failed to connect
-     */
-    ConnectFuture connect( SocketAddress address, int timeout, IoHandler handler )
-            throws IOException;
-    
-    /**
-     * Connects to the specified <code>address</code> with timeout.  If
-     * communication starts successfully, events are fired to the specified
-     * <code>handler</code>.  This method blocks.
-     * 
-     * @param localAddress the local address the channel is bound to
-     * @throws IOException if failed to connect
-     */
-    ConnectFuture connect( SocketAddress address, SocketAddress localAddress,
-                           int timeout, IoHandler handler ) throws IOException;
 }

Added: directory/network/trunk/src/java/org/apache/mina/common/IoConnectorConfig.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoConnectorConfig.java?rev=209223&view=auto
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoConnectorConfig.java (added)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoConnectorConfig.java Mon Jul
 4 22:33:13 2005
@@ -0,0 +1,44 @@
+/*
+ *   @(#) $Id$
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.mina.common;
+
+
+/**
+ * Provides a configuration for {@link IoSessionManager}.
+ *
+ * @author The Apache Directory Project
+ * @version $Rev$, $Date$
+ */
+public interface IoConnectorConfig extends IoSessionManagerConfig
+{
+    /**
+     * Returns the default connect timeout in seconds.
+     */
+    int getDefaultConnectTimeout();
+
+    /**
+     * Returns the default connect timeout in milliseconds.
+     */
+    long getDefaultConnectTimeoutMillis();
+
+    /**
+     * Sets the default connect timeout in seconds.
+     */
+    void setDefaultConnectTimeout( int defaultConnectTimeout );
+}

Propchange: directory/network/trunk/src/java/org/apache/mina/common/IoConnectorConfig.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoSessionManager.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoSessionManager.java?rev=209223&r1=209222&r2=209223&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoSessionManager.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoSessionManager.java Mon Jul
 4 22:33:13 2005
@@ -32,6 +32,11 @@
 public interface IoSessionManager {
     
     /**
+     * Returns the configuration of this session manager.
+     */
+    IoSessionManagerConfig getConfig();
+    
+    /**
      * Returns the filter chain that filters all events which is related
      * with sessions this manager manages.
      */

Added: directory/network/trunk/src/java/org/apache/mina/common/IoSessionManagerConfig.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoSessionManagerConfig.java?rev=209223&view=auto
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoSessionManagerConfig.java (added)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoSessionManagerConfig.java Mon
Jul  4 22:33:13 2005
@@ -0,0 +1,36 @@
+/*
+ *   @(#) $Id$
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.mina.common;
+
+import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
+
+/**
+ * Provides a configuration for {@link IoSessionManager}.
+ * <p>
+ * It is currently an empty marker interface.  Please refer to
+ * {@link TransportType}-specific settings such as {@link SocketAcceptorConfig}.
+ *
+ * @author The Apache Directory Project
+ * @version $Rev$, $Date$
+ * @see IoAcceptorConfig
+ * @see IoConnectorConfig
+ */
+public interface IoSessionManagerConfig
+{
+}

Propchange: directory/network/trunk/src/java/org/apache/mina/common/IoSessionManagerConfig.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java?rev=209223&r1=209222&r2=209223&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
Mon Jul  4 22:33:13 2005
@@ -29,10 +29,12 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.mina.common.BaseIoAcceptorConfig;
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSessionManagerConfig;
 import org.apache.mina.common.IoSessionManagerFilterChain;
 import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.util.ExceptionUtil;
@@ -520,6 +522,15 @@
         }
     }
     
+    /**
+     * This method just returns dummy configuration instance because datagram
+     * transport type (UDP/IP) doesn't provide any configuration.
+     */
+    public IoSessionManagerConfig getConfig()
+    {
+        return new BaseIoAcceptorConfig();
+    }
+
     public IoFilterChain getFilterChain()
     {
         return filters;

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java?rev=209223&r1=209222&r2=209223&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
Mon Jul  4 22:33:13 2005
@@ -27,11 +27,13 @@
 import java.util.Iterator;
 import java.util.Set;
 
+import org.apache.mina.common.BaseIoConnectorConfig;
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.IoConnector;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSessionManagerConfig;
 import org.apache.mina.common.IoSessionManagerFilterChain;
 import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.util.Queue;
@@ -73,16 +75,6 @@
         return connect( address, null, handler);
     }
 
-    public ConnectFuture connect( SocketAddress address, int timeout, IoHandler handler )
throws IOException
-    {
-        return connect( address, null, handler );
-    }
-
-    public ConnectFuture connect( SocketAddress address, SocketAddress localAddress, int
timeout, IoHandler handler ) throws IOException
-    {
-        return connect( address, localAddress, handler );
-    }
-
     public ConnectFuture connect( SocketAddress address, SocketAddress localAddress,
                               IoHandler handler ) throws IOException
     {
@@ -497,5 +489,14 @@
             this.channel = channel;
             this.handler = handler;
         }
+    }
+
+    /**
+     * This method just returns dummy configuration instance because datagram
+     * transport type (UDP/IP) doesn't provide any configuration.
+     */
+    public IoSessionManagerConfig getConfig()
+    {
+        return new BaseIoConnectorConfig();
     }
 }

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramSessionConfig.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramSessionConfig.java?rev=209223&r1=209222&r2=209223&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramSessionConfig.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramSessionConfig.java
Mon Jul  4 22:33:13 2005
@@ -28,9 +28,8 @@
 /**
  * A {@link IoSessionConfig} for datagram transport (UDP/IP).
  * You can downcast {@link IoSessionConfig} instance returned by
- * {@link IoSession#getConfig()} or {@link IoSession#getConfig()}
- * if you've created datagram session using {@link DatagramAcceptor} or 
- * {@link DatagramConnector}.
+ * {@link IoSession#getConfig()} if you've created datagram session using
+ * {@link DatagramAcceptor} or {@link DatagramConnector}.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$,

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java?rev=209223&r1=209222&r2=209223&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
Mon Jul  4 22:33:13 2005
@@ -34,6 +34,7 @@
 import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSessionManagerConfig;
 import org.apache.mina.common.IoSessionManagerFilterChain;
 import org.apache.mina.util.Queue;
 
@@ -47,20 +48,17 @@
 {
     private static volatile int nextId = 0;
 
-    private final IoSessionManagerFilterChain filters = new SocketSessionManagerFilterChain(
this );
-
     private final int id = nextId ++ ;
+    private final SocketAcceptorConfig config = new SocketAcceptorConfig(); 
 
+    private final IoSessionManagerFilterChain filters = new SocketSessionManagerFilterChain(
this );
+    
     private Selector selector;
-
     private final Map channels = new HashMap();
 
     private final Queue registerQueue = new Queue();
-
     private final Queue cancelQueue = new Queue();
     
-    private int backlog = 50;
-
     private Worker worker;
 
 
@@ -71,6 +69,11 @@
     {
     }
 
+    public IoSessionManagerConfig getConfig()
+    {
+        return config;
+    }
+
     /**
      * Binds to the specified <code>address</code> and handles incoming
      * connections with the specified <code>handler</code>.  Backlog value
@@ -100,7 +103,7 @@
             throw new IllegalArgumentException( "Unsupported port number: 0" );
         }
         
-        RegistrationRequest request = new RegistrationRequest( address, backlog, handler
);
+        RegistrationRequest request = new RegistrationRequest( address, handler );
 
         synchronized( this )
         {
@@ -199,27 +202,6 @@
         }
     }
     
-    /**
-     * Returns the default backlog value which is used when user binds. 
-     */
-    public int getBacklog()
-    {
-        return backlog;
-    }
-    
-    /**
-     * Sets the default backlog value which is used when user binds. 
-     */
-    public void setBacklog( int defaultBacklog )
-    {
-        if( defaultBacklog <= 0 )
-        {
-            throw new IllegalArgumentException( "defaultBacklog: " + defaultBacklog );
-        }
-        this.backlog = defaultBacklog;
-    }
-
-
     private class Worker extends Thread
     {
         public Worker()
@@ -359,7 +341,16 @@
             {
                 ssc = ServerSocketChannel.open();
                 ssc.configureBlocking( false );
-                ssc.socket().bind( req.address, req.backlog );
+                
+                // Configure the server socket,
+                ssc.socket().setReuseAddress( config.isReuseAddress() );
+                if( config.getReceiveBufferSize() > 0 )
+                {
+                    ssc.socket().setReceiveBufferSize( config.getReceiveBufferSize() );
+                }
+                
+                // and bind.
+                ssc.socket().bind( req.address, config.getBacklog() );
                 ssc.register( selector, SelectionKey.OP_ACCEPT, req );
 
                 channels.put( req.address, ssc );
@@ -459,18 +450,15 @@
     {
         private final SocketAddress address;
         
-        private final int backlog;
-
         private final IoHandler handler;
         
         private IOException exception; 
         
         private boolean done;
         
-        private RegistrationRequest( SocketAddress address, int backlog, IoHandler handler
)
+        private RegistrationRequest( SocketAddress address, IoHandler handler )
         {
             this.address = address;
-            this.backlog = backlog;
             this.handler = handler;
         }
     }

Added: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptorConfig.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptorConfig.java?rev=209223&view=auto
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptorConfig.java
(added)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptorConfig.java
Mon Jul  4 22:33:13 2005
@@ -0,0 +1,80 @@
+/*
+ *   @(#) $Id$
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.mina.transport.socket.nio;
+
+import org.apache.mina.common.IoAcceptorConfig;
+import org.apache.mina.common.IoSessionManager;
+import org.apache.mina.common.IoSessionManagerConfig;
+
+
+/**
+ * A {@link IoAcceptorConfig} for socket transport (UDP/IP).
+ * You can downcast {@link IoSessionManagerConfig} instance returned by
+ * {@link IoSessionManager#getConfig()}
+ * 
+ * @author Trustin Lee (trustin@apache.org)
+ * @version $Rev$, $Date$,
+ */
+public class SocketAcceptorConfig implements IoAcceptorConfig
+{
+    private boolean reuseAddress = false;
+    private int backlog = 50;
+    private int receiveBufferSize = -1;
+
+    public SocketAcceptorConfig()
+    {
+    }
+
+    public int getReceiveBufferSize()
+    {
+        return receiveBufferSize;
+    }
+
+    /**
+     * @param receiveBufferSize <tt>-1</tt> to use the default value.
+     */
+    public void setReceiveBufferSize( int receiveBufferSize )
+    {
+        this.receiveBufferSize = receiveBufferSize;
+    }
+
+    public boolean isReuseAddress()
+    {
+        return reuseAddress;
+    }
+
+    public void setReuseAddress( boolean reuseAddress )
+    {
+        this.reuseAddress = reuseAddress;
+    }
+
+    public int getBacklog()
+    {
+        return backlog;
+    }
+
+    public void setBacklog( int backlog )
+    {
+        if( backlog <= 0 )
+        {
+            throw new IllegalArgumentException( "backlog: " + backlog );
+        }
+        this.backlog = backlog;
+    }
+}

Propchange: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptorConfig.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketConnector.java?rev=209223&r1=209222&r2=209223&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketConnector.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketConnector.java
Mon Jul  4 22:33:13 2005
@@ -28,11 +28,14 @@
 import java.util.Iterator;
 import java.util.Set;
 
+import org.apache.mina.common.BaseIoConnectorConfig;
 import org.apache.mina.common.BaseIoSessionManager;
 import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.IoConnector;
+import org.apache.mina.common.IoConnectorConfig;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSessionManagerConfig;
 import org.apache.mina.common.IoSessionManagerFilterChain;
 import org.apache.mina.util.ExceptionUtil;
 import org.apache.mina.util.Queue;
@@ -48,6 +51,7 @@
     private static volatile int nextId = 0;
 
     private final int id = nextId++;
+    private final IoConnectorConfig config = new BaseIoConnectorConfig();
 
     private final IoSessionManagerFilterChain filters = new SocketSessionManagerFilterChain(
this );
 
@@ -66,30 +70,17 @@
 
     public ConnectFuture connect( SocketAddress address, IoHandler handler ) throws IOException
     {
-        return connect( address, null, Integer.MAX_VALUE, handler);
-    }
-
-    public ConnectFuture connect( SocketAddress address, SocketAddress localAddress, IoHandler
handler ) throws IOException
-    {
-        return connect( address, localAddress, Integer.MAX_VALUE, handler);
-    }
-
-    public ConnectFuture connect( SocketAddress address, int timeout, IoHandler handler )
throws IOException
-    {
-        return connect( address, null, timeout, handler);
+        return connect( address, null, handler);
     }
 
     public ConnectFuture connect( SocketAddress address, SocketAddress localAddress,
-                              int timeout, IoHandler handler ) throws IOException
+                                  IoHandler handler ) throws IOException
     {
         if( address == null )
             throw new NullPointerException( "address" );
         if( handler == null )
             throw new NullPointerException( "handler" );
 
-        if( timeout <= 0 )
-            throw new IllegalArgumentException( "Illegal timeout: " + timeout );
-
         if( ! ( address instanceof InetSocketAddress ) )
             throw new IllegalArgumentException( "Unexpected address type: "
                                                 + address.getClass() );
@@ -129,7 +120,7 @@
             }
         }
         
-        ConnectionRequest request = new ConnectionRequest( ch, timeout, handler );
+        ConnectionRequest request = new ConnectionRequest( ch, config.getDefaultConnectTimeout(),
handler );
         synchronized( this )
         {
             synchronized( connectQueue )
@@ -348,5 +339,10 @@
     public IoFilterChain getFilterChain()
     {
         return filters;
+    }
+
+    public IoSessionManagerConfig getConfig()
+    {
+        return config;
     }
 }

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketSessionConfig.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketSessionConfig.java?rev=209223&r1=209222&r2=209223&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketSessionConfig.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketSessionConfig.java
Mon Jul  4 22:33:13 2005
@@ -27,9 +27,8 @@
 /**
  * A {@link IoSessionConfig} for socket transport (TCP/IP).
  * You can downcast {@link IoSessionConfig} instance returned by
- * {@link IoSession#getConfig()} or {@link IoSession#getConfig()}
- * if you've created datagram session using {@link SocketAcceptor} or 
- * {@link SocketConnector}.
+ * {@link IoSession#getConfig()} if you've created datagram session
+ * using {@link SocketAcceptor} or {@link SocketConnector}.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$,

Modified: directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java?rev=209223&r1=209222&r2=209223&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
Mon Jul  4 22:33:13 2005
@@ -8,10 +8,12 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.mina.common.BaseIoAcceptorConfig;
 import org.apache.mina.common.BaseIoSessionManager;
 import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSessionManagerConfig;
 
 /**
  * Binds the specified {@link IoHandler} to the specified
@@ -78,6 +80,15 @@
         }
     }
     
+    /**
+     * This method just returns dummy configuration instance because in-VM pipe
+     * transport type doesn't provide any configuration.
+     */
+    public IoSessionManagerConfig getConfig()
+    {
+        return new BaseIoAcceptorConfig();
+    }
+
     public IoFilterChain getFilterChain()
     {
         return filterChain;

Modified: directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java?rev=209223&r1=209222&r2=209223&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
Mon Jul  4 22:33:13 2005
@@ -6,11 +6,13 @@
 import java.io.IOException;
 import java.net.SocketAddress;
 
+import org.apache.mina.common.BaseIoConnectorConfig;
 import org.apache.mina.common.BaseIoSessionManager;
 import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.IoConnector;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSessionManagerConfig;
 import org.apache.mina.transport.vmpipe.VmPipeAcceptor.Entry;
 import org.apache.mina.util.AnonymousSocketAddress;
 
@@ -41,6 +43,15 @@
         }
     }
     
+    /**
+     * This method just returns dummy configuration instance because in-VM pipe
+     * transport type doesn't provide any configuration.
+     */
+    public IoSessionManagerConfig getConfig()
+    {
+        return new BaseIoConnectorConfig();
+    }
+
     public IoFilterChain getFilterChain()
     {
         return filterChain;
@@ -48,20 +59,10 @@
 
     public ConnectFuture connect( SocketAddress address, IoHandler handler ) throws IOException

     {
-        return connect( address, null, Integer.MAX_VALUE, handler );
+        return connect( address, null, handler );
     }
 
     public ConnectFuture connect( SocketAddress address, SocketAddress localAddress, IoHandler
handler ) throws IOException
-    {
-        return connect( address, localAddress, Integer.MAX_VALUE, handler );
-    }
-
-    public ConnectFuture connect( SocketAddress address, int timeout, IoHandler handler )
throws IOException
-    {
-        return connect( address, null, timeout, handler );
-    }
-
-    public ConnectFuture connect( SocketAddress address, SocketAddress localAddress, int
timeout, IoHandler handler ) throws IOException
     {
         if( address == null )
             throw new NullPointerException( "address" );



Mime
View raw message