directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r359356 - in /directory/trunk/mina-core/src: main/java/org/apache/mina/transport/socket/nio/ main/java/org/apache/mina/transport/socket/nio/support/ test/java/org/apache/mina/transport/socket/nio/
Date Wed, 28 Dec 2005 02:49:53 GMT
Author: akarasulu
Date: Tue Dec 27 18:49:40 2005
New Revision: 359356

URL: http://svn.apache.org/viewcvs?rev=359356&view=rev
Log:
merging changes from 359345:359346 on trunk of old trunk after freeze

Added:
    directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramSessionManager.java
Modified:
    directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
    directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
    directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramSession.java
    directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
    directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
    directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/SocketSessionManager.java
    directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java
    directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
    directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramFilterChain.java
    directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
    directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionManager.java
    directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java
    directory/trunk/mina-core/src/test/java/org/apache/mina/transport/socket/nio/AbstractBindTest.java

Modified: directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java?rev=359356&r1=359355&r2=359356&view=diff
==============================================================================
--- directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
(original)
+++ directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
Tue Dec 27 18:49:40 2005
@@ -28,7 +28,7 @@
  * @author The Apache Directory Project (dev@directory.apache.org)
  * @version $Rev$, $Date$
  */
-public class DatagramAcceptor extends DelegatedIoAcceptor
+public class DatagramAcceptor extends DelegatedIoAcceptor implements DatagramSessionManager
 {
     /**
      * Creates a new instance.
@@ -37,4 +37,54 @@
     {
         init( new DatagramAcceptorDelegate( this ) );
     }
+
+	public int getReceiveBufferSize()
+	{
+		return ( ( DatagramAcceptorDelegate ) delegate ).getReceiveBufferSize();
+	}
+
+	public void setReceiveBufferSize( int receiveBufferSize )
+	{
+		( ( DatagramAcceptorDelegate ) delegate ).setReceiveBufferSize( receiveBufferSize );
+	}
+
+	public boolean getBroadcast()
+	{
+		return ( ( DatagramAcceptorDelegate ) delegate ).getBroadcast();
+	}
+
+	public void setBroadcast( boolean broadcast )
+	{
+		( ( DatagramAcceptorDelegate ) delegate ).setBroadcast( broadcast );
+	}
+
+	public int getSendBufferSize()
+	{
+		return ( ( DatagramAcceptorDelegate ) delegate ).getSendBufferSize();
+	}
+
+	public void setSendBufferSize( int sendBufferSize )
+	{
+		( ( DatagramAcceptorDelegate ) delegate ).setSendBufferSize( sendBufferSize );
+	}
+
+	public int getTrafficClass()
+	{
+		return ( ( DatagramAcceptorDelegate ) delegate ).getTrafficClass();
+	}
+
+	public void setTrafficClass( int trafficClass )
+	{
+		( ( DatagramAcceptorDelegate ) delegate ).setTrafficClass( trafficClass );
+	}
+
+	public boolean getReuseAddress()
+	{
+		return ( ( DatagramAcceptorDelegate ) delegate ).getReuseAddress();
+	}
+
+	public void setReuseAddress( boolean reuseAddress )
+	{
+		( ( DatagramAcceptorDelegate ) delegate ).setReuseAddress( reuseAddress );
+	}
 }

Modified: directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
URL: http://svn.apache.org/viewcvs/directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramConnector.java?rev=359356&r1=359355&r2=359356&view=diff
==============================================================================
--- directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
(original)
+++ directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
Tue Dec 27 18:49:40 2005
@@ -28,7 +28,7 @@
  * @author The Apache Directory Project (dev@directory.apache.org)
  * @version $Rev$, $Date$
  */
-public class DatagramConnector extends DelegatedIoConnector
+public class DatagramConnector extends DelegatedIoConnector implements DatagramSessionManager
 {
     /**
      * Creates a new instance.
@@ -37,4 +37,55 @@
     {
         init( new DatagramConnectorDelegate( this ) );
     }
+
+	public int getReceiveBufferSize()
+	{
+		return ( ( DatagramConnectorDelegate ) delegate ).getReceiveBufferSize();
+	}
+
+	public void setReceiveBufferSize( int receiveBufferSize )
+	{
+		( ( DatagramConnectorDelegate ) delegate ).setReceiveBufferSize( receiveBufferSize );
+	}
+
+	public boolean getBroadcast()
+	{
+		return ( ( DatagramConnectorDelegate ) delegate ).getBroadcast();
+	}
+
+	public void setBroadcast( boolean broadcast )
+	{
+		( ( DatagramConnectorDelegate ) delegate ).setBroadcast( broadcast );
+	}
+
+	public int getSendBufferSize()
+	{
+		return ( ( DatagramConnectorDelegate ) delegate ).getSendBufferSize();
+	}
+
+	public void setSendBufferSize( int sendBufferSize )
+	{
+		( ( DatagramConnectorDelegate ) delegate ).setSendBufferSize( sendBufferSize );
+	}
+
+	public int getTrafficClass()
+	{
+		return ( ( DatagramConnectorDelegate ) delegate ).getTrafficClass();
+	}
+
+	public void setTrafficClass( int trafficClass )
+	{
+		( ( DatagramConnectorDelegate ) delegate ).setTrafficClass( trafficClass );
+	}
+
+
+	public boolean getReuseAddress()
+	{
+		return ( ( DatagramConnectorDelegate ) delegate ).getReuseAddress();
+	}
+
+	public void setReuseAddress( boolean reuseAddress )
+	{
+		( ( DatagramConnectorDelegate ) delegate ).setReuseAddress( reuseAddress );
+	}
 }

Modified: directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramSession.java
URL: http://svn.apache.org/viewcvs/directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramSession.java?rev=359356&r1=359355&r2=359356&view=diff
==============================================================================
--- directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramSession.java
(original)
+++ directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramSession.java
Tue Dec 27 18:49:40 2005
@@ -30,8 +30,44 @@
  */
 public interface DatagramSession extends IoSession
 {
-    boolean getReuseAddress() throws SocketException;
-    void setReuseAddress( boolean on ) throws SocketException;
-    int getTrafficClass() throws SocketException;
-    void setTrafficClass( int tc ) throws SocketException;
+	/**
+	 * @see DatagramSocket#getReceiveBufferSize()
+	 */
+	int getReceiveBufferSize() throws SocketException;
+	/**
+	 * @see DatagramSocket#setReceiveBufferSize(int)
+	 */
+	void setReceiveBufferSize( int receiveBufferSize ) throws SocketException;
+	/**
+	 * @see DatagramSocket#getReuseAddress()
+	 */
+	boolean getReuseAddress() throws SocketException;
+	/**
+	 * @see DatagramSocket#setReuseAddress(boolean)
+	 */
+	void setReuseAddress( boolean reuseAddress ) throws SocketException;
+	/**
+	 * @see DatagramSocket#getBroadcast()
+	 */
+	boolean getBroadcast() throws SocketException;
+	/**
+	 * @see DatagramSocket#setBroadcast(boolean)
+	 */
+	void setBroadcast( boolean broadcast ) throws SocketException;
+	/**
+	 * @see DatagramSocket#getSendBufferSize()
+	 */
+	int getSendBufferSize() throws SocketException;
+	/**
+	 * @see DatagramSocket#setSendBufferSize(int)
+	 */
+	void setSendBufferSize( int sendBufferSize ) throws SocketException;
+	/**
+	 * @see DatagramSocket#getTrafficClass()
+	 */
+	int getTrafficClass() throws SocketException;
+	/**
+	 * @see DatagramSocket#setTrafficClass(int)
+	 */
+	void setTrafficClass( int trafficClass ) throws SocketException;
 }

Added: directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramSessionManager.java
URL: http://svn.apache.org/viewcvs/directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramSessionManager.java?rev=359356&view=auto
==============================================================================
--- directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramSessionManager.java
(added)
+++ directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/DatagramSessionManager.java
Tue Dec 27 18:49:40 2005
@@ -0,0 +1,75 @@
+/*
+ *   @(#) $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 java.net.DatagramSocket;
+
+import org.apache.mina.common.IoSessionManager;
+
+/**
+ * An {@link IoSessionManager} which provides some common properties related with
+ * NIO UDP/IP sockets.
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ *
+ */
+public interface DatagramSessionManager extends IoSessionManager
+{
+	/**
+	 * @see DatagramSocket#getBroadcast()
+	 */
+	boolean getBroadcast();
+	/**
+	 * @see DatagramSocket#setBroadcast(boolean)
+	 */
+	void setBroadcast( boolean broadcast );
+	/**
+	 * @see DatagramSocket#getReuseAddress()
+	 */
+	boolean getReuseAddress();
+	/**
+	 * @see DatagramSocket#setReuseAddress(boolean)
+	 */
+	void setReuseAddress( boolean reuseAddress );
+	/**
+	 * @see DatagramSocket#getReceiveBufferSize()
+	 */
+	int getReceiveBufferSize();
+	/**
+	 * @see DatagramSocket#setReceiveBufferSize(int)
+	 */
+	void setReceiveBufferSize( int receiveBufferSize );
+	/**
+	 * @see DatagramSocket#getSendBufferSize()
+	 */
+	int getSendBufferSize();
+	/**
+	 * @see DatagramSocket#setSendBufferSize(int)
+	 */
+	void setSendBufferSize( int sendBufferSize );
+	/**
+	 * @see DatagramSocket#getTrafficClass()
+	 */
+	int getTrafficClass();
+	/**
+	 * @see DatagramSocket#setTrafficClass(int)
+	 */
+	void setTrafficClass( int trafficClass );
+}

Modified: directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java?rev=359356&r1=359355&r2=359356&view=diff
==============================================================================
--- directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
(original)
+++ directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
Tue Dec 27 18:49:40 2005
@@ -70,14 +70,4 @@
     {
         ( ( SocketAcceptorDelegate ) delegate ).setBacklog( backlog );
     }
-
-    public int getProcessors()
-    {
-        return ( ( SocketAcceptorDelegate ) delegate ).getProcessors();
-    }
-
-    public void setProcessors( int nProcessor )
-    {
-        ( ( SocketAcceptorDelegate ) delegate ).setProcessors( nProcessor );
-    }
 }

Modified: directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
URL: http://svn.apache.org/viewcvs/directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java?rev=359356&r1=359355&r2=359356&view=diff
==============================================================================
--- directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
(original)
+++ directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
Tue Dec 27 18:49:40 2005
@@ -37,15 +37,4 @@
     {
         init( new SocketConnectorDelegate( this ) );
     }
-
-
-    public int getProcessors()
-    {
-        return ( ( SocketConnectorDelegate ) delegate ).getProcessors();
-    }
-
-    public void setProcessors( int nProcessor )
-    {
-        ( ( SocketConnectorDelegate ) delegate ).setProcessors( nProcessor );
-    }
 }

Modified: directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/SocketSessionManager.java
URL: http://svn.apache.org/viewcvs/directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/SocketSessionManager.java?rev=359356&r1=359355&r2=359356&view=diff
==============================================================================
--- directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/SocketSessionManager.java
(original)
+++ directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/SocketSessionManager.java
Tue Dec 27 18:49:40 2005
@@ -21,24 +21,13 @@
 import org.apache.mina.common.IoSessionManager;
 
 /**
- * An {@link IoSessionManager} which provides some properties related with
- * NIO sockets.
+ * An {@link IoSessionManager} which provides some common properties related with
+ * NIO TCP/IP sockets.
  *
  * @author The Apache Directory Project (dev@directory.apache.org)
  * @version $Rev$, $Date$
  *
  */
-public interface SocketSessionManager
+public interface SocketSessionManager extends IoSessionManager
 {
-    /**
-     * Returns the number of worker threads assigned to perform socket I/O.
-     */
-    int getProcessors();
-    
-    /**
-     * Sets the number of worker threads assigned to perform socket I/O.
-     * Decreasing this number won't stop threads immediately.  It will
-     * not stop until all sessions assigned to it are closed.
-     */
-    void setProcessors( int nProcessor );
 }

Modified: directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java
URL: http://svn.apache.org/viewcvs/directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java?rev=359356&r1=359355&r2=359356&view=diff
==============================================================================
--- directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java
(original)
+++ directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java
Tue Dec 27 18:49:40 2005
@@ -53,6 +53,11 @@
     private final IoAcceptor wrapper;
     private final int id = nextId ++ ;
     private Selector selector;
+    private boolean broadcast;
+    private boolean reuseAddress;
+    private int receiveBufferSize = -1;
+    private int sendBufferSize = -1;
+    private int trafficClass = -1;
     private final Map channels = new HashMap();
     private final Queue registerQueue = new Queue();
     private final Queue cancelQueue = new Queue();
@@ -209,8 +214,59 @@
         
         return s;
     }
+    
+    public boolean getBroadcast()
+    {
+    	return broadcast;
+    }
+    
+    public void setBroadcast( boolean broadcast )
+    {
+    	this.broadcast = broadcast;
+    }
+    
+    public boolean getReuseAddress()
+    {
+    	return reuseAddress;
+    }
+    
+    public void setReuseAddress( boolean reuseAddress )
+    {
+    	this.reuseAddress = reuseAddress;
+    }
+
 
-    private synchronized void startupWorker() throws IOException
+	public int getReceiveBufferSize()
+	{
+		return receiveBufferSize;
+	}
+
+	public void setReceiveBufferSize( int receiveBufferSize )
+	{
+		this.receiveBufferSize = receiveBufferSize;
+	}
+
+	public int getSendBufferSize()
+	{
+		return sendBufferSize;
+	}
+
+	public void setSendBufferSize( int sendBufferSize )
+	{
+		this.sendBufferSize = sendBufferSize;
+	}
+
+	public int getTrafficClass()
+	{
+		return trafficClass;
+	}
+
+	public void setTrafficClass( int trafficClass )
+	{
+		this.trafficClass = trafficClass;
+	}
+
+	private synchronized void startupWorker() throws IOException
     {
         if( worker == null )
         {
@@ -495,6 +551,20 @@
             try
             {
                 ch = DatagramChannel.open();
+                ch.socket().setReuseAddress( reuseAddress );
+                ch.socket().setBroadcast( broadcast );
+                if( receiveBufferSize > 0 )
+                {
+                	ch.socket().setReceiveBufferSize( receiveBufferSize );
+                }
+                if( sendBufferSize > 0 )
+                {
+                	ch.socket().setSendBufferSize( sendBufferSize );
+                }
+                if( trafficClass > 0 )
+                {
+                	ch.socket().setTrafficClass( trafficClass );
+                }
                 ch.configureBlocking( false );
                 ch.socket().bind( req.address );
                 ch.register( selector, SelectionKey.OP_READ, req );
@@ -516,6 +586,7 @@
                 {
                     try
                     {
+                    	ch.disconnect();
                         ch.close();
                     }
                     catch( Throwable e )
@@ -559,6 +630,7 @@
                     SelectionKey key = ch.keyFor( selector );
                     key.cancel();
                     selector.wakeup(); // wake up again to trigger thread death
+                	ch.disconnect();
                     ch.close();
                 }
             }

Modified: directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
URL: http://svn.apache.org/viewcvs/directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java?rev=359356&r1=359355&r2=359356&view=diff
==============================================================================
--- directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
(original)
+++ directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
Tue Dec 27 18:49:40 2005
@@ -50,6 +50,11 @@
     private final IoConnector wrapper;
     private final int id = nextId ++ ;
     private Selector selector;
+    private boolean broadcast;
+    private boolean reuseAddress;
+    private int receiveBufferSize = -1;
+    private int sendBufferSize = -1;
+    private int trafficClass = -1;
     private final Queue registerQueue = new Queue();
     private final Queue cancelQueue = new Queue();
     private final Queue flushingSessions = new Queue();
@@ -97,7 +102,20 @@
         try
         {
             ch = DatagramChannel.open();
-            ch.socket().setReuseAddress( true );
+            ch.socket().setReuseAddress( reuseAddress );
+            ch.socket().setBroadcast( broadcast );
+            if( receiveBufferSize > 0 )
+            {
+            	ch.socket().setReceiveBufferSize( receiveBufferSize );
+            }
+            if( sendBufferSize > 0 )
+            {
+            	ch.socket().setSendBufferSize( sendBufferSize );
+            }
+            if( trafficClass > 0 )
+            {
+            	ch.socket().setTrafficClass( trafficClass );
+            }
             if( localAddress != null )
             {
                 ch.socket().bind( localAddress );
@@ -116,6 +134,7 @@
             {
                 try
                 {
+                	ch.disconnect();
                     ch.close();
                 }
                 catch( IOException e )
@@ -136,6 +155,7 @@
             {
                 try
                 {
+                	ch.disconnect();
                     ch.close();
                 }
                 catch( IOException e2 )
@@ -156,7 +176,57 @@
         return request;
     }
     
-    private synchronized void startupWorker() throws IOException
+    public boolean getBroadcast()
+    {
+    	return broadcast;
+    }
+    
+    public void setBroadcast( boolean broadcast )
+    {
+    	this.broadcast = broadcast;
+    }
+    
+    public boolean getReuseAddress()
+    {
+    	return reuseAddress;
+    }
+    
+    public void setReuseAddress( boolean reuseAddress )
+    {
+    	this.reuseAddress = reuseAddress;
+    }
+
+	public int getReceiveBufferSize()
+	{
+		return receiveBufferSize;
+	}
+
+	public void setReceiveBufferSize( int receiveBufferSize )
+	{
+		this.receiveBufferSize = receiveBufferSize;
+	}
+
+	public int getSendBufferSize()
+	{
+		return sendBufferSize;
+	}
+
+	public void setSendBufferSize( int sendBufferSize )
+	{
+		this.sendBufferSize = sendBufferSize;
+	}
+
+	public int getTrafficClass()
+	{
+		return trafficClass;
+	}
+
+	public void setTrafficClass( int trafficClass )
+	{
+		this.trafficClass = trafficClass;
+	}
+
+	private synchronized void startupWorker() throws IOException
     {
         if( worker == null )
         {
@@ -540,6 +610,7 @@
                 {
                     try
                     {
+                    	req.channel.disconnect();
                         req.channel.close();
                     }
                     catch (IOException e)
@@ -572,6 +643,7 @@
                 DatagramChannel ch = ( DatagramChannel ) key.channel();
                 try
                 {
+                	ch.disconnect();
                     ch.close();
                 }
                 catch( IOException e )

Modified: directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramFilterChain.java?rev=359356&r1=359355&r2=359356&view=diff
==============================================================================
--- directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramFilterChain.java
(original)
+++ directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramFilterChain.java
Tue Dec 27 18:49:40 2005
@@ -1,3 +1,21 @@
+/*
+ *   @(#) $Id: DatagramConnectorDelegate.java 351888 2005-12-03 04:39:53Z trustin $
+ *
+ *   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.support;
 
 import org.apache.mina.common.CloseFuture;

Modified: directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
URL: http://svn.apache.org/viewcvs/directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java?rev=359356&r1=359355&r2=359356&view=diff
==============================================================================
--- directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
(original)
+++ directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
Tue Dec 27 18:49:40 2005
@@ -171,4 +171,33 @@
     {
         managerDelegate.updateTrafficMask( this );
     }
+
+	public int getReceiveBufferSize() throws SocketException {
+		return ch.socket().getReceiveBufferSize();
+	}
+
+	public void setReceiveBufferSize( int receiveBufferSize ) throws SocketException
+	{
+		ch.socket().setReceiveBufferSize( receiveBufferSize );
+	}
+
+	public boolean getBroadcast() throws SocketException
+	{
+		return ch.socket().getBroadcast();
+	}
+
+	public void setBroadcast( boolean broadcast ) throws SocketException
+	{
+		ch.socket().setBroadcast( broadcast );
+	}
+
+	public int getSendBufferSize() throws SocketException
+	{
+		return ch.socket().getSendBufferSize();
+	}
+
+	public void setSendBufferSize( int sendBufferSize ) throws SocketException
+	{
+		ch.socket().setSendBufferSize( sendBufferSize );
+	}
 }

Modified: directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionManager.java
URL: http://svn.apache.org/viewcvs/directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionManager.java?rev=359356&r1=359355&r2=359356&view=diff
==============================================================================
--- directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionManager.java
(original)
+++ directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionManager.java
Tue Dec 27 18:49:40 2005
@@ -18,7 +18,6 @@
  */
 package org.apache.mina.transport.socket.nio.support;
 
-import org.apache.mina.common.IoSessionManager;
 
 /**
  * A base interface for {@link DatagramAcceptorDelegate} and {@link DatagramConnectorDelegate}.
@@ -26,7 +25,7 @@
  * @author The Apache Directory Project (dev@directory.apache.org)
  * @version $Rev$, $Date$
  */
-interface DatagramSessionManager extends IoSessionManager
+interface DatagramSessionManager extends org.apache.mina.transport.socket.nio.DatagramSessionManager
 {
     /**
      * Requests this processor to flush the write buffer of the specified

Modified: directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java
URL: http://svn.apache.org/viewcvs/directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java?rev=359356&r1=359355&r2=359356&view=diff
==============================================================================
--- directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java
(original)
+++ directory/trunk/mina-core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java
Tue Dec 27 18:49:40 2005
@@ -203,16 +203,6 @@
         }
     }
     
-    public int getProcessors()
-    {
-        throw new UnsupportedOperationException();
-    }
-
-    public void setProcessors( int nProcessor )
-    {
-        throw new UnsupportedOperationException();
-    }
-
     private class Worker extends Thread
     {
         public Worker()

Modified: directory/trunk/mina-core/src/test/java/org/apache/mina/transport/socket/nio/AbstractBindTest.java
URL: http://svn.apache.org/viewcvs/directory/trunk/mina-core/src/test/java/org/apache/mina/transport/socket/nio/AbstractBindTest.java?rev=359356&r1=359355&r2=359356&view=diff
==============================================================================
--- directory/trunk/mina-core/src/test/java/org/apache/mina/transport/socket/nio/AbstractBindTest.java
(original)
+++ directory/trunk/mina-core/src/test/java/org/apache/mina/transport/socket/nio/AbstractBindTest.java
Tue Dec 27 18:49:40 2005
@@ -50,9 +50,11 @@
         this.acceptor = acceptor;
     }
     
-    public void setUp() throws IOException
-    {
-        // Find an availble test port and bind to it.
+	private void bind( boolean reuseAddress ) throws IOException
+	{
+		setReuseAddress( reuseAddress );
+
+    	// Find an availble test port and bind to it.
         boolean socketBound = false;
 
         // Let's start from port #1 to detect possible resource leak
@@ -80,7 +82,19 @@
         }
 
         //System.out.println( "Using port " + port + " for testing." );
-    }
+	}
+
+	private void setReuseAddress( boolean reuseAddress )
+	{
+		if( acceptor instanceof DatagramAcceptor )
+		{
+			( ( DatagramAcceptor ) acceptor ).setReuseAddress( reuseAddress );
+		}
+		else if( acceptor instanceof SocketAcceptor )
+		{
+			( ( SocketAcceptor ) acceptor ).setReuseAddress( reuseAddress );
+		}
+	}
     
     public void tearDown()
     {
@@ -94,8 +108,10 @@
         }
     }
     
-    public void testDuplicateBind()
+    public void testDuplicateBind() throws IOException
     {
+    	bind( false );
+    	
         try
         {
             acceptor.bind( new InetSocketAddress( port ), new EchoProtocolHandler() );
@@ -106,8 +122,10 @@
         }
     }
 
-    public void testDuplicateUnbind()
+    public void testDuplicateUnbind() throws IOException
     {
+    	bind( false );
+    	
         // this should succeed
         acceptor.unbind( new InetSocketAddress( port ) );
         
@@ -124,6 +142,8 @@
     
     public void testManyTimes() throws IOException
     {
+    	bind( true );
+    	
         InetSocketAddress addr = new InetSocketAddress( port );
         EchoProtocolHandler handler = new EchoProtocolHandler();
         for( int i = 0; i < 1024; i++ ) 
@@ -135,7 +155,7 @@
     
     public void _testRegressively() throws IOException
     {
-        tearDown();
+    	setReuseAddress( true );
 
         InetSocketAddress addr = new InetSocketAddress( port );
         EchoProtocolHandler handler = new EchoProtocolHandler();
@@ -149,7 +169,7 @@
                 System.out.println( i + " (" + new Date() + ")" );
             }
         }
-        setUp();
+        bind( false );
     }
 
     



Mime
View raw message