directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r465510 [2/3] - in /directory/trunks/mina: core/src/main/java/org/apache/mina/common/ core/src/main/java/org/apache/mina/common/support/ core/src/main/java/org/apache/mina/management/ core/src/main/java/org/apache/mina/transport/socket/nio/...
Date Thu, 19 Oct 2006 06:42:11 GMT
Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketSessionImpl.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketSessionImpl.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketSessionImpl.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/SocketSessionImpl.java Wed Oct 18 23:42:06 2006
@@ -27,7 +27,6 @@
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoService;
-import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoSessionConfig;
 import org.apache.mina.common.RuntimeIOException;
@@ -46,8 +45,8 @@
  */
 class SocketSessionImpl extends BaseIoSession
 {
-    private final IoService manager;
-    private final IoServiceConfig serviceConfig;
+    private final IoService service;
+    private final IoServiceListenerSupport serviceListeners;
     private final SocketSessionConfig config = new SessionConfigImpl();
     private final SocketIoProcessor ioProcessor;
     private final SocketFilterChain filterChain;
@@ -57,35 +56,27 @@
     private final SocketAddress remoteAddress;
     private final SocketAddress localAddress;
     private final SocketAddress serviceAddress;
-    private final IoServiceListenerSupport serviceListeners;
     private SelectionKey key;
     private int readBufferSize;
 
     /**
      * Creates a new instance.
      */
-    SocketSessionImpl( IoService manager,
-                       SocketIoProcessor ioProcessor,
-                       IoServiceListenerSupport listeners,
-                       IoServiceConfig serviceConfig,
-                       SocketChannel ch,
-                       IoHandler defaultHandler,
-                       SocketAddress serviceAddress )
+    SocketSessionImpl( IoService service, IoServiceListenerSupport serviceListeners, SocketIoProcessor ioProcessor, SocketChannel ch )
     {
-        this.manager = manager;
-        this.serviceListeners = listeners;
+        this.service = service;
         this.ioProcessor = ioProcessor;
         this.filterChain = new SocketFilterChain( this );
         this.ch = ch;
         this.writeRequestQueue = new Queue();
-        this.handler = defaultHandler;
+        this.handler = service.getHandler();
         this.remoteAddress = ch.socket().getRemoteSocketAddress();
         this.localAddress = ch.socket().getLocalSocketAddress();
-        this.serviceAddress = serviceAddress;
-        this.serviceConfig = serviceConfig;
+        this.serviceAddress = service.getServiceAddress();
+        this.serviceListeners = serviceListeners;
 
         // Apply the initial session settings
-        IoSessionConfig sessionConfig = serviceConfig.getSessionConfig();
+        IoSessionConfig sessionConfig = service.getSessionConfig();
         if( sessionConfig instanceof SocketSessionConfig )
         {
             SocketSessionConfig cfg = ( SocketSessionConfig ) sessionConfig;
@@ -107,19 +98,19 @@
 
     public IoService getService()
     {
-        return manager;
+        return service;
     }
     
-    public IoServiceConfig getServiceConfig()
-    {
-        return serviceConfig;
-    }
-
     public IoSessionConfig getConfig()
     {
         return config;
     }
-
+    
+    IoServiceListenerSupport getServiceListeners()
+    {
+        return serviceListeners;
+    }
+    
     SocketIoProcessor getIoProcessor()
     {
         return ioProcessor;
@@ -133,11 +124,6 @@
     SocketChannel getChannel()
     {
         return ch;
-    }
-
-    IoServiceListenerSupport getServiceListeners()
-    {
-        return serviceListeners;
     }
 
     SelectionKey getSelectionKey()

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java Wed Oct 18 23:42:06 2006
@@ -25,25 +25,21 @@
 import java.nio.channels.DatagramChannel;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.ExceptionMonitor;
+import org.apache.mina.common.ExpiringSessionRecycler;
 import org.apache.mina.common.IoAcceptor;
-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.IoSessionRecycler;
 import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.common.support.BaseIoAcceptor;
 import org.apache.mina.common.support.IoServiceListenerSupport;
-import org.apache.mina.transport.socket.nio.DatagramAcceptorConfig;
-import org.apache.mina.transport.socket.nio.DatagramServiceConfig;
 import org.apache.mina.transport.socket.nio.DatagramSessionConfig;
 import org.apache.mina.util.NamePreservingRunnable;
 import org.apache.mina.util.Queue;
@@ -58,13 +54,17 @@
  */
 public class DatagramAcceptorDelegate extends BaseIoAcceptor implements IoAcceptor, DatagramService
 {
+    private static final IoSessionRecycler DEFAULT_RECYCLER = new ExpiringSessionRecycler();
+    
     private static volatile int nextId = 0;
 
+    private IoSessionRecycler sessionRecycler = DEFAULT_RECYCLER;
+    private final IoSessionConfig sessionConfig = new DatagramSessionConfigImpl();
+        
     private final IoAcceptor wrapper;
     private final Executor executor;
     private final int id = nextId ++ ;
     private Selector selector;
-    private DatagramAcceptorConfig defaultConfig = new DatagramAcceptorConfig();
     private final Map channels = new HashMap();
     private final Queue registerQueue = new Queue();
     private final Queue cancelQueue = new Queue();
@@ -80,25 +80,17 @@
         this.executor = executor;
     }
 
-    public void bind( SocketAddress address, IoHandler handler, IoServiceConfig config )
-            throws IOException
+    protected Class getAddressType()
     {
-        if( address == null )
-            throw new NullPointerException( "address" );
-        if( handler == null )
-            throw new NullPointerException( "handler" );
-        if( config == null )
-        {
-            config = getDefaultConfig();
-        }
-
-        if( !( address instanceof InetSocketAddress ) )
-            throw new IllegalArgumentException( "Unexpected address type: "
-                                                + address.getClass() );
-        if( ( ( InetSocketAddress ) address ).getPort() == 0 )
+        return InetSocketAddress.class;
+    }
+
+    protected void doBind() throws IOException
+    {
+        if( ( ( InetSocketAddress ) getLocalAddress() ).getPort() == 0 )
             throw new IllegalArgumentException( "Unsupported port number: 0" );
         
-        RegistrationRequest request = new RegistrationRequest( address, handler, config );
+        RegistrationRequest request = new RegistrationRequest();
         synchronized( this )
         {
             synchronized( registerQueue )
@@ -129,12 +121,9 @@
         }
     }
 
-    public void unbind( SocketAddress address )
+    protected void doUnbind()
     {
-        if( address == null )
-            throw new NullPointerException( "address" );
-
-        CancellationRequest request = new CancellationRequest( address );
+        CancellationRequest request = new CancellationRequest();
         synchronized( this )
         {
             try
@@ -147,7 +136,7 @@
                 // running and failed to open a selector.  We simply throw
                 // IllegalArgumentException here because we can simply
                 // conclude that nothing is bound to the selector.
-                throw new IllegalArgumentException( "Address not bound: " + address );
+                throw new IllegalArgumentException( "Address not bound: " + getLocalAddress() );
             }
 
             synchronized( cancelQueue )
@@ -177,50 +166,35 @@
         }
     }
     
-    public void unbindAll()
-    {
-        List addresses;
-        synchronized( channels )
-        {
-            addresses = new ArrayList( channels.keySet() );
-        }
-        
-        for( Iterator i = addresses.iterator(); i.hasNext(); )
-        {
-            unbind( ( SocketAddress ) i.next() );
-        }
-    }
-    
-    public IoSession newSession( SocketAddress remoteAddress, SocketAddress localAddress )
+    public IoSession newSession( SocketAddress remoteAddress )
     {
         if( remoteAddress == null )
         {
             throw new NullPointerException( "remoteAddress" );
         }
-        if( localAddress == null )
+        if( getLocalAddress() == null )
         {
             throw new NullPointerException( "localAddress" );
         }
         
         Selector selector = this.selector;
-        DatagramChannel ch = ( DatagramChannel ) channels.get( localAddress );
+        DatagramChannel ch = ( DatagramChannel ) channels.get( getLocalAddress() );
         if( selector == null || ch == null )
         {
-            throw new IllegalArgumentException( "Unknown localAddress: " + localAddress );
+            throw new IllegalArgumentException( "Unknown localAddress: " + getLocalAddress() );
         }
             
         SelectionKey key = ch.keyFor( selector );
         if( key == null )
         {
-            throw new IllegalArgumentException( "Unknown localAddress: " + localAddress );
+            throw new IllegalArgumentException( "Unknown localAddress: " + getLocalAddress() );
         }
 
-        RegistrationRequest req = ( RegistrationRequest ) key.attachment();
         IoSession session;
-        IoSessionRecycler sessionRecycler = getSessionRecycler( req );
+        IoSessionRecycler sessionRecycler = getSessionRecycler();
         synchronized ( sessionRecycler )
         {
-            session = sessionRecycler.recycle( localAddress, remoteAddress );
+            session = sessionRecycler.recycle( getLocalAddress(), remoteAddress );
             if( session != null )
             {
                 return session;
@@ -228,19 +202,17 @@
 
             // If a new session needs to be created.
             DatagramSessionImpl datagramSession = new DatagramSessionImpl(
-                    wrapper, this,
-                    req.config, ch, req.handler,
-                    req.address );
+                    wrapper, this, ch, getHandler(), getLocalAddress() );
             datagramSession.setRemoteAddress( remoteAddress );
             datagramSession.setSelectionKey( key );
             
-            getSessionRecycler( req ).put( datagramSession );
+            getSessionRecycler().put( datagramSession );
             session = datagramSession;
         }
         
         try
         {
-            buildFilterChain( req, session );
+            buildFilterChain( session );
             getListeners().fireSessionCreated( session );
         }
         catch( Throwable t )
@@ -251,50 +223,44 @@
         return session;
     }
 
-    private IoSessionRecycler getSessionRecycler( RegistrationRequest req )
+    public IoSessionRecycler getSessionRecycler()
     {
-        IoSessionRecycler sessionRecycler;
-        if( req.config instanceof DatagramServiceConfig )
-        {
-            sessionRecycler = ( ( DatagramServiceConfig ) req.config ).getSessionRecycler();
-        }
-        else
-        {
-            sessionRecycler = defaultConfig.getSessionRecycler();
-        }
         return sessionRecycler;
     }
-    
-    public IoServiceListenerSupport getListeners()
+
+    public void setSessionRecycler( IoSessionRecycler sessionRecycler )
     {
-        return super.getListeners();
+        synchronized( bindLock )
+        {
+            if( isBound() )
+            {
+                throw new IllegalStateException(
+                        "sessionRecycler can't be set while the acceptor is bound." );
+            }
+
+            if( sessionRecycler == null )
+            {
+                sessionRecycler = DEFAULT_RECYCLER;
+            }
+            this.sessionRecycler = sessionRecycler;
+        }
     }
 
-    private void buildFilterChain( RegistrationRequest req, IoSession session ) throws Exception
+
+    public IoSessionConfig getSessionConfig()
     {
-        this.getFilterChainBuilder().buildFilterChain( session.getFilterChain() );
-        req.config.getFilterChainBuilder().buildFilterChain( session.getFilterChain() );
-        req.config.getThreadModel().buildFilterChain( session.getFilterChain() );
+        return sessionConfig;
     }
-    
-    public IoServiceConfig getDefaultConfig()
+
+    public IoServiceListenerSupport getListeners()
     {
-        return defaultConfig;
+        return super.getListeners();
     }
-    
-    /**
-     * Sets the config this acceptor will use by default.
-     * 
-     * @param defaultConfig the default config.
-     * @throws NullPointerException if the specified value is <code>null</code>.
-     */
-    public void setDefaultConfig( DatagramAcceptorConfig defaultConfig )
+
+    private void buildFilterChain( IoSession session ) throws Exception
     {
-        if( defaultConfig == null )
-        {
-            throw new NullPointerException( "defaultConfig" );
-        }
-        this.defaultConfig = defaultConfig;
+        this.getFilterChainBuilder().buildFilterChain( session.getFilterChain() );
+        this.getThreadModel().buildFilterChain( session.getFilterChain() );
     }
     
     private synchronized void startupWorker() throws IOException
@@ -403,17 +369,16 @@
 
             DatagramChannel ch = ( DatagramChannel ) key.channel();
 
-            RegistrationRequest req = ( RegistrationRequest ) key.attachment();
             try
             {
                 if( key.isReadable() )
                 {
-                    readSession( ch, req );
+                    readSession( ch );
                 }
 
                 if( key.isWritable() )
                 {
-                    for( Iterator i = getManagedSessions( req.address ).iterator();
+                    for( Iterator i = getManagedSessions().iterator();
                          i.hasNext(); )
                     {
                         scheduleFlush( ( DatagramSessionImpl ) i.next() );
@@ -427,10 +392,10 @@
         }
     }
 
-    private void readSession( DatagramChannel channel, RegistrationRequest req ) throws Exception
+    private void readSession( DatagramChannel channel ) throws Exception
     {
         ByteBuffer readBuf = ByteBuffer.allocate(
-                ( ( DatagramSessionConfig ) req.config.getSessionConfig() ).getReceiveBufferSize() );
+                ( ( DatagramSessionConfig ) getSessionConfig() ).getReceiveBufferSize() );
         try
         {
             SocketAddress remoteAddress = channel.receive(
@@ -438,7 +403,7 @@
             if( remoteAddress != null )
             {
                 DatagramSessionImpl session =
-                    ( DatagramSessionImpl ) newSession( remoteAddress, req.address );
+                    ( DatagramSessionImpl ) newSession( remoteAddress );
 
                 readBuf.flip();
 
@@ -579,16 +544,7 @@
             try
             {
                 ch = DatagramChannel.open();
-                DatagramSessionConfig cfg;
-                if( req.config.getSessionConfig() instanceof DatagramSessionConfig )
-                {
-                    cfg = ( DatagramSessionConfig ) req.config.getSessionConfig();
-                }
-                else
-                {
-                    cfg = ( DatagramSessionConfig ) getDefaultConfig().getSessionConfig();
-                }
-
+                DatagramSessionConfig cfg = ( DatagramSessionConfig ) getSessionConfig();
                 ch.socket().setReuseAddress( cfg.isReuseAddress() );
                 ch.socket().setBroadcast( cfg.isBroadcast() );
                 ch.socket().setReceiveBufferSize( cfg.getReceiveBufferSize() );
@@ -600,15 +556,14 @@
                 }
 
                 ch.configureBlocking( false );
-                ch.socket().bind( req.address );
+                ch.socket().bind( getLocalAddress() );
                 ch.register( selector, SelectionKey.OP_READ, req );
                 synchronized( channels )
                 {
-                    channels.put( req.address, ch );
+                    channels.put( getLocalAddress(), ch );
                 }
                 
-                getListeners().fireServiceActivated(
-                        this, req.address, req.handler, req.config);
+                getListeners().fireServiceActivated();
             }
             catch( Throwable t )
             {
@@ -659,7 +614,7 @@
             DatagramChannel ch;
             synchronized( channels )
             {
-                ch = ( DatagramChannel ) channels.remove( request.address );
+                ch = ( DatagramChannel ) channels.remove( getLocalAddress() );
             }
 
             // close the channel
@@ -668,12 +623,11 @@
                 if( ch == null )
                 {
                     request.exception = new IllegalArgumentException(
-                            "Address not bound: " + request.address );
+                            "Address not bound: " + getLocalAddress() );
                 }
                 else
                 {
                     SelectionKey key = ch.keyFor( selector );
-                    request.registrationRequest = ( RegistrationRequest ) key.attachment();
                     key.cancel();
                     selector.wakeup(); // wake up again to trigger thread death
                     ch.disconnect();
@@ -694,10 +648,7 @@
 
                 if( request.exception == null )
                 {
-                    getListeners().fireServiceDeactivated(
-                            this, request.address,
-                            request.registrationRequest.handler,
-                            request.registrationRequest.config );
+                    getListeners().fireServiceDeactivated();
                 }
             }
         }
@@ -712,31 +663,13 @@
 
     private static class RegistrationRequest
     {
-        private final SocketAddress address;
-        private final IoHandler handler;
-        private final IoServiceConfig config;
-
         private Throwable exception; 
         private boolean done;
-        
-        private RegistrationRequest( SocketAddress address, IoHandler handler, IoServiceConfig config )
-        {
-            this.address = address;
-            this.handler = handler;
-            this.config = config;
-        }
     }
 
     private static class CancellationRequest
     {
-        private final SocketAddress address;
         private boolean done;
-        private RegistrationRequest registrationRequest;
         private RuntimeException exception;
-        
-        private CancellationRequest( SocketAddress address )
-        {
-            this.address = address;
-        }
     }
 }

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java Wed Oct 18 23:42:06 2006
@@ -21,7 +21,6 @@
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
-import java.net.SocketAddress;
 import java.nio.channels.DatagramChannel;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
@@ -31,17 +30,15 @@
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.ExceptionMonitor;
+import org.apache.mina.common.ExpiringSessionRecycler;
 import org.apache.mina.common.IoConnector;
-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.IoSessionRecycler;
 import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.common.support.AbstractIoFilterChain;
 import org.apache.mina.common.support.BaseIoConnector;
 import org.apache.mina.common.support.DefaultConnectFuture;
-import org.apache.mina.transport.socket.nio.DatagramConnectorConfig;
-import org.apache.mina.transport.socket.nio.DatagramServiceConfig;
 import org.apache.mina.transport.socket.nio.DatagramSessionConfig;
 import org.apache.mina.util.NamePreservingRunnable;
 import org.apache.mina.util.Queue;
@@ -56,13 +53,17 @@
  */
 public class DatagramConnectorDelegate extends BaseIoConnector implements DatagramService
 {
+    private static final IoSessionRecycler DEFAULT_RECYCLER = new ExpiringSessionRecycler();
+
     private static volatile int nextId = 0;
 
+    private IoSessionRecycler sessionRecycler = DEFAULT_RECYCLER;
+    private final IoSessionConfig sessionConfig = new DatagramSessionConfigImpl();
+
     private final IoConnector wrapper;
     private final Executor executor;
     private final int id = nextId ++ ;
     private Selector selector;
-    private DatagramConnectorConfig defaultConfig = new DatagramConnectorConfig();
     private final Queue registerQueue = new Queue();
     private final Queue cancelQueue = new Queue();
     private final Queue flushingSessions = new Queue();
@@ -78,48 +79,19 @@
         this.executor = executor;
     }
 
-    public ConnectFuture connect( SocketAddress address, IoHandler handler, IoServiceConfig config )
+    protected Class getAddressType()
     {
-        return connect( address, null, handler, config );
+        return InetSocketAddress.class;
     }
 
-    public ConnectFuture connect( SocketAddress address, SocketAddress localAddress,
-                                  IoHandler handler, IoServiceConfig config )
+    protected ConnectFuture doConnect()
     {
-        if( address == null )
-            throw new NullPointerException( "address" );
-        if( handler == null )
-            throw new NullPointerException( "handler" );
-
-        if( !( address instanceof InetSocketAddress ) )
-            throw new IllegalArgumentException( "Unexpected address type: "
-                                                + address.getClass() );
-        
-        if( localAddress != null && !( localAddress instanceof InetSocketAddress ) )
-        {
-            throw new IllegalArgumentException( "Unexpected local address type: "
-                                                + localAddress.getClass() );
-        }
-        
-        if( config == null )
-        {
-            config = getDefaultConfig();
-        }
-        
         DatagramChannel ch = null;
         boolean initialized = false;
         try
         {
             ch = DatagramChannel.open();
-            DatagramSessionConfig cfg;
-            if( config.getSessionConfig() instanceof DatagramSessionConfig )
-            {
-                cfg = ( DatagramSessionConfig ) config.getSessionConfig();
-            }
-            else
-            {
-                cfg = ( DatagramSessionConfig ) getDefaultConfig().getSessionConfig();
-            }
+            DatagramSessionConfig cfg = ( DatagramSessionConfig ) getSessionConfig();
             
             ch.socket().setReuseAddress( cfg.isReuseAddress() );
             ch.socket().setBroadcast( cfg.isBroadcast() );
@@ -131,11 +103,11 @@
                 ch.socket().setTrafficClass( cfg.getTrafficClass() );
             }
 
-            if( localAddress != null )
+            if( getLocalAddress() != null )
             {
-                ch.socket().bind( localAddress );
+                ch.socket().bind( getLocalAddress() );
             }
-            ch.connect( address );
+            ch.connect( getRemoteAddress() );
             ch.configureBlocking( false );
             initialized = true;
         }
@@ -159,7 +131,7 @@
             }
         }
 
-        RegistrationRequest request = new RegistrationRequest( ch, handler, config );
+        RegistrationRequest request = new RegistrationRequest( ch );
         synchronized( this )
         {
             try
@@ -191,26 +163,26 @@
         return request;
     }
     
-    public IoServiceConfig getDefaultConfig()
+    public IoSessionRecycler getSessionRecycler()
     {
-        return defaultConfig;
+        return sessionRecycler;
     }
-    
-    /**
-     * Sets the config this connector will use by default.
-     * 
-     * @param defaultConfig the default config.
-     * @throws NullPointerException if the specified value is <code>null</code>.
-     */
-    public void setDefaultConfig( DatagramConnectorConfig defaultConfig )
+
+    // FIXME There can be a problem if a user changes the recycler after the service is activated.
+    public void setSessionRecycler( IoSessionRecycler sessionRecycler )
     {
-        if( defaultConfig == null )
+        if( sessionRecycler == null )
         {
-            throw new NullPointerException( "defaultConfig" );
+            sessionRecycler = DEFAULT_RECYCLER;
         }
-        this.defaultConfig = defaultConfig;
+        this.sessionRecycler = sessionRecycler;
     }
-    
+
+    public IoSessionConfig getSessionConfig()
+    {
+        return sessionConfig;
+    }
+
     private synchronized void startupWorker() throws IOException
     {
         if( worker == null )
@@ -431,7 +403,7 @@
     
     private DatagramSessionImpl getRecycledSession( IoSession session )
     {
-        IoSessionRecycler sessionRecycler = getSessionRecycler( session );
+        IoSessionRecycler sessionRecycler = getSessionRecycler();
         DatagramSessionImpl replaceSession = null;
 
         if ( sessionRecycler != null )
@@ -453,21 +425,6 @@
         return null;
     }
     
-    private IoSessionRecycler getSessionRecycler( IoSession session )
-    {
-        IoServiceConfig config = session.getServiceConfig();
-        IoSessionRecycler sessionRecycler;
-        if( config instanceof DatagramServiceConfig )
-        {
-            sessionRecycler = ( ( DatagramServiceConfig ) config ).getSessionRecycler();
-        }
-        else
-        {
-            sessionRecycler = defaultConfig.getSessionRecycler();
-        }
-        return sessionRecycler;
-    }
-
     private void readSession( DatagramSessionImpl session )
     {
 
@@ -611,8 +568,7 @@
 
             DatagramSessionImpl session = new DatagramSessionImpl(
                     wrapper, this,
-                    req.config,
-                    req.channel, req.handler,
+                    req.channel, getHandler(),
                     req.channel.socket().getRemoteSocketAddress() );
             
             // AbstractIoFilterChain will notify the connect future.
@@ -633,7 +589,7 @@
                             SelectionKey.OP_READ, session );
 
                     session.setSelectionKey( key );
-                    buildFilterChain( req, session );
+                    buildFilterChain( session );
                     // The CONNECT_FUTURE attribute is cleared and notified here.
                     getListeners().fireSessionCreated( session );
                 }
@@ -662,11 +618,10 @@
         }
     }
 
-    private void buildFilterChain( RegistrationRequest req, IoSession session ) throws Exception
+    private void buildFilterChain( IoSession session ) throws Exception
     {
         getFilterChainBuilder().buildFilterChain( session.getFilterChain() );
-        req.config.getFilterChainBuilder().buildFilterChain( session.getFilterChain() );
-        req.config.getThreadModel().buildFilterChain( session.getFilterChain() );
+        getThreadModel().buildFilterChain( session.getFilterChain() );
     }
 
     private void cancelKeys()
@@ -709,16 +664,10 @@
     private static class RegistrationRequest extends DefaultConnectFuture
     {
         private final DatagramChannel channel;
-        private final IoHandler handler;
-        private final IoServiceConfig config;
 
-        private RegistrationRequest( DatagramChannel channel,
-                                     IoHandler handler,
-                                     IoServiceConfig config )
+        private RegistrationRequest( DatagramChannel channel )
         {
             this.channel = channel;
-            this.handler = handler;
-            this.config = config;
         }
     }
 }

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramService.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramService.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramService.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramService.java Wed Oct 18 23:42:06 2006
@@ -26,7 +26,7 @@
  * @author The Apache Directory Project (mina-dev@directory.apache.org)
  * @version $Rev$, $Date$
  */
-interface DatagramService
+interface DatagramService extends org.apache.mina.transport.socket.nio.DatagramService
 {
     /**
      * Requests this processor to flush the write buffer of the specified

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java Wed Oct 18 23:42:06 2006
@@ -28,7 +28,6 @@
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoService;
-import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoSessionConfig;
 import org.apache.mina.common.RuntimeIOException;
@@ -36,7 +35,6 @@
 import org.apache.mina.common.WriteFuture;
 import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.common.support.BaseIoSession;
-import org.apache.mina.transport.socket.nio.DatagramServiceConfig;
 import org.apache.mina.transport.socket.nio.DatagramSessionConfig;
 import org.apache.mina.util.Queue;
 
@@ -49,7 +47,6 @@
 class DatagramSessionImpl extends BaseIoSession implements BroadcastIoSession
 {
     private final IoService wrapperManager;
-    private final IoServiceConfig serviceConfig;
     private final DatagramSessionConfig config = new SessionConfigImpl();
     private final DatagramService managerDelegate;
     private final DatagramFilterChain filterChain;
@@ -67,7 +64,6 @@
      */
     DatagramSessionImpl( IoService wrapperManager,
                          DatagramService managerDelegate,
-                         IoServiceConfig serviceConfig,
                          DatagramChannel ch, IoHandler defaultHandler,
                          SocketAddress serviceAddress )
     {
@@ -83,10 +79,9 @@
         // the case that getLocalSocketAddress() returns IPv6 address while
         // serviceAddress represents the same address in IPv4.
         this.localAddress = this.serviceAddress = serviceAddress;
-        this.serviceConfig = serviceConfig;
 
         // Apply the initial session settings
-        IoSessionConfig sessionConfig = serviceConfig.getSessionConfig();
+        IoSessionConfig sessionConfig = wrapperManager.getSessionConfig();
         if( sessionConfig instanceof DatagramSessionConfig )
         {
             DatagramSessionConfig cfg = ( DatagramSessionConfig ) sessionConfig;
@@ -108,11 +103,6 @@
         return wrapperManager;
     }
 
-    public IoServiceConfig getServiceConfig()
-    {
-        return serviceConfig;
-    }
-
     public IoSessionConfig getConfig()
     {
         return config;
@@ -150,11 +140,7 @@
     
     protected void close0()
     {
-        IoServiceConfig config = getServiceConfig();
-        if( config instanceof DatagramServiceConfig )
-        {
-            ( ( DatagramServiceConfig ) config ).getSessionRecycler().remove( this );
-        }
+        managerDelegate.getSessionRecycler().remove( this );
         filterChain.fireFilterClose( this );
     }
 

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java Wed Oct 18 23:42:06 2006
@@ -21,17 +21,13 @@
 
 import java.io.IOException;
 import java.net.SocketAddress;
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 
 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.common.support.BaseIoSessionConfig;
 import org.apache.mina.transport.vmpipe.support.VmPipe;
 
@@ -47,80 +43,54 @@
     static final Map boundHandlers = new HashMap();
     
     private static final IoSessionConfig CONFIG = new BaseIoSessionConfig() {};
-    private final IoServiceConfig defaultConfig = new BaseIoAcceptorConfig()
-    {
-        public IoSessionConfig getSessionConfig()
-        {
-            return CONFIG;
-        }
-    };
 
-    public void bind( SocketAddress address, IoHandler handler, IoServiceConfig config ) throws IOException
+    /**
+     * Creates a new instance.
+     */
+    public VmPipeAcceptor()
     {
-        if( address == null )
-            throw new NullPointerException( "address" );
-        if( handler == null )
-            throw new NullPointerException( "handler" );
-        if( !( address instanceof VmPipeAddress ) )
-            throw new IllegalArgumentException(
-                    "address must be VmPipeAddress." );
+    }
 
-        if( config == null )
-        {
-            config = getDefaultConfig();
-        }
+    protected Class getAddressType()
+    {
+        return VmPipeAddress.class;
+    }
 
+    protected void doBind() throws IOException
+    {
         synchronized( boundHandlers )
         {
-            if( boundHandlers.containsKey( address ) )
+            if( boundHandlers.containsKey( getLocalAddress() ) )
             {
-                throw new IOException( "Address already bound: " + address );
+                throw new IOException( "Address already bound: " + getLocalAddress() );
             }
 
-            boundHandlers.put( address, 
+            boundHandlers.put( getLocalAddress(), 
                                new VmPipe( this,
-                                          ( VmPipeAddress ) address,
-                                          handler, config, getListeners() ) );
+                                          ( VmPipeAddress ) getLocalAddress(),
+                                          getHandler(), getListeners() ) );
         }
         
-        getListeners().fireServiceActivated( this, address, handler, config );
+        getListeners().fireServiceActivated();
     }
     
-    public void unbind( SocketAddress address )
+    protected void doUnbind()
     {
-        if( address == null )
-            throw new NullPointerException( "address" );
-
-        VmPipe pipe = null;
         synchronized( boundHandlers )
         {
-            if( !boundHandlers.containsKey( address ) )
-            {
-                throw new IllegalArgumentException( "Address not bound: " + address );
-            }
-            
-            pipe = ( VmPipe ) boundHandlers.remove( address );
+            boundHandlers.remove( getLocalAddress() );
         }
         
-        getListeners().fireServiceDeactivated(
-                this, pipe.getAddress(),
-                pipe.getHandler(), pipe.getConfig() );
+        getListeners().fireServiceDeactivated();
     }
-    
-    public void unbindAll()
+
+    public IoSessionConfig getSessionConfig()
     {
-        synchronized( boundHandlers )
-        {
-            List addresses = new ArrayList( boundHandlers.keySet() );
-            for( Iterator i = addresses.iterator(); i.hasNext(); )
-            {
-                unbind( ( SocketAddress ) i.next() );
-            }
-        }
+        return CONFIG;
     }
-    
-    public IoServiceConfig getDefaultConfig()
+
+    public IoSession newSession( SocketAddress remoteAddress )
     {
-        return defaultConfig;
+        throw new UnsupportedOperationException();
     }
 }

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java Wed Oct 18 23:42:06 2006
@@ -20,17 +20,14 @@
 package org.apache.mina.transport.vmpipe;
 
 import java.io.IOException;
-import java.net.SocketAddress;
 
 import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.ExceptionMonitor;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.common.IoSessionConfig;
 import org.apache.mina.common.support.AbstractIoFilterChain;
 import org.apache.mina.common.support.BaseIoConnector;
-import org.apache.mina.common.support.BaseIoConnectorConfig;
 import org.apache.mina.common.support.BaseIoSessionConfig;
 import org.apache.mina.common.support.DefaultConnectFuture;
 import org.apache.mina.transport.vmpipe.support.VmPipe;
@@ -48,13 +45,6 @@
 public class VmPipeConnector extends BaseIoConnector
 {
     private static final IoSessionConfig CONFIG = new BaseIoSessionConfig() {};
-    private final IoServiceConfig defaultConfig = new BaseIoConnectorConfig()
-    {
-        public IoSessionConfig getSessionConfig()
-        {
-            return CONFIG;
-        }
-    };
 
     /**
      * Creates a new instance.
@@ -63,42 +53,28 @@
     {
     }
 
-    public ConnectFuture connect( SocketAddress address, IoHandler handler, IoServiceConfig config )
+    protected Class getAddressType()
     {
-        return connect( address, null, handler, config );
+        return VmPipeAddress.class;
     }
 
-    public ConnectFuture connect( SocketAddress address, SocketAddress localAddress, IoHandler handler, IoServiceConfig config )
+    protected ConnectFuture doConnect()
     {
-        if( address == null )
-            throw new NullPointerException( "address" );
-        if( handler == null )
-            throw new NullPointerException( "handler" );
-        if( ! ( address instanceof VmPipeAddress ) )
-            throw new IllegalArgumentException(
-                                                "address must be VmPipeAddress." );
-
-        if( config == null )
-        {
-            config = getDefaultConfig();
-        }
-
-        VmPipe entry = ( VmPipe ) VmPipeAcceptor.boundHandlers.get( address );
+        VmPipe entry = ( VmPipe ) VmPipeAcceptor.boundHandlers.get( getRemoteAddress() );
         if( entry == null )
         {
             return DefaultConnectFuture.newFailedFuture(
-                    new IOException( "Endpoint unavailable: " + address ) );
+                    new IOException( "Endpoint unavailable: " + getRemoteAddress() ) );
         }
 
         DefaultConnectFuture future = new DefaultConnectFuture();
         VmPipeSessionImpl localSession =
             new VmPipeSessionImpl(
                     this,
-                    config,
                     getListeners(),
                     new Object(), // lock
                     new AnonymousSocketAddress(),
-                    handler,
+                    getHandler(),
                     entry );
         
         // initialize connector session
@@ -106,8 +82,7 @@
         {
             IoFilterChain filterChain = localSession.getFilterChain();
             this.getFilterChainBuilder().buildFilterChain( filterChain );
-            config.getFilterChainBuilder().buildFilterChain( filterChain );
-            config.getThreadModel().buildFilterChain( filterChain );
+            this.getThreadModel().buildFilterChain( filterChain );
 
             // The following sentences don't throw any exceptions.
             localSession.setAttribute( AbstractIoFilterChain.CONNECT_FUTURE, future );
@@ -125,8 +100,7 @@
         {
             IoFilterChain filterChain = remoteSession.getFilterChain();
             entry.getAcceptor().getFilterChainBuilder().buildFilterChain( filterChain );
-            entry.getConfig().getFilterChainBuilder().buildFilterChain( filterChain );
-            entry.getConfig().getThreadModel().buildFilterChain( filterChain );
+            entry.getAcceptor().getThreadModel().buildFilterChain( filterChain );
             
             // The following sentences don't throw any exceptions.
             entry.getListeners().fireSessionCreated( remoteSession );
@@ -140,9 +114,9 @@
 
         return future;
     }
-    
-    public IoServiceConfig getDefaultConfig()
+
+    public IoSessionConfig getSessionConfig()
     {
-        return defaultConfig;
+        return CONFIG;
     }
 }

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipe.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipe.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipe.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipe.java Wed Oct 18 23:42:06 2006
@@ -20,7 +20,6 @@
 package org.apache.mina.transport.vmpipe.support;
 
 import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.common.support.IoServiceListenerSupport;
 import org.apache.mina.transport.vmpipe.VmPipeAcceptor;
 import org.apache.mina.transport.vmpipe.VmPipeAddress;
@@ -34,19 +33,16 @@
     private final VmPipeAcceptor acceptor;
     private final VmPipeAddress address;
     private final IoHandler handler;
-    private final IoServiceConfig config;
     private final IoServiceListenerSupport listeners;
     
     public VmPipe( VmPipeAcceptor acceptor,
                    VmPipeAddress address,
                    IoHandler handler,
-                   IoServiceConfig config,
                    IoServiceListenerSupport listeners)
     {
         this.acceptor = acceptor;
         this.address = address;
         this.handler = handler;
-        this.config = config;
         this.listeners = listeners;
     }
 
@@ -63,11 +59,6 @@
     public IoHandler getHandler()
     {
         return handler;
-    }
-    
-    public IoServiceConfig getConfig()
-    {
-        return config;
     }
     
     public IoServiceListenerSupport getListeners()

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java Wed Oct 18 23:42:06 2006
@@ -24,7 +24,6 @@
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoService;
-import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoSessionConfig;
 import org.apache.mina.common.TransportType;
@@ -45,7 +44,6 @@
     private static final IoSessionConfig CONFIG = new BaseIoSessionConfig() {};
     
     private final IoService service;
-    private final IoServiceConfig serviceConfig;
     private final IoServiceListenerSupport serviceListeners;
     private final SocketAddress localAddress;
     private final SocketAddress remoteAddress;
@@ -60,12 +58,11 @@
      * Constructor for client-side session.
      */
     public VmPipeSessionImpl(
-            IoService service, IoServiceConfig serviceConfig,
+            IoService service,
             IoServiceListenerSupport serviceListeners, Object lock, SocketAddress localAddress,
             IoHandler handler, VmPipe remoteEntry )
     {
         this.service = service;
-        this.serviceConfig = serviceConfig;
         this.serviceListeners = serviceListeners;
         this.lock = lock;
         this.localAddress = localAddress;
@@ -83,7 +80,6 @@
     private VmPipeSessionImpl( VmPipeSessionImpl remoteSession, VmPipe entry )
     {
         this.service = entry.getAcceptor();
-        this.serviceConfig = entry.getConfig();
         this.serviceListeners = entry.getListeners();
         this.lock = remoteSession.lock;
         this.localAddress = this.serviceAddress = remoteSession.remoteAddress;
@@ -102,11 +98,6 @@
     IoServiceListenerSupport getServiceListeners()
     {
         return serviceListeners;
-    }
-    
-    public IoServiceConfig getServiceConfig()
-    {
-        return serviceConfig;
     }
     
     public IoSessionConfig getConfig()

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/common/IoFilterChainTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/common/IoFilterChainTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/common/IoFilterChainTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/common/IoFilterChainTest.java Wed Oct 18 23:42:06 2006
@@ -313,11 +313,6 @@
         public int getScheduledWriteBytes() {
             return 0;
         }
-
-        public IoServiceConfig getServiceConfig()
-        {
-            return null;
-        }
     }
 
     private class EventOrderTestFilter extends IoFilterAdapter
@@ -448,11 +443,6 @@
                 public int getScheduledWriteBytes()
                 {
                     return 0;
-                }
-
-                public IoServiceConfig getServiceConfig()
-                {
-                    return null;
                 }
             } );
         }

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/common/support/FutureTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/common/support/FutureTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/common/support/FutureTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/common/support/FutureTest.java Wed Oct 18 23:42:06 2006
@@ -28,7 +28,6 @@
 import org.apache.mina.common.IoFuture;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoService;
-import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoSessionConfig;
 import org.apache.mina.common.TransportType;
@@ -128,11 +127,6 @@
             public int getScheduledWriteBytes()
             {
                 return 0;
-            }
-
-            public IoServiceConfig getServiceConfig()
-            {
-                return null;
             }
         };
         

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/common/support/IoServiceListenerSupportTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/common/support/IoServiceListenerSupportTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/common/support/IoServiceListenerSupportTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/common/support/IoServiceListenerSupportTest.java Wed Oct 18 23:42:06 2006
@@ -26,12 +26,10 @@
 import junit.framework.TestCase;
 
 import org.apache.mina.common.IoAcceptor;
-import org.apache.mina.common.IoAcceptorConfig;
 import org.apache.mina.common.IoConnector;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoService;
-import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.common.IoServiceListener;
 import org.apache.mina.common.IoSessionConfig;
 import org.apache.mina.common.TransportType;
@@ -46,50 +44,46 @@
 public class IoServiceListenerSupportTest extends TestCase
 {
     private static final SocketAddress ADDRESS = new InetSocketAddress( 8080 );
+    
+    private final IoService mockService = ( IoService ) MockControl.createControl( IoService.class ).getMock();
 
     public void testServiceLifecycle() throws Exception
     {
-        IoServiceListenerSupport support = new IoServiceListenerSupport();
+        IoServiceListenerSupport support = new IoServiceListenerSupport( mockService );
     
         MockControl listenerControl = MockControl.createStrictControl( IoServiceListener.class );
         IoServiceListener listener = ( IoServiceListener ) listenerControl.getMock();
         
         // Test activation
-        listener.serviceActivated( null, ADDRESS, null, null );
+        listener.serviceActivated( mockService );
         
         listenerControl.replay();
         
         support.add( listener );
-        support.fireServiceActivated( null, ADDRESS, null, null );
+        support.fireServiceActivated();
         
         listenerControl.verify();
         
-        Assert.assertEquals( 1, support.getManagedServiceAddresses().size() );
-        Assert.assertTrue( support.getManagedServiceAddresses().contains( ADDRESS ) );
-        
         // Test deactivation & other side effects
         listenerControl.reset();
-        listener.serviceDeactivated( null, ADDRESS, null, null );
+        listener.serviceDeactivated( mockService );
 
         listenerControl.replay();
         //// Activate more than once
-        support.fireServiceActivated( null, ADDRESS, null, null );
+        support.fireServiceActivated();
         //// Deactivate
-        support.fireServiceDeactivated( null, ADDRESS, null, null );
+        support.fireServiceDeactivated();
         //// Deactivate more than once
-        support.fireServiceDeactivated( null, ADDRESS, null, null );
+        support.fireServiceDeactivated();
         
         listenerControl.verify();
-
-        Assert.assertEquals( 0, support.getManagedServiceAddresses().size() );
-        Assert.assertFalse( support.getManagedServiceAddresses().contains( ADDRESS ) );
     }
     
     public void testSessionLifecycle() throws Exception
     {
-        IoServiceListenerSupport support = new IoServiceListenerSupport();
+        IoServiceListenerSupport support = new IoServiceListenerSupport( mockService );
     
-        TestSession session = new TestSession( ADDRESS );
+        TestSession session = new TestSession( mockService, ADDRESS );
         
         MockControl chainControl = MockControl.createStrictControl( IoFilterChain.class );
         IoFilterChain chain = ( IoFilterChain ) chainControl.getMock();
@@ -112,8 +106,8 @@
         listenerControl.verify();
         chainControl.verify();
         
-        Assert.assertEquals( 1, support.getManagedSessions( ADDRESS ).size() );
-        Assert.assertTrue( support.getManagedSessions( ADDRESS ).contains( session ) );
+        Assert.assertEquals( 1, support.getManagedSessions().size() );
+        Assert.assertTrue( support.getManagedSessions().contains( session ) );
         
         // Test destruction & other side effects
         listenerControl.reset();
@@ -132,22 +126,19 @@
         listenerControl.verify();
 
         Assert.assertFalse( session.isClosing() );
-        Assert.assertEquals( 0, support.getManagedSessions( ADDRESS ).size() );
-        Assert.assertFalse( support.getManagedSessions( ADDRESS ).contains( session ) );
+        Assert.assertEquals( 0, support.getManagedSessions().size() );
+        Assert.assertFalse( support.getManagedSessions().contains( session ) );
     }
     
     public void testDisconnectOnUnbind() throws Exception
     {
-        final IoServiceListenerSupport support = new IoServiceListenerSupport();
-    
         MockControl acceptorControl = MockControl.createStrictControl( IoAcceptor.class );
         IoAcceptor acceptor = ( IoAcceptor ) acceptorControl.getMock();
 
+        final IoServiceListenerSupport support = new IoServiceListenerSupport( acceptor );
+        
         final TestSession session = new TestSession( acceptor, ADDRESS );
 
-        MockControl configControl = MockControl.createStrictControl( IoAcceptorConfig.class );
-        IoAcceptorConfig config = ( IoAcceptorConfig ) configControl.getMock();
-
         MockControl chainControl = MockControl.createStrictControl( IoFilterChain.class );
         IoFilterChain chain = ( IoFilterChain ) chainControl.getMock();
         session.setFilterChain( chain );
@@ -156,7 +147,7 @@
         IoServiceListener listener = ( IoServiceListener ) listenerControl.getMock();
         
         // Activate a service and create a session.
-        listener.serviceActivated( acceptor, ADDRESS, null, config );
+        listener.serviceActivated( acceptor );
         listener.sessionCreated( session );
         chain.fireSessionCreated( session );
         chain.fireSessionOpened( session );
@@ -165,7 +156,7 @@
         chainControl.replay();
         
         support.add( listener );
-        support.fireServiceActivated( acceptor, ADDRESS, null, config );
+        support.fireServiceActivated();
         support.fireSessionCreated( session );
         
         listenerControl.verify();
@@ -175,13 +166,13 @@
         listenerControl.reset();
         chainControl.reset();
 
-        listener.serviceDeactivated( acceptor, ADDRESS, null, config );
-        configControl.expectAndReturn(config.isDisconnectOnUnbind(), true );
+        listener.serviceDeactivated( acceptor );
+        acceptorControl.expectAndReturn(acceptor.isDisconnectOnUnbind(), true );
         listener.sessionDestroyed( session );
         chain.fireSessionClosed( session );
 
         listenerControl.replay();
-        configControl.replay();
+        acceptorControl.replay();
         chainControl.replay();
 
         new Thread()
@@ -200,24 +191,24 @@
                 support.fireSessionDestroyed( session );
             }
         }.start();
-        support.fireServiceDeactivated( acceptor, ADDRESS, null, config );
+        support.fireServiceDeactivated();
         
         listenerControl.verify();
-        configControl.verify();
+        acceptorControl.verify();
         chainControl.verify();
 
         Assert.assertTrue( session.isClosing() );
-        Assert.assertEquals( 0, support.getManagedSessions( ADDRESS ).size() );
-        Assert.assertFalse( support.getManagedSessions( ADDRESS ).contains( session ) );
+        Assert.assertEquals( 0, support.getManagedSessions().size() );
+        Assert.assertFalse( support.getManagedSessions().contains( session ) );
     }
     
     public void testConnectorActivation() throws Exception
     {
-        IoServiceListenerSupport support = new IoServiceListenerSupport();
-    
         MockControl connectorControl = MockControl.createStrictControl( IoConnector.class );
         IoConnector connector = ( IoConnector ) connectorControl.getMock();
 
+        IoServiceListenerSupport support = new IoServiceListenerSupport( connector );
+        
         final TestSession session = new TestSession( connector, ADDRESS );
 
         MockControl chainControl = MockControl.createStrictControl( IoFilterChain.class );
@@ -228,7 +219,7 @@
         IoServiceListener listener = ( IoServiceListener ) listenerControl.getMock();
         
         // Creating a session should activate a service automatically.
-        listener.serviceActivated( connector, ADDRESS, null, null );
+        listener.serviceActivated( connector );
         listener.sessionCreated( session );
         chain.fireSessionCreated( session );
         chain.fireSessionOpened( session );
@@ -247,7 +238,7 @@
         chainControl.reset();
         listener.sessionDestroyed( session );
         chain.fireSessionClosed( session );
-        listener.serviceDeactivated( connector, ADDRESS, null, null );
+        listener.serviceDeactivated( connector );
         
         listenerControl.replay();
         chainControl.replay();
@@ -257,8 +248,8 @@
         listenerControl.verify();
         chainControl.verify();
 
-        Assert.assertEquals( 0, support.getManagedSessions( ADDRESS ).size() );
-        Assert.assertFalse( support.getManagedSessions( ADDRESS ).contains( session ) );
+        Assert.assertEquals( 0, support.getManagedSessions().size() );
+        Assert.assertFalse( support.getManagedSessions().contains( session ) );
     }
     
     private static class TestSession extends BaseIoSession
@@ -330,11 +321,6 @@
         public SocketAddress getServiceAddress()
         {
             return serviceAddress;
-        }
-
-        public IoServiceConfig getServiceConfig()
-        {
-            return null;
         }
 
         public TransportType getTransportType()

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/filter/StreamWriteFilterTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/filter/StreamWriteFilterTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/filter/StreamWriteFilterTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/filter/StreamWriteFilterTest.java Wed Oct 18 23:42:06 2006
@@ -31,8 +31,6 @@
 
 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.IoFutureListener;
 import org.apache.mina.common.IoHandlerAdapter;
 import org.apache.mina.common.IoSession;
@@ -41,7 +39,6 @@
 import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.common.support.DefaultWriteFuture;
 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.apache.mina.util.Queue;
@@ -379,31 +376,37 @@
     
     public void testWriteUsingSocketTransport() throws Exception
     {
-        IoAcceptor acceptor = new SocketAcceptor();
-        ( ( SocketAcceptorConfig ) acceptor.getDefaultConfig() ).setReuseAddress( true );
+        SocketAcceptor acceptor = new SocketAcceptor();
+        acceptor.setReuseAddress( true );
         SocketAddress address = new InetSocketAddress( "localhost", AvailablePortFinder.getNextAvailable() );
 
-        IoConnector connector = new SocketConnector();
+        SocketConnector connector = new SocketConnector();
         
         FixedRandomInputStream stream = new FixedRandomInputStream( 4 * 1024 * 1024 );
         
         SenderHandler sender = new SenderHandler( stream );
         ReceiverHandler receiver = new ReceiverHandler( stream.size );
         
-        acceptor.bind( address, sender );
+        acceptor.setLocalAddress( address );
+        acceptor.setHandler( sender );
+        
+        connector.setRemoteAddress( address );
+        connector.setHandler( receiver );
+
+        acceptor.bind();
         
         synchronized( sender.lock )
         {
             synchronized( receiver.lock )
             {
-                connector.connect( address, receiver );
+                connector.connect();
                 
                 sender.lock.wait();
                 receiver.lock.wait();
             }
         }
         
-        acceptor.unbind( address );
+        acceptor.unbind();
         
         assertEquals( stream.bytesRead, receiver.bytesRead );
         assertEquals( stream.size, receiver.bytesRead );

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java Wed Oct 18 23:42:06 2006
@@ -30,9 +30,8 @@
 import org.apache.mina.common.CloseFuture;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoServiceConfig;
-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.support.BaseIoSession;
@@ -228,11 +227,6 @@
         }
 
         public IoService getService()
-        {
-            return null;
-        }
-
-        public IoServiceConfig getServiceConfig()
         {
             return null;
         }

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineDecoderTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineDecoderTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineDecoderTest.java Wed Oct 18 23:42:06 2006
@@ -30,7 +30,6 @@
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoService;
-import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoSessionConfig;
 import org.apache.mina.common.TransportType;
@@ -193,11 +192,6 @@
             return null;
         }
         
-        public IoServiceConfig getServiceConfig()
-        {
-            return null;
-        }
-
         public IoHandler getHandler()
         {
             return null;

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineEncoderTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineEncoderTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/filter/codec/textline/TextLineEncoderTest.java Wed Oct 18 23:42:06 2006
@@ -28,9 +28,8 @@
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoServiceConfig;
-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.WriteFuture;
@@ -82,11 +81,6 @@
         }
 
         public IoService getService()
-        {
-            return null;
-        }
-
-        public IoServiceConfig getServiceConfig()
         {
             return null;
         }

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/filter/executor/ExecutorFilterRegressionTest.java Wed Oct 18 23:42:06 2006
@@ -29,7 +29,6 @@
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoService;
-import org.apache.mina.common.IoServiceConfig;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoSessionConfig;
 import org.apache.mina.common.TransportType;
@@ -162,11 +161,6 @@
         }
 
         public IoService getService()
-        {
-            return null;
-        }
-
-        public IoServiceConfig getServiceConfig()
         {
             return null;
         }

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/handler/chain/ChainedIoHandlerTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/handler/chain/ChainedIoHandlerTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/handler/chain/ChainedIoHandlerTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/handler/chain/ChainedIoHandlerTest.java Wed Oct 18 23:42:06 2006
@@ -26,9 +26,8 @@
 
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoServiceConfig;
-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.support.BaseIoSession;
@@ -62,11 +61,6 @@
                     }
 
                     public IoService getService()
-                    {
-                        return null;
-                    }
-
-                    public IoServiceConfig getServiceConfig()
                     {
                         return null;
                     }

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/transport/AbstractBindTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/transport/AbstractBindTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/transport/AbstractBindTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/transport/AbstractBindTest.java Wed Oct 18 23:42:06 2006
@@ -34,7 +34,6 @@
 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.SocketAcceptorConfig;
 import org.apache.mina.transport.socket.nio.SocketSessionConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -59,6 +58,8 @@
     
     protected void bind( boolean reuseAddress ) throws IOException
     {
+        acceptor.setHandler( new EchoProtocolHandler() );
+
         setReuseAddress( reuseAddress );
 
         // Find an availble test port and bind to it.
@@ -72,8 +73,8 @@
             socketBound = false;
             try
             {
-                acceptor.bind( createSocketAddress( port ),
-                        new EchoProtocolHandler() );
+                acceptor.setLocalAddress( createSocketAddress( port ) );
+                acceptor.bind();
                 socketBound = true;
                 break;
             }
@@ -95,11 +96,11 @@
     {
         if( acceptor instanceof DatagramAcceptor )
         {
-            ( ( DatagramSessionConfig ) acceptor.getDefaultConfig().getSessionConfig() ).setReuseAddress( reuseAddress );
+            ( ( DatagramSessionConfig ) acceptor.getSessionConfig() ).setReuseAddress( reuseAddress );
         }
         else if( acceptor instanceof SocketAcceptor )
         {
-            ( ( SocketAcceptorConfig ) acceptor.getDefaultConfig() ).setReuseAddress( reuseAddress );
+            ( ( SocketAcceptor ) acceptor ).setReuseAddress( reuseAddress );
         }
     }
     
@@ -107,7 +108,7 @@
     {
         try
         {
-            acceptor.unbind( createSocketAddress( port ) );
+            acceptor.unbind();
         }
         catch( Exception e )
         {
@@ -121,10 +122,10 @@
         
         try
         {
-            acceptor.bind( createSocketAddress( port ), new EchoProtocolHandler() );
-            Assert.fail( "IOException is not thrown" );
+            acceptor.bind();
+            Assert.fail( "IllegalStateException is not thrown" );
         }
-        catch( IOException e )
+        catch( IllegalStateException e )
         {
         }
     }
@@ -134,29 +135,20 @@
         bind( false );
         
         // this should succeed
-        acceptor.unbind( createSocketAddress( port ) );
+        acceptor.unbind();
         
-        try
-        {
-            // this should fail
-            acceptor.unbind( createSocketAddress( port ) );
-            Assert.fail( "Exception is not thrown" );
-        }
-        catch( Exception e )
-        {
-        }
+        // this shouldn't fail
+        acceptor.unbind();
     }
     
     public void testManyTimes() throws IOException
     {
         bind( true );
         
-        SocketAddress addr = createSocketAddress( port );
-        EchoProtocolHandler handler = new EchoProtocolHandler();
         for( int i = 0; i < 1024; i++ ) 
         {
-            acceptor.unbind( addr );
-            acceptor.bind( addr, handler );
+            acceptor.unbind();
+            acceptor.bind();
         }
     }
     
@@ -166,9 +158,11 @@
 
         SocketAddress addr = createSocketAddress( port );
         EchoProtocolHandler handler = new EchoProtocolHandler();
+        acceptor.setLocalAddress( addr );
+        acceptor.setHandler( handler );
         for( int i = 0; i < 1048576; i++ )
         {
-            acceptor.bind( addr, handler );
+            acceptor.bind();
             testDuplicateBind();
             testDuplicateUnbind();
             if( i % 100 == 0 )

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/transport/AbstractConnectorTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/transport/AbstractConnectorTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/transport/AbstractConnectorTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/transport/AbstractConnectorTest.java Wed Oct 18 23:42:06 2006
@@ -47,32 +47,33 @@
     {
         int port = AvailablePortFinder.getNextAvailable( 1025 );
         IoAcceptor acceptor = createAcceptor();
-        acceptor.bind( new InetSocketAddress( port ), new IoHandlerAdapter() );
+        acceptor.setLocalAddress( new InetSocketAddress( port ) );
+        acceptor.setHandler( new IoHandlerAdapter() );
+        acceptor.bind();
         
         try
         {
             final StringBuffer buf = new StringBuffer();
             IoConnector connector = createConnector();
-            ConnectFuture future = connector.connect(
-                    new InetSocketAddress( "localhost", port ),
-                    new IoHandlerAdapter()
-                    {
-                        public void sessionCreated( IoSession session )
-                        {
-                            buf.append( "1" );
-                        }
-                        
-                        public void sessionOpened( IoSession session )
-                        {
-                            buf.append( "2" );
-                        }
-                        
-                        public void exceptionCaught( IoSession session, Throwable cause )
-                        {
-                            buf.append( "X" );
-                        }
-                    });
-            
+            connector.setRemoteAddress( new InetSocketAddress( "localhost", port ) );
+            connector.setHandler( new IoHandlerAdapter()
+            {
+                public void sessionCreated( IoSession session )
+                {
+                    buf.append( "1" );
+                }
+                
+                public void sessionOpened( IoSession session )
+                {
+                    buf.append( "2" );
+                }
+                
+                public void exceptionCaught( IoSession session, Throwable cause )
+                {
+                    buf.append( "X" );
+                }
+            });
+            ConnectFuture future = connector.connect();
             future.join();
             buf.append("3");
             future.getSession().close();
@@ -80,7 +81,7 @@
         }
         finally
         {
-            acceptor.unbind( new InetSocketAddress( port ) );
+            acceptor.unbind();
         }
     }
 
@@ -90,26 +91,25 @@
         final StringBuffer buf = new StringBuffer();
 
         IoConnector connector = createConnector();
-        ConnectFuture future = connector.connect(
-                new InetSocketAddress( "localhost", port ),
-                new IoHandlerAdapter()
-                {
-                    public void sessionCreated( IoSession session )
-                    {
-                        buf.append( "X" );
-                    }
-                    
-                    public void sessionOpened( IoSession session )
-                    {
-                        buf.append( "Y" );
-                    }
-                    
-                    public void exceptionCaught( IoSession session, Throwable cause )
-                    {
-                        buf.append( "Z" );
-                    }
-                });
-        
+        connector.setRemoteAddress( new InetSocketAddress( "localhost", port ) );
+        connector.setHandler( new IoHandlerAdapter()
+        {
+            public void sessionCreated( IoSession session )
+            {
+                buf.append( "X" );
+            }
+            
+            public void sessionOpened( IoSession session )
+            {
+                buf.append( "Y" );
+            }
+            
+            public void exceptionCaught( IoSession session, Throwable cause )
+            {
+                buf.append( "Z" );
+            }
+        });
+        ConnectFuture future = connector.connect();
         future.join();
         buf.append("1");
         try

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/transport/AbstractTrafficControlTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/transport/AbstractTrafficControlTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/transport/AbstractTrafficControlTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/transport/AbstractTrafficControlTest.java Wed Oct 18 23:42:06 2006
@@ -55,17 +55,16 @@
         super.setUp();
         
         port = AvailablePortFinder.getNextAvailable();
-        
-        acceptor.bind( createServerSocketAddress( port ), 
-                       new ServerIoHandler() );
-        
+        acceptor.setLocalAddress( createServerSocketAddress( port ) );
+        acceptor.setHandler( new ServerIoHandler() );
+        acceptor.bind();
     }
 
     protected void tearDown() throws Exception
     {
         super.tearDown();
         
-        acceptor.unbind( createServerSocketAddress( port ) );
+        acceptor.unbind();
     }
 
     protected abstract ConnectFuture connect( int port, IoHandler handler) throws Exception;

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramConfigTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramConfigTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramConfigTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramConfigTest.java Wed Oct 18 23:42:06 2006
@@ -45,31 +45,36 @@
 public class DatagramConfigTest extends TestCase
 {
     private final IoAcceptor acceptor = new DatagramAcceptor();
+
     private final IoConnector connector = new DatagramConnector();
+
     private String result;
 
     public DatagramConfigTest()
     {
     }
-    
+
     protected void setUp() throws Exception
     {
         result = "";
     }
-    
+
     public void testAcceptorFilterChain() throws Exception
     {
         int port = AvailablePortFinder.getNextAvailable( 1024 );
-        DatagramAcceptorConfig expectedConfig = new DatagramAcceptorConfig();
         IoFilter mockFilter = new MockFilter();
         IoHandler mockHandler = new MockHandler();
         
-        expectedConfig.getFilterChain().addLast( "mock", mockFilter );
-        acceptor.bind( new InetSocketAddress( port ), mockHandler, expectedConfig );
+        acceptor.getFilterChain().addLast( "mock", mockFilter );
+        acceptor.setLocalAddress( new InetSocketAddress( port ) );
+        acceptor.setHandler( mockHandler );
+        acceptor.bind();
         
         try
         {
-            ConnectFuture future = connector.connect( new InetSocketAddress( "localhost", port ), new IoHandlerAdapter() );
+            connector.setRemoteAddress( new InetSocketAddress( "localhost", port ) );
+            connector.setHandler( new IoHandlerAdapter() );
+            ConnectFuture future = connector.connect();
             future.join();
             
             WriteFuture writeFuture = future.getSession().write( ByteBuffer.allocate( 16 ).putInt( 0 ).flip() );
@@ -91,24 +96,26 @@
         }
         finally
         {
-            acceptor.unbind( new InetSocketAddress( port ) );
+            acceptor.unbind();
         }
     }
-    
+
     private class MockFilter extends IoFilterAdapter
     {
 
-        public void messageReceived( NextFilter nextFilter, IoSession session, Object message ) throws Exception
+        public void messageReceived( NextFilter nextFilter, IoSession session,
+                Object message ) throws Exception
         {
             result += "F";
             nextFilter.messageReceived( session, message );
         }
-        
+
     }
-    
+
     private class MockHandler extends IoHandlerAdapter
     {
-        public void messageReceived( IoSession session, Object message ) throws Exception
+        public void messageReceived( IoSession session, Object message )
+                throws Exception
         {
             result += "H";
         }

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramRecyclerTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramRecyclerTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramRecyclerTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramRecyclerTest.java Wed Oct 18 23:42:06 2006
@@ -28,8 +28,6 @@
 import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.ExpiringSessionRecycler;
 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.util.AvailablePortFinder;
@@ -42,8 +40,8 @@
  */
 public class DatagramRecyclerTest extends TestCase
 {
-    private final IoAcceptor acceptor = new DatagramAcceptor();
-    private final IoConnector connector = new DatagramConnector();
+    private final DatagramAcceptor acceptor = new DatagramAcceptor();
+    private final DatagramConnector connector = new DatagramConnector();
 
     public DatagramRecyclerTest()
     {
@@ -52,19 +50,22 @@
     public void testDatagramRecycler() throws Exception
     {
         int port = AvailablePortFinder.getNextAvailable( 1024 );
-        DatagramAcceptorConfig config = new DatagramAcceptorConfig();
         ExpiringSessionRecycler recycler = new ExpiringSessionRecycler( 1, 1 );
-        config.setSessionRecycler( recycler );
         
         MockHandler acceptorHandler = new MockHandler();
         MockHandler connectorHandler = new MockHandler();
         
-        acceptor.bind( new InetSocketAddress( port ), acceptorHandler, config );
+        acceptor.setLocalAddress( new InetSocketAddress( port ) );
+        acceptor.setHandler( acceptorHandler );
+        acceptor.setSessionRecycler( recycler );
+        acceptor.bind();
         
         try
         {
-            ConnectFuture future = connector.connect(
-                    new InetSocketAddress( "localhost", port ), connectorHandler, config );
+            connector.setRemoteAddress( new InetSocketAddress( "localhost", port ) );
+            connector.setHandler( connectorHandler );
+            connector.setSessionRecycler( recycler );
+            ConnectFuture future = connector.connect();
             future.join();
             
             // Write whatever to trigger the acceptor.
@@ -83,7 +84,7 @@
         }
         finally
         {
-            acceptor.unbind( new InetSocketAddress( port ) );
+            acceptor.unbind();
         }
     }
     

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramTrafficControlTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramTrafficControlTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramTrafficControlTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/DatagramTrafficControlTest.java Wed Oct 18 23:42:06 2006
@@ -47,7 +47,9 @@
     {
         IoConnector connector = new DatagramConnector();
         SocketAddress addr = new InetSocketAddress( "localhost", port );
-        return connector.connect( addr, handler );
+        connector.setRemoteAddress( addr );
+        connector.setHandler( handler );
+        return connector.connect();
     }
 
     protected SocketAddress createServerSocketAddress( int port )

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/SocketBindTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/SocketBindTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/SocketBindTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/SocketBindTest.java Wed Oct 18 23:42:06 2006
@@ -55,13 +55,13 @@
         // TODO: This test is almost identical to the test with the same name in VmPipeBindTest
         bind( false );
         
-        SocketAddress addr = createSocketAddress( port );
-     
         IoConnector connector = new SocketConnector();
         IoSession[] sessions = new IoSession[ 5 ];
+        connector.setRemoteAddress( new InetSocketAddress( "localhost", port ) );
+        connector.setHandler( new IoHandlerAdapter() );
         for( int i = 0; i < sessions.length; i++ )
         {
-            ConnectFuture future = connector.connect( new InetSocketAddress( "localhost", port ), new IoHandlerAdapter() );
+            ConnectFuture future = connector.connect();
             future.join();
             sessions[ i ] = future.getSession();
             Assert.assertTrue( sessions[ i ].isConnected() );
@@ -70,10 +70,10 @@
         // Wait for the server side sessions to be created.
         Thread.sleep( 500 );
         
-        Collection managedSessions = acceptor.getManagedSessions( addr );
+        Collection managedSessions = acceptor.getManagedSessions();
         Assert.assertEquals( 5, managedSessions.size() );
         
-        acceptor.unbind( addr );
+        acceptor.unbind();
         
         // Wait for the client side sessions to close.
         Thread.sleep( 500 );

Modified: directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/SocketTrafficControlTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/SocketTrafficControlTest.java?view=diff&rev=465510&r1=465509&r2=465510
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/SocketTrafficControlTest.java (original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/transport/socket/nio/SocketTrafficControlTest.java Wed Oct 18 23:42:06 2006
@@ -47,7 +47,9 @@
     {
         IoConnector connector = new SocketConnector();
         SocketAddress addr = new InetSocketAddress( "localhost", port );
-        return connector.connect( addr, handler );
+        connector.setRemoteAddress( addr );
+        connector.setHandler( handler );
+        return connector.connect();
     }
 
     protected SocketAddress createServerSocketAddress( int port )



Mime
View raw message