directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r372449 [2/2] - in /directory/sandbox/trustin/dirmina-158/core/src: main/java/org/apache/mina/common/ main/java/org/apache/mina/common/support/ main/java/org/apache/mina/registry/ main/java/org/apache/mina/transport/socket/nio/ main/java/or...
Date Thu, 26 Jan 2006 05:26:05 GMT
Modified: directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java Wed Jan 25 21:24:58 2006
@@ -31,10 +31,13 @@
 import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.ExceptionMonitor;
 import org.apache.mina.common.IoConnector;
-import org.apache.mina.common.IoFilterChainBuilder;
+import org.apache.mina.common.IoConnectorConfig;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.common.support.BaseIoConnector;
+import org.apache.mina.transport.socket.nio.DatagramConnectorConfig;
+import org.apache.mina.transport.socket.nio.DatagramSessionConfig;
 import org.apache.mina.util.Queue;
 
 /**
@@ -50,11 +53,7 @@
     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 DatagramConnectorConfig defaultConfig = new DatagramConnectorConfig();
     private final Queue registerQueue = new Queue();
     private final Queue cancelQueue = new Queue();
     private final Queue flushingSessions = new Queue();
@@ -69,13 +68,13 @@
         this.wrapper = wrapper;
     }
 
-    public ConnectFuture connect( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder )
+    public ConnectFuture connect( SocketAddress address, IoHandler handler, IoConnectorConfig config )
     {
-        return connect( address, null, handler, filterChainBuilder );
+        return connect( address, null, handler, config );
     }
 
     public ConnectFuture connect( SocketAddress address, SocketAddress localAddress,
-                                  IoHandler handler, IoFilterChainBuilder filterChainBuilder )
+                                  IoHandler handler, IoConnectorConfig config )
     {
         if( address == null )
             throw new NullPointerException( "address" );
@@ -92,9 +91,9 @@
                                                 + localAddress.getClass() );
         }
         
-        if( filterChainBuilder == null )
+        if( config == null )
         {
-            filterChainBuilder = IoFilterChainBuilder.NOOP;
+            config = ( IoConnectorConfig ) getDefaultConfig();
         }
         
         DatagramChannel ch = null;
@@ -102,20 +101,22 @@
         try
         {
             ch = DatagramChannel.open();
-            ch.socket().setReuseAddress( reuseAddress );
-            ch.socket().setBroadcast( broadcast );
-            if( receiveBufferSize > 0 )
+            DatagramSessionConfig cfg;
+            if( config.getSessionConfig() instanceof DatagramSessionConfig )
             {
-                ch.socket().setReceiveBufferSize( receiveBufferSize );
+                cfg = ( DatagramSessionConfig ) config.getSessionConfig();
             }
-            if( sendBufferSize > 0 )
-            {
-                ch.socket().setSendBufferSize( sendBufferSize );
-            }
-            if( trafficClass > 0 )
+            else
             {
-                ch.socket().setTrafficClass( trafficClass );
+                cfg = ( DatagramSessionConfig ) getDefaultConfig().getSessionConfig();
             }
+            
+            ch.socket().setReuseAddress( cfg.isReuseAddress() );
+            ch.socket().setBroadcast( cfg.isBroadcast() );
+            ch.socket().setReceiveBufferSize( cfg.getReceiveBufferSize() );
+            ch.socket().setSendBufferSize( cfg.getSendBufferSize() );
+            ch.socket().setTrafficClass( cfg.getTrafficClass() );
+
             if( localAddress != null )
             {
                 ch.socket().bind( localAddress );
@@ -144,7 +145,7 @@
             }
         }
 
-        RegistrationRequest request = new RegistrationRequest( ch, handler, filterChainBuilder );
+        RegistrationRequest request = new RegistrationRequest( ch, handler, config );
         synchronized( this )
         {
             try
@@ -176,54 +177,9 @@
         return request;
     }
     
-    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 )
+    public IoServiceConfig getDefaultConfig()
     {
-        this.trafficClass = trafficClass;
+        return defaultConfig;
     }
 
     private synchronized void startupWorker() throws IOException
@@ -443,7 +399,7 @@
     private void readSession( DatagramSessionImpl session )
     {
 
-        ByteBuffer readBuf = ByteBuffer.allocate( 2048 );
+        ByteBuffer readBuf = ByteBuffer.allocate( session.getReadBufferSize() );
         try
         {
             int readBytes = session.getChannel().read( readBuf.buf() );
@@ -582,14 +538,15 @@
             if( req == null )
                 break;
 
-            DatagramSessionImpl session =
-                new DatagramSessionImpl( wrapper, this, req.channel, req.handler );
+            DatagramSessionImpl session = new DatagramSessionImpl(
+                    wrapper, this,
+                    ( DatagramSessionConfig ) req.config.getSessionConfig(),
+                    req.channel, req.handler );
 
             boolean success = false;
             try
             {
-                this.filterChainBuilder.buildFilterChain( session.getFilterChain() );
-                req.filterChainBuilder.buildFilterChain( session.getFilterChain() );
+                req.config.getFilterChainBuilder().buildFilterChain( session.getFilterChain() );
                 ( ( DatagramFilterChain ) session.getFilterChain() ).sessionCreated( session );
 
                 SelectionKey key = req.channel.register( selector,
@@ -661,15 +618,15 @@
     {
         private final DatagramChannel channel;
         private final IoHandler handler;
-        private final IoFilterChainBuilder filterChainBuilder;
+        private final IoConnectorConfig config;
 
         private RegistrationRequest( DatagramChannel channel,
                                      IoHandler handler,
-                                     IoFilterChainBuilder filterChainBuilder )
+                                     IoConnectorConfig config )
         {
             this.channel = channel;
             this.handler = handler;
-            this.filterChainBuilder = filterChainBuilder;
+            this.config = config;
         }
     }
 }

Modified: directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramService.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramService.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramService.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramService.java Wed Jan 25 21:24:58 2006
@@ -25,7 +25,7 @@
  * @author The Apache Directory Project (dev@directory.apache.org)
  * @version $Rev$, $Date$
  */
-interface DatagramService extends org.apache.mina.transport.socket.nio.DatagramService
+interface DatagramService
 {
     /**
      * Requests this processor to flush the write buffer of the specified

Added: directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionConfigImpl.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionConfigImpl.java?rev=372449&view=auto
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionConfigImpl.java (added)
+++ directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionConfigImpl.java Wed Jan 25 21:24:58 2006
@@ -0,0 +1,129 @@
+/*
+ * @(#) $Id$
+ */
+package org.apache.mina.transport.socket.nio.support;
+
+import java.net.DatagramSocket;
+import java.net.SocketException;
+
+import org.apache.mina.common.RuntimeIOException;
+import org.apache.mina.transport.socket.nio.DatagramSessionConfig;
+
+public class DatagramSessionConfigImpl implements DatagramSessionConfig
+{
+    private boolean broadcast;
+    private boolean reuseAddress;
+    private int receiveBufferSize;
+    private int sendBufferSize;
+    private int trafficClass;
+
+    /**
+     * Creates a new instance.
+     * 
+     * @throws RuntimeIOException if failed to get the default configuration
+     */
+    public DatagramSessionConfigImpl()
+    {
+        DatagramSocket s = null;
+        try
+        {
+            s = new DatagramSocket();
+            broadcast = s.getBroadcast();
+            reuseAddress = s.getReuseAddress();
+            receiveBufferSize = s.getReceiveBufferSize();
+            sendBufferSize = s.getSendBufferSize();
+            trafficClass = s.getTrafficClass();
+        }
+        catch( SocketException e )
+        {
+            throw new RuntimeIOException( "Failed to get the default configuration.", e );
+        }
+        finally
+        {
+            if( s != null )
+            {
+                s.close();
+            }
+        }
+    }
+
+    /**
+     * @see DatagramSocket#getBroadcast()
+     */
+    public boolean isBroadcast()
+    {
+        return broadcast;
+    }
+    
+    /**
+     * @see DatagramSocket#setBroadcast(boolean)
+     */
+    public void setBroadcast( boolean broadcast )
+    {
+        this.broadcast = broadcast;
+    }
+    
+    /**
+     * @see DatagramSocket#getReuseAddress()
+     */
+    public boolean isReuseAddress()
+    {
+        return reuseAddress;
+    }
+    
+    /**
+     * @see DatagramSocket#setReuseAddress(boolean)
+     */
+    public void setReuseAddress( boolean reuseAddress )
+    {
+        this.reuseAddress = reuseAddress;
+    }
+
+    /**
+     * @see DatagramSocket#getReceiveBufferSize()
+     */
+    public int getReceiveBufferSize()
+    {
+        return receiveBufferSize;
+    }
+
+    /**
+     * @see DatagramSocket#setReceiveBufferSize(int)
+     */
+    public void setReceiveBufferSize( int receiveBufferSize )
+    {
+        this.receiveBufferSize = receiveBufferSize;
+    }
+
+    /**
+     * @see DatagramSocket#getSendBufferSize()
+     */
+    public int getSendBufferSize()
+    {
+        return sendBufferSize;
+    }
+
+    /**
+     * @see DatagramSocket#setSendBufferSize(int)
+     */
+    public void setSendBufferSize( int sendBufferSize )
+    {
+        this.sendBufferSize = sendBufferSize;
+    }
+
+    /**
+     * @see DatagramSocket#getTrafficClass()
+     */
+    public int getTrafficClass()
+    {
+        return trafficClass;
+    }
+
+    /**
+     * @see DatagramSocket#setTrafficClass(int)
+     */
+    public void setTrafficClass( int trafficClass )
+    {
+        this.trafficClass = trafficClass;
+    }
+}
\ No newline at end of file

Propchange: directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionConfigImpl.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Modified: directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java Wed Jan 25 21:24:58 2006
@@ -26,12 +26,14 @@
 import org.apache.mina.common.CloseFuture;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoService;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.common.IoSessionConfig;
+import org.apache.mina.common.RuntimeIOException;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.common.support.BaseIoSession;
-import org.apache.mina.transport.socket.nio.DatagramSession;
+import org.apache.mina.transport.socket.nio.DatagramSessionConfig;
 import org.apache.mina.util.Queue;
 
 /**
@@ -40,9 +42,10 @@
  * @author The Apache Directory Project (dev@directory.apache.org)
  * @version $Rev$, $Date$
  */
-class DatagramSessionImpl extends BaseIoSession implements DatagramSession
+class DatagramSessionImpl extends BaseIoSession
 {
     private final IoService wrapperManager;
+    private final DatagramSessionConfig config = new DatagramSessionConfigImpl();
     private final DatagramService managerDelegate;
     private final DatagramFilterChain filterChain;
     private final DatagramChannel ch;
@@ -51,12 +54,14 @@
     private final SocketAddress localAddress;
     private SocketAddress remoteAddress;
     private SelectionKey key;
+    private int readBufferSize;
 
     /**
      * Creates a new instance.
      */
     DatagramSessionImpl( IoService wrapperManager,
                          DatagramService managerDelegate,
+                         DatagramSessionConfig config,
                          DatagramChannel ch, IoHandler defaultHandler )
     {
         this.wrapperManager = wrapperManager;
@@ -67,6 +72,14 @@
         this.handler = defaultHandler;
         this.remoteAddress = ch.socket().getRemoteSocketAddress();
         this.localAddress = ch.socket().getLocalSocketAddress();
+        
+        // Apply the initial session settings
+        this.config.setBroadcast( config.isBroadcast() );
+        this.config.setReceiveBufferSize( config.getReceiveBufferSize() );
+        this.readBufferSize = config.getReceiveBufferSize();
+        this.config.setReuseAddress( config.isReuseAddress() );
+        this.config.setSendBufferSize( config.getSendBufferSize() );
+        this.config.setTrafficClass( config.getTrafficClass() );
     }
     
     public IoService getService()
@@ -74,6 +87,11 @@
         return wrapperManager;
     }
     
+    public IoSessionConfig getConfig()
+    {
+        return config;
+    }
+    
     DatagramService getManagerDelegate()
     {
         return managerDelegate;
@@ -147,57 +165,137 @@
         return localAddress;
     }
 
-    public boolean getReuseAddress() throws SocketException
+    protected void updateTrafficMask()
     {
-        return ch.socket().getReuseAddress();
+        managerDelegate.updateTrafficMask( this );
     }
-
-    public void setReuseAddress( boolean on ) throws SocketException
+    
+    int getReadBufferSize()
     {
-        ch.socket().setReuseAddress( on );
+        return readBufferSize;
     }
-
-    public int getTrafficClass() throws SocketException
+    
+    private class DatagramSessionConfigImpl implements DatagramSessionConfig
     {
-        return ch.socket().getTrafficClass();
-    }
+        public int getReceiveBufferSize()
+        {
+            try
+            {
+                return ch.socket().getReceiveBufferSize();
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
 
-    public void setTrafficClass( int tc ) throws SocketException
-    {
-        ch.socket().setTrafficClass( tc );
-    }
+        public void setReceiveBufferSize( int receiveBufferSize )
+        {
+            try
+            {
+                ch.socket().setReceiveBufferSize( receiveBufferSize );
+                DatagramSessionImpl.this.readBufferSize = receiveBufferSize;
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
 
-    protected void updateTrafficMask()
-    {
-        managerDelegate.updateTrafficMask( this );
-    }
+        public boolean isBroadcast()
+        {
+            try
+            {
+                return ch.socket().getBroadcast();
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
 
-    public int getReceiveBufferSize() throws SocketException {
-        return ch.socket().getReceiveBufferSize();
-    }
+        public void setBroadcast( boolean broadcast )
+        {
+            try
+            {
+                ch.socket().setBroadcast( broadcast );
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
 
-    public void setReceiveBufferSize( int receiveBufferSize ) throws SocketException
-    {
-        ch.socket().setReceiveBufferSize( receiveBufferSize );
-    }
+        public int getSendBufferSize()
+        {
+            try
+            {
+                return ch.socket().getSendBufferSize();
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
 
-    public boolean getBroadcast() throws SocketException
-    {
-        return ch.socket().getBroadcast();
-    }
+        public void setSendBufferSize( int sendBufferSize )
+        {
+            try
+            {
+                ch.socket().setSendBufferSize( sendBufferSize );
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
 
-    public void setBroadcast( boolean broadcast ) throws SocketException
-    {
-        ch.socket().setBroadcast( broadcast );
-    }
+        public boolean isReuseAddress()
+        {
+            try
+            {
+                return ch.socket().getReuseAddress();
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
 
-    public int getSendBufferSize() throws SocketException
-    {
-        return ch.socket().getSendBufferSize();
-    }
+        public void setReuseAddress( boolean reuseAddress )
+        {
+            try
+            {
+                ch.socket().setReuseAddress( reuseAddress );
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
 
-    public void setSendBufferSize( int sendBufferSize ) throws SocketException
-    {
-        ch.socket().setSendBufferSize( sendBufferSize );
+        public int getTrafficClass()
+        {
+            try
+            {
+                return ch.socket().getTrafficClass();
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
+
+        public void setTrafficClass( int trafficClass )
+        {
+            try
+            {
+                ch.socket().setTrafficClass( trafficClass );
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
     }
 }

Modified: directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java Wed Jan 25 21:24:58 2006
@@ -26,7 +26,6 @@
 import java.nio.channels.ServerSocketChannel;
 import java.nio.channels.SocketChannel;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -37,11 +36,15 @@
 
 import org.apache.mina.common.ExceptionMonitor;
 import org.apache.mina.common.IoAcceptor;
-import org.apache.mina.common.IoFilterChainBuilder;
+import org.apache.mina.common.IoAcceptorConfig;
 import org.apache.mina.common.IoFuture;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.support.BaseIoAcceptor;
+import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
+import org.apache.mina.transport.socket.nio.SocketSessionConfig;
+import org.apache.mina.util.IdentityHashSet;
 import org.apache.mina.util.Queue;
 
 /**
@@ -57,9 +60,7 @@
     private final IoAcceptor wrapper;
     private final int id = nextId ++ ;
     private final String threadName = "SocketAcceptor-" + id;
-    private boolean reuseAddress = false;
-    private int backlog = 50;
-    private int receiveBufferSize = -1;
+    private final IoServiceConfig defaultConfig = new SocketAcceptorConfig();
     private Selector selector;
     private final Map channels = new HashMap();
     private final Hashtable sessions = new Hashtable();
@@ -84,7 +85,7 @@
      *
      * @throws IOException if failed to bind
      */
-    public void bind( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder ) throws IOException
+    public void bind( SocketAddress address, IoHandler handler, IoAcceptorConfig config ) throws IOException
     {
         if( address == null )
         {
@@ -106,12 +107,12 @@
             throw new IllegalArgumentException( "Unsupported port number: 0" );
         }
         
-        if( filterChainBuilder == null )
+        if( config == null )
         {
-            filterChainBuilder = IoFilterChainBuilder.NOOP;
+            config = ( IoAcceptorConfig ) getDefaultConfig();
         }
         
-        RegistrationRequest request = new RegistrationRequest( address, handler, filterChainBuilder );
+        RegistrationRequest request = new RegistrationRequest( address, handler, config );
 
         synchronized( this )
         {
@@ -156,7 +157,7 @@
         }
     }
 
-    public Collection getManagedSessions( SocketAddress address )
+    public Set getManagedSessions( SocketAddress address )
     {
         if( address == null )
         {
@@ -170,7 +171,8 @@
             throw new IllegalArgumentException( "Address not bound: " + address );
         }
         
-        return Collections.unmodifiableCollection( Arrays.asList( managedSessions.toArray() ) );
+        return Collections.unmodifiableSet(
+                new IdentityHashSet( Arrays.asList( managedSessions.toArray() ) ) );
     }
     
     public void unbind( SocketAddress address )
@@ -228,7 +230,8 @@
         
         
         // Disconnect all clients
-        if( isDisconnectClientsOnUnbind() && managedSessions != null )
+        if( request.registrationRequest.config.isDisconnectOnUnbind() &&
+            managedSessions != null )
         {
             IoSession[] tempSessions = ( IoSession[] ) 
                                   managedSessions.toArray( new IoSession[ 0 ] );
@@ -365,10 +368,12 @@
                 try
                 {
                     RegistrationRequest req = ( RegistrationRequest ) key.attachment();
-                    session = new SocketSessionImpl( SocketAcceptorDelegate.this.wrapper, 
-                            ( Set ) sessions.get( req.address ), ch, req.handler );
-                    SocketAcceptorDelegate.this.filterChainBuilder.buildFilterChain( session.getFilterChain() );
-                    req.filterChainBuilder.buildFilterChain( session.getFilterChain() );
+                    session = new SocketSessionImpl(
+                            SocketAcceptorDelegate.this.wrapper,
+                            ( Set ) sessions.get( req.address ),
+                            ( SocketSessionConfig ) req.config.getSessionConfig(),
+                            ch, req.handler );
+                    req.config.getFilterChainBuilder().buildFilterChain( session.getFilterChain() );
                     ( ( SocketFilterChain ) session.getFilterChain() ).sessionCreated( session );
                     session.getManagedSessions().add( session );
                     session.getIoProcessor().addNew( session );
@@ -393,6 +398,10 @@
         }
     }
 
+    public IoServiceConfig getDefaultConfig()
+    {
+        return defaultConfig;
+    }
 
     private void registerNew()
     {
@@ -423,14 +432,22 @@
                 ssc.configureBlocking( false );
                 
                 // Configure the server socket,
-                ssc.socket().setReuseAddress( isReuseAddress() );
-                if( getReceiveBufferSize() > 0 )
+                SocketAcceptorConfig cfg;
+                if( req.config instanceof SocketAcceptorConfig )
+                {
+                    cfg = ( SocketAcceptorConfig ) req.config;
+                }
+                else
                 {
-                    ssc.socket().setReceiveBufferSize( getReceiveBufferSize() );
+                    cfg = ( SocketAcceptorConfig ) getDefaultConfig();
                 }
                 
+                ssc.socket().setReuseAddress( cfg.isReuseAddress() );
+                ssc.socket().setReceiveBufferSize(
+                        ( ( SocketSessionConfig ) cfg.getSessionConfig() ).getReceiveBufferSize() );
+                
                 // and bind.
-                ssc.socket().bind( req.address, getBacklog() );
+                ssc.socket().bind( req.address, cfg.getBacklog() );
                 ssc.register( selector, SelectionKey.OP_ACCEPT, req );
 
                 channels.put( req.address, ssc );
@@ -499,7 +516,7 @@
                 else
                 {
                     SelectionKey key = ssc.keyFor( selector );
-
+                    request.registrationRequest = ( RegistrationRequest ) key.attachment();
                     key.cancel();
 
                     selector.wakeup(); // wake up again to trigger thread death
@@ -516,63 +533,25 @@
                 synchronized( request )
                 {
                     request.done = true;
-
                     request.notify();
                 }
             }
         }
     }
 
-    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;
-    }
-
     private static class RegistrationRequest
     {
         private final SocketAddress address;
         private final IoHandler handler;
-        private final IoFilterChainBuilder filterChainBuilder;
+        private final IoAcceptorConfig config;
         private IOException exception;
         private boolean done;
         
-        private RegistrationRequest( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder )
+        private RegistrationRequest( SocketAddress address, IoHandler handler, IoAcceptorConfig config )
         {
             this.address = address;
             this.handler = handler;
-            this.filterChainBuilder = filterChainBuilder;
+            this.config = config;
         }
     }
 
@@ -580,9 +559,8 @@
     private static class CancellationRequest
     {
         private final SocketAddress address;
-
         private boolean done;
-
+        private RegistrationRequest registrationRequest;
         private RuntimeException exception;
         
         private CancellationRequest( SocketAddress address )

Modified: directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketConnectorDelegate.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketConnectorDelegate.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketConnectorDelegate.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketConnectorDelegate.java Wed Jan 25 21:24:58 2006
@@ -33,9 +33,12 @@
 import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.ExceptionMonitor;
 import org.apache.mina.common.IoConnector;
-import org.apache.mina.common.IoFilterChainBuilder;
+import org.apache.mina.common.IoConnectorConfig;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.common.support.BaseIoConnector;
+import org.apache.mina.transport.socket.nio.SocketConnectorConfig;
+import org.apache.mina.transport.socket.nio.SocketSessionConfig;
 import org.apache.mina.util.Queue;
 
 /**
@@ -51,6 +54,7 @@
     private final IoConnector wrapper;
     private final int id = nextId++;
     private final String threadName = "SocketConnector-" + id;
+    private final IoServiceConfig defaultConfig = new SocketConnectorConfig();
     private Selector selector;
     private final Queue connectQueue = new Queue();
     private final Set managedSessions = Collections.synchronizedSet( new HashSet() );
@@ -64,13 +68,13 @@
         this.wrapper = wrapper;
     }
 
-    public ConnectFuture connect( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder )
+    public ConnectFuture connect( SocketAddress address, IoHandler handler, IoConnectorConfig config )
     {
-        return connect( address, null, handler, filterChainBuilder );
+        return connect( address, null, handler, config );
     }
 
     public ConnectFuture connect( SocketAddress address, SocketAddress localAddress,
-                                  IoHandler handler, IoFilterChainBuilder filterChainBuilder )
+                                  IoHandler handler, IoConnectorConfig config )
     {
         if( address == null )
             throw new NullPointerException( "address" );
@@ -85,9 +89,9 @@
             throw new IllegalArgumentException( "Unexpected local address type: "
                                                 + localAddress.getClass() );
 
-        if( filterChainBuilder == null )
+        if( config == null )
         {
-            filterChainBuilder = IoFilterChainBuilder.NOOP;
+            config = ( IoConnectorConfig ) getDefaultConfig();
         }
         
         SocketChannel ch = null;
@@ -105,7 +109,7 @@
 
             if( ch.connect( address ) )
             {
-                SocketSessionImpl session = newSession( ch, handler, filterChainBuilder );
+                SocketSessionImpl session = newSession( ch, handler, config );
                 success = true;
                 ConnectFuture future = new ConnectFuture();
                 future.setSession( session );
@@ -133,7 +137,7 @@
             }
         }
         
-        ConnectionRequest request = new ConnectionRequest( ch, getConnectTimeout(), handler, filterChainBuilder );
+        ConnectionRequest request = new ConnectionRequest( ch, handler, config );
         synchronized( this )
         {
             try
@@ -163,6 +167,11 @@
         return request;
     }
     
+    public IoServiceConfig getDefaultConfig()
+    {
+        return defaultConfig;
+    }
+    
     private synchronized void startupWorker() throws IOException
     {
         if( worker == null )
@@ -219,7 +228,7 @@
             try
             {
                 ch.finishConnect();
-                SocketSessionImpl session = newSession( ch, entry.handler, entry.filterChainBuilder );
+                SocketSessionImpl session = newSession( ch, entry.handler, entry.config );
                 entry.setSession( session );
                 success = true;
             }
@@ -269,13 +278,15 @@
         }
     }
 
-    private SocketSessionImpl newSession( SocketChannel ch, IoHandler handler, IoFilterChainBuilder filterChainBuilder ) throws IOException
+    private SocketSessionImpl newSession( SocketChannel ch, IoHandler handler, IoConnectorConfig config ) throws IOException
     {
-        SocketSessionImpl session = new SocketSessionImpl( wrapper, managedSessions, ch, handler );
+        SocketSessionImpl session = new SocketSessionImpl(
+                wrapper, managedSessions,
+                ( SocketSessionConfig ) config.getSessionConfig(),
+                ch, handler );
         try
         {
-            this.filterChainBuilder.buildFilterChain( session.getFilterChain() );
-            filterChainBuilder.buildFilterChain( session.getFilterChain() );
+            config.getFilterChainBuilder().buildFilterChain( session.getFilterChain() );
             ( ( SocketFilterChain ) session.getFilterChain() ).sessionCreated( session );
         }
         catch( Throwable e )
@@ -357,14 +368,14 @@
         private final SocketChannel channel;
         private final long deadline;
         private final IoHandler handler;
-        private final IoFilterChainBuilder filterChainBuilder;
+        private final IoConnectorConfig config;
 
-        private ConnectionRequest( SocketChannel channel, int timeout, IoHandler handler, IoFilterChainBuilder filterChainBuilder )
+        private ConnectionRequest( SocketChannel channel, IoHandler handler, IoConnectorConfig config )
         {
             this.channel = channel;
-            this.deadline = System.currentTimeMillis() + timeout * 1000L;
+            this.deadline = System.currentTimeMillis() + config.getConnectTimeoutMillis();
             this.handler = handler;
-            this.filterChainBuilder = filterChainBuilder;
+            this.config = config;
         }
     }
 }

Modified: directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketIoProcessor.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketIoProcessor.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketIoProcessor.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketIoProcessor.java Wed Jan 25 21:24:58 2006
@@ -278,7 +278,7 @@
 
     private void read( SocketSessionImpl session )
     {
-        ByteBuffer buf = ByteBuffer.allocate( session.getSessionReceiveBufferSize() ); 
+        ByteBuffer buf = ByteBuffer.allocate( session.getReadBufferSize() ); 
         SocketChannel ch = session.getChannel();
 
         try

Added: directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketSessionConfigImpl.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketSessionConfigImpl.java?rev=372449&view=auto
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketSessionConfigImpl.java (added)
+++ directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketSessionConfigImpl.java Wed Jan 25 21:24:58 2006
@@ -0,0 +1,167 @@
+/*
+ *   @(#) $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.support;
+
+import java.io.IOException;
+import java.net.Socket;
+import java.net.SocketException;
+
+import org.apache.mina.common.ExceptionMonitor;
+import org.apache.mina.common.IoConnectorConfig;
+import org.apache.mina.common.RuntimeIOException;
+import org.apache.mina.transport.socket.nio.SocketConnector;
+import org.apache.mina.transport.socket.nio.SocketSessionConfig;
+
+/**
+ * An {@link IoConnectorConfig} for {@link SocketConnector}.
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class SocketSessionConfigImpl implements SocketSessionConfig
+{
+    private boolean reuseAddress;
+    private int receiveBufferSize;
+    private int sendBufferSize;
+    private int trafficClass;
+    private boolean keepAlive;
+    private boolean oobInline;
+    private int soLinger;
+    private boolean tcpNoDelay;
+
+    /**
+     * Creates a new instance.
+     * 
+     * @throws RuntimeIOException if failed to get the default configuration
+     */
+    public SocketSessionConfigImpl()
+    {
+        Socket s = null;
+        try
+        {
+            s = new Socket();
+            reuseAddress = s.getReuseAddress();
+            receiveBufferSize = s.getReceiveBufferSize();
+            sendBufferSize = s.getSendBufferSize();
+            trafficClass = s.getTrafficClass();
+            keepAlive = s.getKeepAlive();
+            oobInline = s.getOOBInline();
+            soLinger = s.getSoLinger();
+            tcpNoDelay = s.getTcpNoDelay();
+        }
+        catch( SocketException e )
+        {
+            throw new RuntimeIOException( "Failed to get the default configuration.", e );
+        }
+        finally
+        {
+            if( s != null )
+            {
+                try
+                {
+                    s.close();
+                }
+                catch( IOException e )
+                {
+                    ExceptionMonitor.getInstance().exceptionCaught( e );
+                }
+            }
+        }
+    }
+
+    public boolean isReuseAddress()
+    {
+        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;
+    }
+
+    public boolean isKeepAlive()
+    {
+        return keepAlive;
+    }
+
+    public void setKeepAlive( boolean keepAlive )
+    {
+        this.keepAlive = keepAlive;
+    }
+
+    public boolean isOobInline()
+    {
+        return oobInline;
+    }
+
+    public void setOobInline( boolean oobInline )
+    {
+        this.oobInline = oobInline;
+    }
+
+    public int getSoLinger()
+    {
+        return soLinger;
+    }
+
+    public void setSoLinger( int soLinger )
+    {
+        this.soLinger = soLinger;
+    }
+
+    public boolean isTcpNoDelay()
+    {
+        return tcpNoDelay;
+    }
+
+    public void setTcpNoDelay( boolean tcpNoDelay )
+    {
+        this.tcpNoDelay = tcpNoDelay;
+    }
+}

Propchange: directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketSessionConfigImpl.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Modified: directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java Wed Jan 25 21:24:58 2006
@@ -27,12 +27,14 @@
 import org.apache.mina.common.CloseFuture;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoService;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.common.IoSessionConfig;
+import org.apache.mina.common.RuntimeIOException;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.common.support.BaseIoSession;
-import org.apache.mina.transport.socket.nio.SocketSession;
+import org.apache.mina.transport.socket.nio.SocketSessionConfig;
 import org.apache.mina.util.Queue;
 
 /**
@@ -41,11 +43,10 @@
  * @author The Apache Directory Project (dev@directory.apache.org)
  * @version $Rev$, $Date$
  */
-class SocketSessionImpl extends BaseIoSession implements SocketSession
+class SocketSessionImpl extends BaseIoSession
 {
-    private static final int DEFAULT_READ_BUFFER_SIZE = 1024;
-
     private final IoService manager;
+    private final SocketSessionConfig config = new SocketSessionConfigImpl();
     private final SocketIoProcessor ioProcessor;
     private final SocketFilterChain filterChain;
     private final SocketChannel ch;
@@ -55,13 +56,14 @@
     private final SocketAddress localAddress;
     private final Set managedSessions;    
     private SelectionKey key;
-    private int readBufferSize = DEFAULT_READ_BUFFER_SIZE;
+    private int readBufferSize;
 
     /**
      * Creates a new instance.
      */
     public SocketSessionImpl(
             IoService manager, Set managedSessions,
+            SocketSessionConfig config,
             SocketChannel ch, IoHandler defaultHandler )
     {
         this.manager = manager;
@@ -73,6 +75,17 @@
         this.handler = defaultHandler;
         this.remoteAddress = ch.socket().getRemoteSocketAddress();
         this.localAddress = ch.socket().getLocalSocketAddress();
+        
+        // Apply the initial session settings
+        this.config.setKeepAlive( config.isKeepAlive() );
+        this.config.setOobInline( config.isOobInline() );
+        this.config.setReceiveBufferSize( config.getReceiveBufferSize() );
+        this.readBufferSize = config.getReceiveBufferSize();
+        this.config.setReuseAddress( config.isReuseAddress() );
+        this.config.setSendBufferSize( config.getSendBufferSize() );
+        this.config.setSoLinger( config.getSoLinger() );
+        this.config.setTcpNoDelay( config.isTcpNoDelay() );
+        this.config.setTrafficClass( config.getTrafficClass() );
     }
     
     public IoService getService()
@@ -80,6 +93,11 @@
         return manager;
     }
     
+    public IoSessionConfig getConfig()
+    {
+        return config;
+    }
+    
     SocketIoProcessor getIoProcessor()
     {
         return ioProcessor;
@@ -152,104 +170,217 @@
     {
         return localAddress;
     }
-
-    public boolean getKeepAlive() throws SocketException
-    {
-        return ch.socket().getKeepAlive();
-    }
-
-    public void setKeepAlive( boolean on ) throws SocketException
-    {
-        ch.socket().setKeepAlive( on );
-    }
-
-    public boolean getOOBInline() throws SocketException
-    {
-        return ch.socket().getOOBInline();
-    }
-
-    public void setOOBInline( boolean on ) throws SocketException
-    {
-        ch.socket().setOOBInline( on );
-    }
-
-    public boolean getReuseAddress() throws SocketException
-    {
-        return ch.socket().getReuseAddress();
-    }
-
-    public void setReuseAddress( boolean on ) throws SocketException
-    {
-        ch.socket().setReuseAddress( on );
-    }
-
-    public int getSoLinger() throws SocketException
-    {
-        return ch.socket().getSoLinger();
-    }
-
-    public void setSoLinger( boolean on, int linger ) throws SocketException
-    {
-        ch.socket().setSoLinger( on, linger );
-    }
-
-    public boolean getTcpNoDelay() throws SocketException
-    {
-        return ch.socket().getTcpNoDelay();
-    }
-
-    public void setTcpNoDelay( boolean on ) throws SocketException
-    {
-        ch.socket().setTcpNoDelay( on );
-    }
-
-    public int getTrafficClass() throws SocketException
-    {
-        return ch.socket().getTrafficClass();
-    }
-
-    public void setTrafficClass( int tc ) throws SocketException
-    {
-        ch.socket().setTrafficClass( tc );
-    }
-
-    public int getSendBufferSize() throws SocketException
-    {
-        return ch.socket().getSendBufferSize();
-    }
-
-    public void setSendBufferSize( int size ) throws SocketException
+    
+    protected void updateTrafficMask()
     {
-        ch.socket().setSendBufferSize( size );
+        this.ioProcessor.updateTrafficMask( this );
     }
-
-    public int getReceiveBufferSize() throws SocketException
+    
+    int getReadBufferSize()
     {
-        return ch.socket().getReceiveBufferSize();
+        return readBufferSize;
     }
 
-    public void setReceiveBufferSize( int size ) throws SocketException
+    private class SocketSessionConfigImpl implements SocketSessionConfig
     {
-        ch.socket().setReceiveBufferSize( size );
-    }
+        public boolean isKeepAlive()
+        {
+            try
+            {
+                return ch.socket().getKeepAlive();
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
     
-    public int getSessionReceiveBufferSize()
-    {
-        return readBufferSize;
-    }
+        public void setKeepAlive( boolean on )
+        {
+            try
+            {
+                ch.socket().setKeepAlive( on );
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
     
-    public void setSessionReceiveBufferSize( int size )
-    {
-        if( size <= 0 )
+        public boolean isOobInline()
         {
-            throw new IllegalArgumentException( "Invalid session receive buffer size: " + size );
+            try
+            {
+                return ch.socket().getOOBInline();
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
+    
+        public void setOobInline( boolean on )
+        {
+            try
+            {
+                ch.socket().setOOBInline( on );
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
+    
+        public boolean isReuseAddress()
+        {
+            try
+            {
+                return ch.socket().getReuseAddress();
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
+    
+        public void setReuseAddress( boolean on )
+        {
+            try
+            {
+                ch.socket().setReuseAddress( on );
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
+    
+        public int getSoLinger()
+        {
+            try
+            {
+                return ch.socket().getSoLinger();
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
+    
+        public void setSoLinger( int linger )
+        {
+            try
+            {
+                if( linger < 0 )
+                {
+                    ch.socket().setSoLinger( false, 0 );
+                }
+                else
+                {
+                    ch.socket().setSoLinger( true, linger );
+                }
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
+    
+        public boolean isTcpNoDelay()
+        {
+            try
+            {
+                return ch.socket().getTcpNoDelay();
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
+    
+        public void setTcpNoDelay( boolean on )
+        {
+            try
+            {
+                ch.socket().setTcpNoDelay( on );
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
+    
+        public int getTrafficClass()
+        {
+            try
+            {
+                return ch.socket().getTrafficClass();
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
+    
+        public void setTrafficClass( int tc )
+        {
+            try
+            {
+                ch.socket().setTrafficClass( tc );
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
+    
+        public int getSendBufferSize()
+        {
+            try
+            {
+                return ch.socket().getSendBufferSize();
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
+    
+        public void setSendBufferSize( int size )
+        {
+            try
+            {
+                ch.socket().setSendBufferSize( size );
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
+    
+        public int getReceiveBufferSize()
+        {
+            try
+            {
+                return ch.socket().getReceiveBufferSize();
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
+        }
+    
+        public void setReceiveBufferSize( int size )
+        {
+            try
+            {
+                ch.socket().setReceiveBufferSize( size );
+                SocketSessionImpl.this.readBufferSize = size;
+            }
+            catch( SocketException e )
+            {
+                throw new RuntimeIOException( e );
+            }
         }
-        
-        this.readBufferSize = size;
-    }
-
-    protected void updateTrafficMask()
-    {
-        this.ioProcessor.updateTrafficMask( this );
     }
 }

Modified: directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java Wed Jan 25 21:24:58 2006
@@ -6,18 +6,21 @@
 import java.io.IOException;
 import java.net.SocketAddress;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.mina.common.IoFilterChainBuilder;
+import org.apache.mina.common.IoAcceptorConfig;
 import org.apache.mina.common.IoFuture;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.common.IoSession;
+import org.apache.mina.common.IoSessionConfig;
 import org.apache.mina.common.support.BaseIoAcceptor;
+import org.apache.mina.common.support.BaseIoAcceptorConfig;
 import org.apache.mina.transport.vmpipe.support.VmPipe;
+import org.apache.mina.util.IdentityHashSet;
 
 /**
  * Binds the specified {@link IoHandler} to the specified
@@ -29,8 +32,17 @@
 public class VmPipeAcceptor extends BaseIoAcceptor
 {
     static final Map boundHandlers = new HashMap();
+    
+    private static final IoSessionConfig CONFIG = new IoSessionConfig() {};
+    private final IoServiceConfig defaultConfig = new BaseIoAcceptorConfig()
+    {
+        public IoSessionConfig getSessionConfig()
+        {
+            return CONFIG;
+        }
+    };
 
-    public void bind( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder ) throws IOException
+    public void bind( SocketAddress address, IoHandler handler, IoAcceptorConfig config ) throws IOException
     {
         if( address == null )
             throw new NullPointerException( "address" );
@@ -40,9 +52,9 @@
             throw new IllegalArgumentException(
                     "address must be VmPipeAddress." );
 
-        if( filterChainBuilder == null )
+        if( config == null )
         {
-            filterChainBuilder = IoFilterChainBuilder.NOOP;
+            config = ( IoAcceptorConfig ) getDefaultConfig();
         }
 
         synchronized( boundHandlers )
@@ -55,11 +67,11 @@
             boundHandlers.put( address, 
                                new VmPipe( this,
                                           ( VmPipeAddress ) address,
-                                          handler, filterChainBuilder ) );
+                                          handler, config ) );
         }
     }
 
-    public Collection getManagedSessions( SocketAddress address )
+    public Set getManagedSessions( SocketAddress address )
     {
         if( address == null )
             throw new NullPointerException( "address" );
@@ -75,7 +87,8 @@
         }
         
         Set managedSessions = pipe.getManagedServerSessions();
-        return Collections.unmodifiableCollection( Arrays.asList( managedSessions.toArray() ) );
+        return Collections.unmodifiableSet(
+                new IdentityHashSet( Arrays.asList( managedSessions.toArray() ) ) );
     }
 
     public void unbind( SocketAddress address )
@@ -96,7 +109,7 @@
         
         Set managedSessions = pipe.getManagedServerSessions();
         
-        if( isDisconnectClientsOnUnbind() && managedSessions != null )
+        if( pipe.getConfig().isDisconnectOnUnbind() && managedSessions != null )
         {
             IoSession[] tempSessions = ( IoSession[] ) 
                                   managedSessions.toArray( new IoSession[ 0 ] );
@@ -137,7 +150,11 @@
             {
                 // Ignored
             }
-            
         }                
+    }
+    
+    public IoServiceConfig getDefaultConfig()
+    {
+        return defaultConfig;
     }
 }

Modified: directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java Wed Jan 25 21:24:58 2006
@@ -7,9 +7,12 @@
 import java.net.SocketAddress;
 
 import org.apache.mina.common.ConnectFuture;
-import org.apache.mina.common.IoFilterChainBuilder;
+import org.apache.mina.common.IoConnectorConfig;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoServiceConfig;
+import org.apache.mina.common.IoSessionConfig;
 import org.apache.mina.common.support.BaseIoConnector;
+import org.apache.mina.common.support.BaseIoConnectorConfig;
 import org.apache.mina.transport.vmpipe.support.VmPipe;
 import org.apache.mina.transport.vmpipe.support.VmPipeSessionImpl;
 import org.apache.mina.util.AnonymousSocketAddress;
@@ -23,12 +26,21 @@
  */
 public class VmPipeConnector extends BaseIoConnector
 {
-    public ConnectFuture connect( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder ) 
+    private static final IoSessionConfig CONFIG = new IoSessionConfig() {};
+    private final IoServiceConfig defaultConfig = new BaseIoConnectorConfig()
     {
-        return connect( address, null, handler, filterChainBuilder );
+        public IoSessionConfig getSessionConfig()
+        {
+            return CONFIG;
+        }
+    };
+
+    public ConnectFuture connect( SocketAddress address, IoHandler handler, IoConnectorConfig config ) 
+    {
+        return connect( address, null, handler, config );
     }
 
-    public ConnectFuture connect( SocketAddress address, SocketAddress localAddress, IoHandler handler, IoFilterChainBuilder filterChainBuilder )
+    public ConnectFuture connect( SocketAddress address, SocketAddress localAddress, IoHandler handler, IoConnectorConfig config )
     {
         if( address == null )
             throw new NullPointerException( "address" );
@@ -38,9 +50,9 @@
             throw new IllegalArgumentException(
                                                 "address must be VmPipeAddress." );
 
-        if( filterChainBuilder == null )
+        if( config == null )
         {
-            filterChainBuilder = IoFilterChainBuilder.NOOP;
+            config = ( IoConnectorConfig ) getDefaultConfig();
         }
 
         VmPipe entry = ( VmPipe ) VmPipeAcceptor.boundHandlers.get( address );
@@ -59,7 +71,7 @@
                         new Object(), // lock
                         AnonymousSocketAddress.INSTANCE,
                         handler,
-                        filterChainBuilder,
+                        config.getFilterChainBuilder(),
                         entry );
             future.setSession( session );
         }
@@ -68,5 +80,10 @@
             future.setException( e );
         }
         return future;
+    }
+    
+    public IoServiceConfig getDefaultConfig()
+    {
+        return defaultConfig;
     }
 }

Modified: directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipe.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipe.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipe.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipe.java Wed Jan 25 21:24:58 2006
@@ -7,7 +7,7 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.mina.common.IoFilterChainBuilder;
+import org.apache.mina.common.IoAcceptorConfig;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.transport.vmpipe.VmPipeAcceptor;
 import org.apache.mina.transport.vmpipe.VmPipeAddress;
@@ -17,19 +17,19 @@
     private final VmPipeAcceptor acceptor;
     private final VmPipeAddress address;
     private final IoHandler handler;
-    private final IoFilterChainBuilder filterChainBuilder;
+    private final IoAcceptorConfig config;
     private final Set managedClientSessions = Collections.synchronizedSet( new HashSet() );
     private final Set managedServerSessions = Collections.synchronizedSet( new HashSet() );
     
     public VmPipe( VmPipeAcceptor acceptor,
                    VmPipeAddress address,
                    IoHandler handler,
-                   IoFilterChainBuilder filterChainBuilder )
+                   IoAcceptorConfig config )
     {
         this.acceptor = acceptor;
         this.address = address;
         this.handler = handler;
-        this.filterChainBuilder = filterChainBuilder;
+        this.config = config;
     }
 
     public VmPipeAcceptor getAcceptor()
@@ -47,9 +47,9 @@
         return handler;
     }
     
-    public IoFilterChainBuilder getFilterChainBuilder()
+    public IoAcceptorConfig getConfig()
     {
-        return filterChainBuilder;
+        return config;
     }
 
     public Set getManagedClientSessions()

Modified: directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java Wed Jan 25 21:24:58 2006
@@ -12,14 +12,14 @@
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoFilterChainBuilder;
 import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoService;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.common.IoSessionConfig;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.common.support.BaseIoSession;
 import org.apache.mina.filter.codec.ProtocolDecoder;
 import org.apache.mina.filter.codec.ProtocolEncoder;
-import org.apache.mina.transport.vmpipe.VmPipeSession;
 import org.apache.mina.util.Queue;
 
 /**
@@ -28,8 +28,10 @@
  * @author The Apache Directory Project (dev@directory.apache.org)
  * @version $Rev$, $Date$
  */
-public class VmPipeSessionImpl extends BaseIoSession implements VmPipeSession
+public class VmPipeSessionImpl extends BaseIoSession
 {
+    private static final IoSessionConfig CONFIG = new IoSessionConfig() {};
+    
     private final IoService manager;
     private final SocketAddress localAddress;
     private final SocketAddress remoteAddress;
@@ -62,8 +64,7 @@
         // initialize remote session
         try
         {
-            remoteEntry.getAcceptor().getFilterChainBuilder().buildFilterChain( remoteSession.getFilterChain() );
-            remoteEntry.getFilterChainBuilder().buildFilterChain( remoteSession.getFilterChain() );
+            remoteEntry.getConfig().getFilterChainBuilder().buildFilterChain( remoteSession.getFilterChain() );
             ( ( VmPipeFilterChain ) remoteSession.getFilterChain() ).sessionCreated( remoteSession );
         }
         catch( Throwable t )
@@ -77,7 +78,6 @@
         // initialize client session
         try
         {
-            manager.getFilterChainBuilder().buildFilterChain( filterChain );
             filterChainBuilder.buildFilterChain( filterChain );
             handler.sessionCreated( this );
         }
@@ -120,6 +120,11 @@
     public IoService getService()
     {
         return manager;
+    }
+    
+    public IoSessionConfig getConfig()
+    {
+        return CONFIG;
     }
 
     public IoFilterChain getFilterChain()

Modified: directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/util/IdentityHashSet.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/util/IdentityHashSet.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/util/IdentityHashSet.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/util/IdentityHashSet.java Wed Jan 25 21:24:58 2006
@@ -19,6 +19,7 @@
 package org.apache.mina.util;
 
 import java.util.AbstractSet;
+import java.util.Collection;
 import java.util.IdentityHashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -36,6 +37,11 @@
 
     public IdentityHashSet()
     {
+    }
+    
+    public IdentityHashSet( Collection c )
+    {
+        addAll( c );
     }
 
     public int size()

Modified: directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/util/SessionUtil.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/util/SessionUtil.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/util/SessionUtil.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/main/java/org/apache/mina/util/SessionUtil.java Wed Jan 25 21:24:58 2006
@@ -18,11 +18,10 @@
  */
 package org.apache.mina.util;
 
-import java.net.SocketException;
-
 import org.apache.mina.common.IoSession;
-import org.apache.mina.transport.socket.nio.DatagramSession;
-import org.apache.mina.transport.socket.nio.SocketSession;
+import org.apache.mina.common.IoSessionConfig;
+import org.apache.mina.transport.socket.nio.DatagramSessionConfig;
+import org.apache.mina.transport.socket.nio.SocketSessionConfig;
 
 /**
  * Exception utility.
@@ -32,18 +31,19 @@
  */
 public class SessionUtil
 {
-    public static void initialize( IoSession session ) throws SocketException
+    public static void initialize( IoSession session )
     {
-        if( session instanceof SocketSession )
+        IoSessionConfig cfg = session.getConfig();
+        if( cfg instanceof SocketSessionConfig )
         {
-            SocketSession ss = ( SocketSession ) session;
-            ss.setReuseAddress( true );
-            ss.setKeepAlive( true );
+            SocketSessionConfig sCfg = ( SocketSessionConfig ) cfg;
+            sCfg.setReuseAddress( true );
+            sCfg.setKeepAlive( true );
         }
-        else if( session instanceof DatagramSession )
+        else if( cfg instanceof DatagramSessionConfig )
         {
-            DatagramSession ds = ( DatagramSession ) session;
-            ds.setReuseAddress( true );
+            DatagramSessionConfig dCfg = ( DatagramSessionConfig ) cfg;
+            dCfg.setReuseAddress( true );
         }
     }
 

Modified: directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/common/FutureTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/common/FutureTest.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/common/FutureTest.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/common/FutureTest.java Wed Jan 25 21:24:58 2006
@@ -106,6 +106,11 @@
             {
                 return null;
             }
+
+            public IoSessionConfig getConfig()
+            {
+                return null;
+            }
         };
         
         future.setSession( session );

Modified: directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/common/IoFilterChainTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/common/IoFilterChainTest.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/common/IoFilterChainTest.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/common/IoFilterChainTest.java Wed Jan 25 21:24:58 2006
@@ -299,6 +299,11 @@
         {
             return null;
         }
+
+        public IoSessionConfig getConfig()
+        {
+            return null;
+        }
     }
 
     private class EventOrderTestFilter extends IoFilterAdapter
@@ -414,6 +419,11 @@
                 public int getScheduledWriteRequests()
                 {
                     return 0;
+                }
+
+                public IoSessionConfig getConfig()
+                {
+                    return null;
                 }
             } );
         }

Modified: directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/StreamWriteFilterTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/StreamWriteFilterTest.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/StreamWriteFilterTest.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/StreamWriteFilterTest.java Wed Jan 25 21:24:58 2006
@@ -30,15 +30,14 @@
 
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IdleStatus;
+import org.apache.mina.common.IoAcceptor;
+import org.apache.mina.common.IoConnector;
 import org.apache.mina.common.IoHandlerAdapter;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.common.TransportType;
 import org.apache.mina.common.IoFilter.NextFilter;
 import org.apache.mina.common.IoFilter.WriteRequest;
-import org.apache.mina.registry.Service;
-import org.apache.mina.registry.ServiceRegistry;
-import org.apache.mina.registry.SimpleServiceRegistry;
 import org.apache.mina.transport.socket.nio.SocketAcceptor;
+import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
 import org.apache.mina.transport.socket.nio.SocketConnector;
 import org.apache.mina.util.AvailablePortFinder;
 import org.easymock.AbstractMatcher;
@@ -317,20 +316,19 @@
     
     public void testWriteUsingSocketTransport() throws Exception
     {
-        ServiceRegistry reg = new SimpleServiceRegistry();
-        ( ( SocketAcceptor ) reg.getAcceptor( TransportType.SOCKET ) ).setReuseAddress( true );
+        IoAcceptor acceptor = new SocketAcceptor();
+        ( ( SocketAcceptorConfig ) acceptor.getDefaultConfig() ).setReuseAddress( true );
         SocketAddress address = new InetSocketAddress( "localhost", AvailablePortFinder.getNextAvailable() );
-        Service service = new Service( "stream", TransportType.SOCKET, address );
 
-        SocketConnector connector = new SocketConnector();
-        connector.getFilterChain().addFirst( "threadPool", new ThreadPoolFilter() );
+        IoConnector connector = new SocketConnector();
+        connector.getDefaultConfig().getFilterChain().addFirst( "threadPool", new ThreadPoolFilter() );
         
         FixedRandomInputStream stream = new FixedRandomInputStream( 4 * 1024 * 1024 );
         
         SenderHandler sender = new SenderHandler( stream );
         ReceiverHandler receiver = new ReceiverHandler( stream.size );
         
-        reg.bind( service, sender );
+        acceptor.bind( address, sender );
         
         synchronized( sender.lock )
         {
@@ -343,7 +341,7 @@
             }
         }
         
-        reg.unbindAll();
+        acceptor.unbind( address );
         
         assertEquals( stream.bytesRead, receiver.bytesRead );
         assertEquals( stream.size, receiver.bytesRead );

Modified: directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java Wed Jan 25 21:24:58 2006
@@ -11,6 +11,7 @@
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoService;
+import org.apache.mina.common.IoSessionConfig;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.common.WriteFuture;
 import org.apache.mina.common.IoFilter.NextFilter;
@@ -190,6 +191,11 @@
         {
             return null;
         }
+
+        public IoSessionConfig getConfig()
+        {
+            return null;
+        }
     }
     
     private static class EventOrderChecker implements NextFilter
@@ -291,6 +297,11 @@
         }
 
         public IoService getService()
+        {
+            return null;
+        }
+
+        public IoSessionConfig getConfig()
         {
             return null;
         }

Modified: directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java Wed Jan 25 21:24:58 2006
@@ -31,6 +31,7 @@
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoService;
+import org.apache.mina.common.IoSessionConfig;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.common.support.BaseIoSession;
 
@@ -229,6 +230,11 @@
         }
 
         public IoService getService()
+        {
+            return null;
+        }
+
+        public IoSessionConfig getConfig()
         {
             return null;
         }

Modified: directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineDecoderTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineDecoderTest.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineDecoderTest.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineDecoderTest.java Wed Jan 25 21:24:58 2006
@@ -30,6 +30,7 @@
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoService;
+import org.apache.mina.common.IoSessionConfig;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.common.support.BaseIoSession;
 import org.apache.mina.filter.codec.support.SimpleProtocolDecoderOutput;
@@ -217,6 +218,11 @@
         public int getScheduledWriteRequests()
         {
             return 0;
+        }
+
+        public IoSessionConfig getConfig()
+        {
+            return null;
         }
     }
 }

Modified: directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineEncoderTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineEncoderTest.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineEncoderTest.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineEncoderTest.java Wed Jan 25 21:24:58 2006
@@ -29,6 +29,7 @@
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoService;
+import org.apache.mina.common.IoSessionConfig;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.common.WriteFuture;
 import org.apache.mina.common.support.BaseIoSession;
@@ -111,6 +112,11 @@
         public int getScheduledWriteRequests()
         {
             return 0;
+        }
+
+        public IoSessionConfig getConfig()
+        {
+            return null;
         }
     }
 }

Modified: directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/handler/chain/ChainedIoHandlerTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/handler/chain/ChainedIoHandlerTest.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/handler/chain/ChainedIoHandlerTest.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/handler/chain/ChainedIoHandlerTest.java Wed Jan 25 21:24:58 2006
@@ -27,6 +27,7 @@
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoService;
+import org.apache.mina.common.IoSessionConfig;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.common.support.BaseIoSession;
 
@@ -91,6 +92,11 @@
                     public int getScheduledWriteRequests()
                     {
                         return 0;
+                    }
+
+                    public IoSessionConfig getConfig()
+                    {
+                        return null;
                     }
                 }, null );
         

Modified: directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/AbstractBindTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/AbstractBindTest.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/AbstractBindTest.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/AbstractBindTest.java Wed Jan 25 21:24:58 2006
@@ -31,8 +31,10 @@
 import org.apache.mina.common.IoHandlerAdapter;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.transport.socket.nio.DatagramAcceptor;
+import org.apache.mina.transport.socket.nio.DatagramSessionConfig;
 import org.apache.mina.transport.socket.nio.SocketAcceptor;
-import org.apache.mina.transport.socket.nio.SocketSession;
+import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
+import org.apache.mina.transport.socket.nio.SocketSessionConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -92,11 +94,11 @@
     {
         if( acceptor instanceof DatagramAcceptor )
         {
-            ( ( DatagramAcceptor ) acceptor ).setReuseAddress( reuseAddress );
+            ( ( DatagramSessionConfig ) acceptor.getDefaultConfig().getSessionConfig() ).setReuseAddress( reuseAddress );
         }
         else if( acceptor instanceof SocketAcceptor )
         {
-            ( ( SocketAcceptor ) acceptor ).setReuseAddress( reuseAddress );
+            ( ( SocketAcceptorConfig ) acceptor.getDefaultConfig() ).setReuseAddress( reuseAddress );
         }
     }
     
@@ -182,9 +184,9 @@
 
         public void sessionCreated( IoSession session )
         {
-            if( session instanceof SocketSession )
+            if( session.getConfig() instanceof SocketSessionConfig )
             {
-                ( ( SocketSession ) session ).setSessionReceiveBufferSize( 2048 );
+                ( ( SocketSessionConfig ) session.getConfig() ).setReceiveBufferSize( 2048 );
             }
 
             session.setIdleTime( IdleStatus.BOTH_IDLE, 10 );

Modified: directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/AbstractTrafficControlTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/AbstractTrafficControlTest.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/AbstractTrafficControlTest.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/AbstractTrafficControlTest.java Wed Jan 25 21:24:58 2006
@@ -24,12 +24,11 @@
 
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.ConnectFuture;
+import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoHandlerAdapter;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.TransportType;
-import org.apache.mina.registry.Service;
-import org.apache.mina.registry.SimpleServiceRegistry;
 import org.apache.mina.util.AvailablePortFinder;
 
 /**
@@ -42,12 +41,12 @@
 public abstract class AbstractTrafficControlTest extends TestCase
 {
     protected int port = 0;
-    protected SimpleServiceRegistry registry;
+    protected IoAcceptor acceptor;
     protected TransportType transportType;
     
-    public AbstractTrafficControlTest( TransportType transportType )
+    public AbstractTrafficControlTest( IoAcceptor acceptor )
     {
-        this.transportType = transportType;
+        this.acceptor = acceptor;
     }
 
     protected void setUp() throws Exception
@@ -56,9 +55,7 @@
         
         port = AvailablePortFinder.getNextAvailable();
         
-        registry = new SimpleServiceRegistry();
-        registry.bind( new Service( "traffic", transportType, 
-                                    createServerSocketAddress( port ) ), 
+        acceptor.bind( createServerSocketAddress( port ), 
                        new ServerIoHandler() );
         
     }
@@ -67,7 +64,7 @@
     {
         super.tearDown();
         
-        registry.unbindAll();
+        acceptor.unbind( createServerSocketAddress( port ) );
     }
 
     protected abstract ConnectFuture connect( int port, IoHandler handler) throws Exception;

Modified: directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramTrafficControlTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramTrafficControlTest.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramTrafficControlTest.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramTrafficControlTest.java Wed Jan 25 21:24:58 2006
@@ -24,7 +24,6 @@
 import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.IoConnector;
 import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.TransportType;
 import org.apache.mina.transport.AbstractTrafficControlTest;
 
 /**
@@ -39,7 +38,7 @@
 
     public DatagramTrafficControlTest()
     {
-        super( TransportType.DATAGRAM );
+        super( new DatagramAcceptor() );
     }
 
     protected ConnectFuture connect( int port, IoHandler handler )

Modified: directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/socket/nio/SocketTrafficControlTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/socket/nio/SocketTrafficControlTest.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/socket/nio/SocketTrafficControlTest.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/socket/nio/SocketTrafficControlTest.java Wed Jan 25 21:24:58 2006
@@ -24,7 +24,6 @@
 import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.IoConnector;
 import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.TransportType;
 import org.apache.mina.transport.AbstractTrafficControlTest;
 
 /**
@@ -39,7 +38,7 @@
 
     public SocketTrafficControlTest()
     {
-        super( TransportType.SOCKET );
+        super( new SocketAcceptor() );
     }
 
     protected ConnectFuture connect( int port, IoHandler handler )

Modified: directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/vmpipe/VmPipeTrafficControlTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/vmpipe/VmPipeTrafficControlTest.java?rev=372449&r1=372448&r2=372449&view=diff
==============================================================================
--- directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/vmpipe/VmPipeTrafficControlTest.java (original)
+++ directory/sandbox/trustin/dirmina-158/core/src/test/java/org/apache/mina/transport/vmpipe/VmPipeTrafficControlTest.java Wed Jan 25 21:24:58 2006
@@ -23,7 +23,6 @@
 import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.IoConnector;
 import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.TransportType;
 import org.apache.mina.transport.AbstractTrafficControlTest;
 
 /**
@@ -38,7 +37,7 @@
 
     public VmPipeTrafficControlTest()
     {
-        super( TransportType.VM_PIPE );
+        super( new VmPipeAcceptor() );
     }
 
     protected ConnectFuture connect( int port, IoHandler handler )



Mime
View raw message