directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r349659 [1/2] - in /directory/network/branches/chain_refactor: ./ src/examples/org/apache/mina/examples/sumup/ src/examples/org/apache/mina/examples/sumup/codec/ src/examples/org/apache/mina/examples/sumup/message/ src/java/org/apache/mina/...
Date Tue, 29 Nov 2005 07:20:34 GMT
Author: trustin
Date: Mon Nov 28 23:19:46 2005
New Revision: 349659

URL: http://svn.apache.org/viewcvs?rev=349659&view=rev
Log:
Branching to refactor IoFilterChain

Added:
    directory/network/branches/chain_refactor/
      - copied from r349561, directory/network/trunk/
    directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/Client.java
      - copied unchanged from r349650, directory/network/trunk/src/examples/org/apache/mina/examples/sumup/Client.java
    directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java
      - copied unchanged from r349650, directory/network/trunk/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java
    directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/Server.java
      - copied unchanged from r349650, directory/network/trunk/src/examples/org/apache/mina/examples/sumup/Server.java
    directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/ServerSessionHandler.java
      - copied unchanged from r349650, directory/network/trunk/src/examples/org/apache/mina/examples/sumup/ServerSessionHandler.java
    directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/codec/AbstractMessageDecoder.java
      - copied unchanged from r349650, directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AbstractMessageDecoder.java
    directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/codec/AbstractMessageEncoder.java
      - copied unchanged from r349650, directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AbstractMessageEncoder.java
    directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/codec/AddMessageDecoder.java
      - copied unchanged from r349650, directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AddMessageDecoder.java
    directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/codec/AddMessageEncoder.java
      - copied unchanged from r349650, directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AddMessageEncoder.java
    directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/codec/ResultMessageDecoder.java
      - copied unchanged from r349650, directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/ResultMessageDecoder.java
    directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/codec/ResultMessageEncoder.java
      - copied unchanged from r349650, directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/ResultMessageEncoder.java
    directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/codec/SumUpProtocolCodecFactory.java
      - copied unchanged from r349650, directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/SumUpProtocolCodecFactory.java
    directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/message/AbstractMessage.java
      - copied unchanged from r349650, directory/network/trunk/src/examples/org/apache/mina/examples/sumup/message/AbstractMessage.java
    directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/message/AddMessage.java
      - copied unchanged from r349650, directory/network/trunk/src/examples/org/apache/mina/examples/sumup/message/AddMessage.java
    directory/network/branches/chain_refactor/src/examples/org/apache/mina/examples/sumup/message/ResultMessage.java
      - copied unchanged from r349650, directory/network/trunk/src/examples/org/apache/mina/examples/sumup/message/ResultMessage.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/ByteBuffer.java
      - copied unchanged from r349617, directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoFilterChainBuilder.java   (with props)
    directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/codec/demux/
      - copied from r349650, directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/
    directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/codec/serialization/
      - copied from r349650, directory/network/trunk/src/java/org/apache/mina/filter/codec/serialization/
    directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/support/SSLHandler.java
      - copied unchanged from r349583, directory/network/trunk/src/java/org/apache/mina/filter/support/SSLHandler.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramFilterChain.java
      - copied, changed from r349561, directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionManagerFilterChain.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketFilterChain.java
      - copied, changed from r349561, directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionManagerFilterChain.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/support/VmPipeFilterChain.java
      - copied, changed from r349561, directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionManagerFilterChain.java
Removed:
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/IoSessionFilterChain.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/IoSessionManagerFilterChain.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/codec/DemuxingProtocolCodecFactory.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/codec/MessageDecoder.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/codec/MessageDecoderFactory.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/codec/MessageDecoderResult.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/codec/MessageEncoder.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/codec/MessageEncoderFactory.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionManagerFilterChain.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionManagerFilterChain.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionManagerFilterChain.java
Modified:
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoAcceptor.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoConnector.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoFilterChain.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoSession.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoSessionManager.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/AbstractIoFilterChain.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoAcceptor.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoConnector.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoSession.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoSessionManager.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoAcceptor.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoConnector.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/SSLFilter.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketConnectorDelegate.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketIoProcessor.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/support/VmPipe.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/support/VmPipeIdleStatusChecker.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoAcceptor.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoAcceptor.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoAcceptor.java Mon Nov 28 23:19:46 2005
@@ -51,6 +51,15 @@
     void bind( SocketAddress address, IoHandler handler ) throws IOException;
 
     /**
+     * TODO Revise documentation
+     * Binds to the specified <code>address</code> and handles incoming
+     * connections with the specified <code>handler</code>.
+     * 
+     * @throws IOException if failed to bind
+     */
+    void bind( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder ) throws IOException;
+
+    /**
      * Unbinds from the specified <code>address</code> and disconnects all clients
      * connected there.
      */

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoConnector.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoConnector.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoConnector.java Mon Nov 28 23:19:46 2005
@@ -51,6 +51,17 @@
      */
     ConnectFuture connect( SocketAddress address, IoHandler handler )
             throws IOException;
+    
+    /**
+     * TODO revise documentation 
+     * Connects to the specified <code>address</code>.  If communication starts
+     * successfully, events are fired to the specified
+     * <code>handler</code>.
+     * 
+     * @throws IOException if failed to connect
+     */
+    ConnectFuture connect( SocketAddress address, IoHandler handler,
+                           IoFilterChainBuilder filterChainBuilder ) throws IOException;
 
     /**
      * Connects to the specified <code>address</code>.  If communication starts
@@ -63,6 +74,17 @@
     ConnectFuture connect( SocketAddress address, SocketAddress localAddress,
                            IoHandler handler ) throws IOException;
 
+    /**
+     * TODO revise documentation
+     * Connects to the specified <code>address</code>.  If communication starts
+     * successfully, events are fired to the specified
+     * <code>handler</code>.
+     * 
+     * @throws IOException if failed to connect
+     */
+    ConnectFuture connect( SocketAddress address, SocketAddress localAddress,
+                           IoHandler handler, IoFilterChainBuilder filterChainBuilder ) throws IOException;
+    
     /**
      * Returns the connect timeout in seconds.
      */

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoFilterChain.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoFilterChain.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoFilterChain.java Mon Nov 28 23:19:46 2005
@@ -31,10 +31,10 @@
  */
 public interface IoFilterChain {
     /**
-     * Returns the parent of this chain.
-     * @return {@link IoSessionManager} or {@link IoSession}
+     * Returns the parent {@link IoSession} of this chain.
+     * @return {@link IoSession}
      */
-    Object getParent();
+    IoSession getSession();
     
     /**
      * Returns the {@link IoFilter} with the specified <tt>name</tt> in this chain.

Added: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoFilterChainBuilder.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoFilterChainBuilder.java?rev=349659&view=auto
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoFilterChainBuilder.java (added)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoFilterChainBuilder.java Mon Nov 28 23:19:46 2005
@@ -0,0 +1,53 @@
+/*
+ *   @(#) $Id$
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.mina.common;
+
+/**
+ * An interface that builds {@link IoFilterChain} in predefined way
+ * when {@link IoSession} is created.  You can extract common filter chain
+ * modification logic to this interface.  For example, to add a filter
+ * to the chain,
+ * <pre>
+ * public class MyFilterChainBuilder implements IoFilterChainBuilder {
+ *     public void buildFilterChain( IoFilterChain chain ) throws Exception {
+ *         chain.addLast( "myFilter", new MyFilter() );
+ *     }
+ * }
+ * </pre>
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public interface IoFilterChainBuilder
+{
+    /**
+     * An implementation which does nothing.
+     */
+    IoFilterChainBuilder NOOP = new IoFilterChainBuilder()
+    {
+        public void buildFilterChain( IoFilterChain chain ) throws Exception
+        {
+        }
+    };
+    
+    /**
+     * Modifies the specified <tt>chain</tt>.
+     */
+    void buildFilterChain( IoFilterChain chain ) throws Exception;
+}

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

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoSession.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoSession.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoSession.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoSession.java Mon Nov 28 23:19:46 2005
@@ -39,6 +39,11 @@
  * @version $Rev$, $Date$
  */
 public interface IoSession {
+    
+    /**
+     * Returns the {@link IoSessionManager} which manages this session.
+     */
+    IoSessionManager getManager();
 
     /**
      * Returns the {@link IoHandler} which handles this session.

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoSessionManager.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoSessionManager.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoSessionManager.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/IoSessionManager.java Mon Nov 28 23:19:46 2005
@@ -34,10 +34,19 @@
 public interface IoSessionManager {
     
     /**
-     * Returns the filter chain that filters all events which is related
-     * with sessions this manager manages.
+     * Returns the {@link IoFilterChain} which will affect the {@link IoFilterChain}
+     * of all {@link IoSession}s which is managed by this manager.
+     * The default value is {@link IoFilterChainBuilder#NOOP}.
      */
-    IoFilterChain getFilterChain();
+    IoFilterChainBuilder getFilterChainBuilder();
+    
+    /**
+     * Sets the {@link IoFilterChain} which will affect the {@link IoFilterChain}
+     * of all {@link IoSession}s which is managed by this manager.
+     * If you specify <tt>null</tt> this property will be set to
+     * {@link IoFilterChainBuilder#NOOP}.
+     */
+    void setFilterChainBuilder( IoFilterChainBuilder builder );
     
     /**
      * Returns the current exception monitor.

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/AbstractIoFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/AbstractIoFilterChain.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/AbstractIoFilterChain.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/AbstractIoFilterChain.java Mon Nov 28 23:19:46 2005
@@ -50,7 +50,7 @@
  */
 public abstract class AbstractIoFilterChain implements IoFilterChain
 {
-    private final Object parent;
+    private final IoSession parent;
 
     private final Map name2entry = new HashMap();
     private final Map filter2entry = new IdentityHashMap();
@@ -58,7 +58,7 @@
     private final Entry head;
     private final Entry tail;
 
-    protected AbstractIoFilterChain( Object parent )
+    protected AbstractIoFilterChain( IoSession parent )
     {
         if( parent == null )
         {
@@ -236,7 +236,7 @@
         };
     }
     
-    public Object getParent()
+    public IoSession getSession()
     {
         return parent;
     }

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoAcceptor.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoAcceptor.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoAcceptor.java Mon Nov 28 23:19:46 2005
@@ -18,9 +18,12 @@
  */
 package org.apache.mina.common.support;
 
+import java.io.IOException;
 import java.net.SocketAddress;
 
 import org.apache.mina.common.IoAcceptor;
+import org.apache.mina.common.IoFilterChainBuilder;
+import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoSession;
 
 /**
@@ -39,6 +42,11 @@
     {
     }
     
+    public void bind( SocketAddress address, IoHandler handler ) throws IOException
+    {
+        this.bind( address, handler, IoFilterChainBuilder.NOOP );
+    }
+
     /* TODO: DIRMINA-93
     public boolean isDisconnectClientsOnUnbind()
     {

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoConnector.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoConnector.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoConnector.java Mon Nov 28 23:19:46 2005
@@ -18,7 +18,13 @@
  */
 package org.apache.mina.common.support;
 
+import java.io.IOException;
+import java.net.SocketAddress;
+
+import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.IoConnector;
+import org.apache.mina.common.IoFilterChainBuilder;
+import org.apache.mina.common.IoHandler;
 
 /**
  * A base implementation of {@link IoConnector}.
@@ -34,6 +40,16 @@
     {
     }
     
+    public ConnectFuture connect( SocketAddress address, IoHandler handler ) throws IOException
+    {
+        return connect( address, handler, IoFilterChainBuilder.NOOP );
+    }
+
+    public ConnectFuture connect( SocketAddress address, SocketAddress localAddress, IoHandler handler ) throws IOException
+    {
+        return connect( address, localAddress, handler, IoFilterChainBuilder.NOOP );
+    }
+
     public int getConnectTimeout()
     {
         return defaultConnectTimeout;

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoSession.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoSession.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoSession.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoSession.java Mon Nov 28 23:19:46 2005
@@ -38,6 +38,8 @@
  */
 public abstract class BaseIoSession implements IoSession
 {
+    // TODO pull up getManager() from other implementations.
+    
     private final Map attributes = new HashMap();
     private final long creationTime;
 

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoSessionManager.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoSessionManager.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoSessionManager.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoSessionManager.java Mon Nov 28 23:19:46 2005
@@ -19,6 +19,7 @@
 package org.apache.mina.common.support;
 
 import org.apache.mina.common.ExceptionMonitor;
+import org.apache.mina.common.IoFilterChainBuilder;
 import org.apache.mina.common.IoSessionManager;
 
 /**
@@ -34,10 +35,29 @@
      */
     protected ExceptionMonitor exceptionMonitor = new DefaultExceptionMonitor();
     
+    /**
+     * Current filter chain builder.
+     */
+    protected IoFilterChainBuilder filterChainBuilder = IoFilterChainBuilder.NOOP;
+
     protected BaseIoSessionManager()
     {
     }
     
+    public IoFilterChainBuilder getFilterChainBuilder()
+    {
+        return filterChainBuilder;
+    }
+
+    public void setFilterChainBuilder( IoFilterChainBuilder builder )
+    {
+        if( builder == null )
+        {
+            builder = IoFilterChainBuilder.NOOP;
+        }
+        filterChainBuilder = builder;
+    }
+
     public ExceptionMonitor getExceptionMonitor()
     {
         return exceptionMonitor;

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoAcceptor.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoAcceptor.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoAcceptor.java Mon Nov 28 23:19:46 2005
@@ -23,7 +23,7 @@
 
 import org.apache.mina.common.ExceptionMonitor;
 import org.apache.mina.common.IoAcceptor;
-import org.apache.mina.common.IoFilterChain;
+import org.apache.mina.common.IoFilterChainBuilder;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoSession;
 
@@ -50,6 +50,11 @@
         delegate.bind( address, handler );
     }
 
+    public void bind( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder ) throws IOException
+    {
+        delegate.bind( address, handler, filterChainBuilder );
+    }
+
     public void unbind( SocketAddress address )
     {
         delegate.unbind( address );
@@ -60,11 +65,6 @@
         return delegate.newSession( remoteAddress, localAddress );
     }
 
-    public IoFilterChain getFilterChain()
-    {
-        return delegate.getFilterChain();
-    }
-
     public ExceptionMonitor getExceptionMonitor()
     {
         return delegate.getExceptionMonitor();
@@ -73,6 +73,16 @@
     public void setExceptionMonitor( ExceptionMonitor monitor )
     {
         delegate.setExceptionMonitor( monitor );
+    }
+
+    public IoFilterChainBuilder getFilterChainBuilder()
+    {
+        return delegate.getFilterChainBuilder();
+    }
+
+    public void setFilterChainBuilder( IoFilterChainBuilder builder )
+    {
+        delegate.setFilterChainBuilder( builder );
     }
 
     /* TODO: DIRMINA-93

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoConnector.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoConnector.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoConnector.java Mon Nov 28 23:19:46 2005
@@ -24,7 +24,7 @@
 import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.ExceptionMonitor;
 import org.apache.mina.common.IoConnector;
-import org.apache.mina.common.IoFilterChain;
+import org.apache.mina.common.IoFilterChainBuilder;
 import org.apache.mina.common.IoHandler;
 
 /**
@@ -50,15 +50,21 @@
         return delegate.connect( address, handler );
     }
 
+    public ConnectFuture connect( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder ) throws IOException
+    {
+        return delegate.connect( address, handler, filterChainBuilder );
+    }
+
     public ConnectFuture connect( SocketAddress address, SocketAddress localAddress,
-                              IoHandler handler ) throws IOException
+                                  IoHandler handler ) throws IOException
     {
         return delegate.connect( address, localAddress, handler );
     }
 
-    public IoFilterChain getFilterChain()
+    public ConnectFuture connect( SocketAddress address, SocketAddress localAddress,
+                                  IoHandler handler, IoFilterChainBuilder filterChainBuilder ) throws IOException
     {
-        return delegate.getFilterChain();
+        return delegate.connect( address, localAddress, handler, filterChainBuilder );
     }
 
     public ExceptionMonitor getExceptionMonitor()
@@ -84,5 +90,15 @@
     public void setConnectTimeout( int connectTimeout )
     {
         delegate.setConnectTimeout( connectTimeout );
+    }
+
+    public IoFilterChainBuilder getFilterChainBuilder()
+    {
+        return delegate.getFilterChainBuilder();
+    }
+
+    public void setFilterChainBuilder( IoFilterChainBuilder builder )
+    {
+        delegate.setFilterChainBuilder( builder );
     }
 }

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/SSLFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/SSLFilter.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/SSLFilter.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/filter/SSLFilter.java Mon Nov 28 23:19:46 2005
@@ -334,7 +334,7 @@
     public void init( IoFilterChain parent, NextFilter nextFilter ) throws SSLException
     {
         this.parent = parent;
-        Object managerOrSession = parent.getParent();
+        Object managerOrSession = parent.getSession();
         if( managerOrSession instanceof IoSession )
         {
             createSSLSessionHandler( nextFilter, ( IoSession ) managerOrSession );

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/registry/SimpleServiceRegistry.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/registry/SimpleServiceRegistry.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/registry/SimpleServiceRegistry.java Mon Nov 28 23:19:46 2005
@@ -171,9 +171,12 @@
 
         try
         {
+            // FIXME HERE
+            /*
             socketIoAcceptor.getFilterChain().addFirst( "threadPool", threadPoolFilter );
             datagramIoAcceptor.getFilterChain().addFirst( "threadPool", threadPoolFilter );
             vmPipeAcceptor.getFilterChain().addFirst( "threadPool", threadPoolFilter );
+            */
         }
         catch( Exception e )
         {
@@ -189,9 +192,12 @@
 
         try
         {
+            // FIXME HERE
+            /*
             socketIoAcceptor.getFilterChain().remove( "threadPool" );
             datagramIoAcceptor.getFilterChain().remove( "threadPool" );
             vmPipeAcceptor.getFilterChain().remove( "threadPool" );
+            */
         }
         catch( Exception e )
         {

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java Mon Nov 28 23:19:46 2005
@@ -31,12 +31,11 @@
 
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IoAcceptor;
-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.IoFilter.WriteRequest;
 import org.apache.mina.common.support.BaseIoAcceptor;
-import org.apache.mina.common.support.IoSessionManagerFilterChain;
 import org.apache.mina.util.ExceptionUtil;
 import org.apache.mina.util.Queue;
 
@@ -48,23 +47,15 @@
  */
 public class DatagramAcceptorDelegate extends BaseIoAcceptor implements IoAcceptor, DatagramSessionManager
 {
+    // FIXME use real manager, not the delegate
     private static volatile int nextId = 0;
 
-    private final IoSessionManagerFilterChain filters =
-        new DatagramSessionManagerFilterChain( this );
-
     private final int id = nextId ++ ;
-
     private Selector selector;
-
     private final Map channels = new HashMap();
-
     private final Queue registerQueue = new Queue();
-
     private final Queue cancelQueue = new Queue();
-
     private final Queue flushingSessions = new Queue();
-
     private Worker worker;
 
     /**
@@ -74,7 +65,7 @@
     {
     }
 
-    public void bind( SocketAddress address, IoHandler handler )
+    public void bind( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder )
             throws IOException
     {
         if( address == null )
@@ -88,7 +79,12 @@
         if( ( ( InetSocketAddress ) address ).getPort() == 0 )
             throw new IllegalArgumentException( "Unsupported port number: 0" );
         
-        RegistrationRequest request = new RegistrationRequest( address, handler );
+        if( filterChainBuilder == null )
+        {
+            filterChainBuilder = IoFilterChainBuilder.NOOP;
+        }
+
+        RegistrationRequest request = new RegistrationRequest( address, handler, filterChainBuilder );
         synchronized( this )
         {
             synchronized( registerQueue )
@@ -190,17 +186,19 @@
         SelectionKey key = ch.keyFor( selector );
         if( key == null )
         {
-            throw new IllegalArgumentException( "Unknown lodalAddress: " + localAddress );
+            throw new IllegalArgumentException( "Unknown localAddress: " + localAddress );
         }
 
         RegistrationRequest req = ( RegistrationRequest ) key.attachment();
-        DatagramSessionImpl s = new DatagramSessionImpl( filters, ch, req.handler );
+        DatagramSessionImpl s = new DatagramSessionImpl( this, ch, req.handler );
         s.setRemoteAddress( remoteAddress );
         s.setSelectionKey( key );
         
         try
         {
-            s.getManagerFilterChain().sessionCreated( s );
+            this.filterChainBuilder.buildFilterChain( s.getFilterChain() );
+            req.filterChainBuilder.buildFilterChain( s.getFilterChain() );
+            ( ( DatagramFilterChain ) s.getFilterChain() ).sessionCreated( s );
         }
         catch( Throwable t )
         {
@@ -317,13 +315,13 @@
             DatagramChannel ch = ( DatagramChannel ) key.channel();
 
             RegistrationRequest req = ( RegistrationRequest ) key.attachment();
-            DatagramSessionImpl session = new DatagramSessionImpl(
-                    filters, ch, req.handler );
+            DatagramSessionImpl session =
+                new DatagramSessionImpl( this, ch, req.handler );
             session.setSelectionKey( key );
             
             try
             {
-                session.getManagerFilterChain().sessionCreated( session );
+                ( ( DatagramFilterChain ) session.getFilterChain() ).sessionCreated( session );
 
                 if( key.isReadable() )
                 {
@@ -360,12 +358,12 @@
                 newBuf.flip();
 
                 session.increaseReadBytes( newBuf.remaining() );
-                filters.messageReceived( session, newBuf );
+                ( ( DatagramFilterChain ) session.getFilterChain() ).messageReceived( session, newBuf );
             }
         }
         catch( IOException e )
         {
-            filters.exceptionCaught( session, e );
+            ( ( DatagramFilterChain ) session.getFilterChain() ).exceptionCaught( session, e );
         }
         finally
         {
@@ -396,7 +394,7 @@
             }
             catch( IOException e )
             {
-                session.getManagerFilterChain().exceptionCaught( session, e );
+                ( ( DatagramFilterChain ) session.getFilterChain() ).exceptionCaught( session, e );
             }
         }
     }
@@ -429,7 +427,7 @@
 
                 req.getFuture().setWritten( true );
                 session.increaseWrittenWriteRequests();
-                session.getManagerFilterChain().messageSent( session, buf );
+                ( ( DatagramFilterChain ) session.getFilterChain() ).messageSent( session, buf );
                 continue;
             }
 
@@ -467,7 +465,7 @@
                 session.increaseWrittenBytes( writtenBytes );
                 req.getFuture().setWritten( true );
                 session.increaseWrittenWriteRequests();
-                session.getManagerFilterChain().messageSent( session, buf.position( pos ) );
+                ( ( DatagramFilterChain ) session.getFilterChain() ).messageSent( session, buf.position( pos ) );
             }
         }
     }
@@ -581,25 +579,20 @@
         // received.
     }
 
-    public IoFilterChain getFilterChain()
-    {
-        return filters;
-    }
-
     private static class RegistrationRequest
     {
         private final SocketAddress address;
-        
         private final IoHandler handler;
-        
+        private final IoFilterChainBuilder filterChainBuilder;
+
         private Throwable exception; 
-        
         private boolean done;
         
-        private RegistrationRequest( SocketAddress address, IoHandler handler )
+        private RegistrationRequest( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder )
         {
             this.address = address;
             this.handler = handler;
+            this.filterChainBuilder = filterChainBuilder;
         }
     }
 

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java Mon Nov 28 23:19:46 2005
@@ -30,11 +30,10 @@
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.IoConnector;
-import org.apache.mina.common.IoFilterChain;
+import org.apache.mina.common.IoFilterChainBuilder;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.common.support.BaseIoConnector;
-import org.apache.mina.common.support.IoSessionManagerFilterChain;
 import org.apache.mina.util.Queue;
 
 /**
@@ -45,23 +44,15 @@
  */
 public class DatagramConnectorDelegate extends BaseIoConnector implements DatagramSessionManager
 {
+    // FIXME use real manager, not the delegate
     private static volatile int nextId = 0;
 
-    private final IoSessionManagerFilterChain filters =
-        new DatagramSessionManagerFilterChain( this );
-
     private final int id = nextId ++ ;
-
     private Selector selector;
-
     private final Queue registerQueue = new Queue();
-
     private final Queue cancelQueue = new Queue();
-
     private final Queue flushingSessions = new Queue();
-
     private final Queue trafficControllingSessions = new Queue();
-    
     private Worker worker;
 
     /**
@@ -71,13 +62,13 @@
     {
     }
 
-    public ConnectFuture connect( SocketAddress address, IoHandler handler ) throws IOException
+    public ConnectFuture connect( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder ) throws IOException
     {
-        return connect( address, null, handler);
+        return connect( address, null, handler, filterChainBuilder );
     }
 
     public ConnectFuture connect( SocketAddress address, SocketAddress localAddress,
-                              IoHandler handler ) throws IOException
+                                  IoHandler handler, IoFilterChainBuilder filterChainBuilder ) throws IOException
     {
         if( address == null )
             throw new NullPointerException( "address" );
@@ -94,6 +85,11 @@
                                                 + localAddress.getClass() );
         }
         
+        if( filterChainBuilder == null )
+        {
+            filterChainBuilder = IoFilterChainBuilder.NOOP;
+        }
+        
         DatagramChannel ch = DatagramChannel.open();
         boolean initialized = false;
         try
@@ -115,7 +111,7 @@
             }
         }
 
-        RegistrationRequest request = new RegistrationRequest( ch, handler );
+        RegistrationRequest request = new RegistrationRequest( ch, handler, filterChainBuilder );
         synchronized( this )
         {
             synchronized( registerQueue )
@@ -350,12 +346,12 @@
                 newBuf.flip();
 
                 session.increaseReadBytes( readBytes );
-                filters.messageReceived( session, newBuf );
+                ( ( DatagramFilterChain ) session.getFilterChain() ).messageReceived( session, newBuf );
             }
         }
         catch( IOException e )
         {
-            filters.exceptionCaught( session, e );
+            ( ( DatagramFilterChain ) session.getFilterChain() ).exceptionCaught( session, e );
         }
         finally
         {
@@ -386,7 +382,7 @@
             }
             catch( IOException e )
             {
-                session.getManagerFilterChain().exceptionCaught( session, e );
+                ( ( DatagramFilterChain ) session.getFilterChain() ).exceptionCaught( session, e );
             }
         }
     }
@@ -419,7 +415,7 @@
 
                 req.getFuture().setWritten( true );
                 session.increaseWrittenWriteRequests();
-                session.getManagerFilterChain().messageSent( session, buf );
+                ( ( DatagramFilterChain ) session.getFilterChain() ).messageSent( session, buf );
                 continue;
             }
 
@@ -456,7 +452,7 @@
                 session.increaseWrittenBytes( writtenBytes );
                 req.getFuture().setWritten( true );
                 session.increaseWrittenWriteRequests();
-                session.getManagerFilterChain().messageSent( session, buf.position( pos ) );
+                ( ( DatagramFilterChain ) session.getFilterChain() ).messageSent( session, buf.position( pos ) );
             }
         }
     }
@@ -477,13 +473,15 @@
             if( req == null )
                 break;
 
-            DatagramSessionImpl session = new DatagramSessionImpl(
-                    filters, req.channel, req.handler );
+            DatagramSessionImpl session =
+                new DatagramSessionImpl( this, req.channel, req.handler );
 
             boolean success = false;
             try
             {
-                session.getManagerFilterChain().sessionCreated( session );
+                this.filterChainBuilder.buildFilterChain( session.getFilterChain() );
+                req.filterChainBuilder.buildFilterChain( session.getFilterChain() );
+                ( ( DatagramFilterChain ) session.getFilterChain() ).sessionCreated( session );
 
                 SelectionKey key = req.channel.register( selector,
                         SelectionKey.OP_READ, session );
@@ -548,22 +546,19 @@
         }
     }
 
-    public IoFilterChain getFilterChain()
-    {
-        return filters;
-    }
-
     private static class RegistrationRequest extends ConnectFuture
     {
         private final DatagramChannel channel;
-
         private final IoHandler handler;
+        private final IoFilterChainBuilder filterChainBuilder;
 
         private RegistrationRequest( DatagramChannel channel,
-                                     IoHandler handler )
+                                     IoHandler handler,
+                                     IoFilterChainBuilder filterChainBuilder )
         {
             this.channel = channel;
             this.handler = handler;
+            this.filterChainBuilder = filterChainBuilder;
         }
     }
 }

Copied: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramFilterChain.java (from r349561, directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionManagerFilterChain.java)
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramFilterChain.java?p2=directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramFilterChain.java&p1=directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionManagerFilterChain.java&r1=349561&r2=349659&rev=349659&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionManagerFilterChain.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramFilterChain.java Mon Nov 28 23:19:46 2005
@@ -3,9 +3,8 @@
 import org.apache.mina.common.CloseFuture;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.common.IoSessionManager;
 import org.apache.mina.common.IoFilter.WriteRequest;
-import org.apache.mina.common.support.IoSessionManagerFilterChain;
+import org.apache.mina.common.support.AbstractIoFilterChain;
 import org.apache.mina.util.Queue;
 
 /**
@@ -13,11 +12,11 @@
  * 
  * @author The Apache Directory Project
  */
-class DatagramSessionManagerFilterChain extends IoSessionManagerFilterChain {
+class DatagramFilterChain extends AbstractIoFilterChain {
 
-    DatagramSessionManagerFilterChain( DatagramSessionManager processor )
+    DatagramFilterChain( IoSession parent )
     {
-        super( processor );
+        super( parent );
     }
     
     protected void doWrite( IoSession session, WriteRequest writeRequest )
@@ -31,14 +30,14 @@
             if( writeRequestQueue.size() == 1 && session.getTrafficMask().isWritable() )
             {
                 // Notify DatagramSessionManager only when writeRequestQueue was empty.
-                ( ( DatagramSessionManager ) getManager() ).flushSession( s );
+                ( ( DatagramSessionManager ) s.getManager() ).flushSession( s );
             }
         }
     }
 
     protected void doClose( IoSession session, CloseFuture closeFuture )
     {
-        IoSessionManager manager = getManager();
+        DatagramSessionManager manager = ( DatagramSessionManager ) session.getManager();
         if( manager instanceof DatagramConnectorDelegate )
         {
             ( ( DatagramConnectorDelegate ) manager ).closeSession( ( DatagramSessionImpl ) session );

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java Mon Nov 28 23:19:46 2005
@@ -27,11 +27,10 @@
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoSession;
+import org.apache.mina.common.IoSessionManager;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.common.support.BaseIoSession;
-import org.apache.mina.common.support.IoSessionFilterChain;
-import org.apache.mina.common.support.IoSessionManagerFilterChain;
 import org.apache.mina.transport.socket.nio.DatagramSession;
 import org.apache.mina.util.Queue;
 
@@ -43,8 +42,8 @@
  */
 class DatagramSessionImpl extends BaseIoSession implements DatagramSession
 {
-    private final IoSessionManagerFilterChain managerFilterChain;
-    private final IoSessionFilterChain filterChain;
+    private final DatagramSessionManager manager;
+    private final DatagramFilterChain filterChain;
     private final DatagramChannel ch;
     private final Queue writeRequestQueue;
     private final IoHandler handler;
@@ -55,23 +54,23 @@
     /**
      * Creates a new instance.
      */
-    DatagramSessionImpl( IoSessionManagerFilterChain managerFilterChain,
+    DatagramSessionImpl( DatagramSessionManager manager,
                          DatagramChannel ch, IoHandler defaultHandler )
     {
-        this.managerFilterChain = managerFilterChain;
-        this.filterChain = new IoSessionFilterChain( this, managerFilterChain );
+        this.manager = manager;
+        this.filterChain = new DatagramFilterChain( this );
         this.ch = ch;
         this.writeRequestQueue = new Queue();
         this.handler = defaultHandler;
         this.remoteAddress = ch.socket().getRemoteSocketAddress();
         this.localAddress = ch.socket().getLocalSocketAddress();
     }
-
-    IoSessionManagerFilterChain getManagerFilterChain()
+    
+    public IoSessionManager getManager()
     {
-        return managerFilterChain;
+        return manager;
     }
-    
+
     public IoFilterChain getFilterChain()
     {
         return filterChain;
@@ -99,7 +98,7 @@
     
     protected void close0( CloseFuture closeFuture )
     {
-        managerFilterChain.filterClose( this, closeFuture );
+        filterChain.filterClose( this, closeFuture );
     }
 
     Queue getWriteRequestQueue()
@@ -167,8 +166,6 @@
 
     protected void updateTrafficMask()
     {
-        DatagramSessionManager sessionManager = 
-            ( DatagramSessionManager) managerFilterChain.getManager();
-        sessionManager.updateTrafficMask( this );
+        manager.updateTrafficMask( this );
     }
 }

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java Mon Nov 28 23:19:46 2005
@@ -31,10 +31,9 @@
 import java.util.Set;
 
 import org.apache.mina.common.IoAcceptor;
-import org.apache.mina.common.IoFilterChain;
+import org.apache.mina.common.IoFilterChainBuilder;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.support.BaseIoAcceptor;
-import org.apache.mina.common.support.IoSessionManagerFilterChain;
 import org.apache.mina.transport.socket.nio.SocketSessionManager;
 import org.apache.mina.util.Queue;
 
@@ -46,17 +45,14 @@
  */
 public class SocketAcceptorDelegate extends BaseIoAcceptor implements SocketSessionManager
 {
+    // FIXME use real manager, not the delegate
     private static volatile int nextId = 0;
 
     private final int id = nextId ++ ;
     private final String threadName = "SocketAcceptor-" + id;
-
-    private final IoSessionManagerFilterChain filters = new SocketSessionManagerFilterChain( this );
-    
     private boolean reuseAddress = false;
     private int backlog = 50;
     private int receiveBufferSize = -1;
-
     private Selector selector;
     private final Map channels = new HashMap();
 
@@ -80,7 +76,7 @@
      *
      * @throws IOException if failed to bind
      */
-    public void bind( SocketAddress address, IoHandler handler ) throws IOException
+    public void bind( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder ) throws IOException
     {
         if( address == null )
         {
@@ -102,7 +98,12 @@
             throw new IllegalArgumentException( "Unsupported port number: 0" );
         }
         
-        RegistrationRequest request = new RegistrationRequest( address, handler );
+        if( filterChainBuilder == null )
+        {
+            filterChainBuilder = IoFilterChainBuilder.NOOP;
+        }
+        
+        RegistrationRequest request = new RegistrationRequest( address, handler, filterChainBuilder );
 
         synchronized( this )
         {
@@ -302,8 +303,10 @@
                 try
                 {
                     RegistrationRequest req = ( RegistrationRequest ) key.attachment();
-                    SocketSessionImpl session = new SocketSessionImpl( ioProcessor, filters, ch, req.handler );
-                    session.getManagerFilterChain().sessionCreated( session );
+                    SocketSessionImpl session = new SocketSessionImpl( SocketAcceptorDelegate.this, ioProcessor, ch, req.handler );
+                    SocketAcceptorDelegate.this.filterChainBuilder.buildFilterChain( session.getFilterChain() );
+                    req.filterChainBuilder.buildFilterChain( session.getFilterChain() );
+                    ( ( SocketFilterChain ) session.getFilterChain() ).sessionCreated( session );
                     session.getIoProcessor().addNew( session );
                     success = true;
                 }
@@ -450,11 +453,6 @@
         }
     }
 
-    public IoFilterChain getFilterChain()
-    {
-        return filters;
-    }
-
     public int getReceiveBufferSize()
     {
         return receiveBufferSize;
@@ -496,13 +494,15 @@
     {
         private final SocketAddress address;
         private final IoHandler handler;
+        private final IoFilterChainBuilder filterChainBuilder;
         private IOException exception;
         private boolean done;
         
-        private RegistrationRequest( SocketAddress address, IoHandler handler )
+        private RegistrationRequest( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder )
         {
             this.address = address;
             this.handler = handler;
+            this.filterChainBuilder = filterChainBuilder;
         }
     }
 

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketConnectorDelegate.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketConnectorDelegate.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketConnectorDelegate.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketConnectorDelegate.java Mon Nov 28 23:19:46 2005
@@ -30,10 +30,9 @@
 
 import org.apache.mina.common.ConnectFuture;
 import org.apache.mina.common.IoConnector;
-import org.apache.mina.common.IoFilterChain;
+import org.apache.mina.common.IoFilterChainBuilder;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.support.BaseIoConnector;
-import org.apache.mina.common.support.IoSessionManagerFilterChain;
 import org.apache.mina.transport.socket.nio.SocketSessionManager;
 import org.apache.mina.util.ExceptionUtil;
 import org.apache.mina.util.Queue;
@@ -46,19 +45,14 @@
  */
 public class SocketConnectorDelegate extends BaseIoConnector implements SocketSessionManager
 {
+    // FIXME use real manager, not the delegate
     private static volatile int nextId = 0;
 
     private final int id = nextId++;
     private final String threadName = "SocketConnector-" + id;
-
-    private final IoSessionManagerFilterChain filters = new SocketSessionManagerFilterChain( this );
-
     private Selector selector;
-
     private final Queue connectQueue = new Queue();
-
     private Worker worker;
-    
     private final SocketIoProcessor ioProcessor = new SocketIoProcessor( this, threadName + "-1" );
 
     /**
@@ -68,13 +62,13 @@
     {
     }
 
-    public ConnectFuture connect( SocketAddress address, IoHandler handler ) throws IOException
+    public ConnectFuture connect( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder ) throws IOException
     {
-        return connect( address, null, handler);
+        return connect( address, null, handler, filterChainBuilder );
     }
 
     public ConnectFuture connect( SocketAddress address, SocketAddress localAddress,
-                                  IoHandler handler ) throws IOException
+                                  IoHandler handler, IoFilterChainBuilder filterChainBuilder ) throws IOException
     {
         if( address == null )
             throw new NullPointerException( "address" );
@@ -89,6 +83,11 @@
             throw new IllegalArgumentException( "Unexpected local address type: "
                                                 + localAddress.getClass() );
 
+        if( filterChainBuilder == null )
+        {
+            filterChainBuilder = IoFilterChainBuilder.NOOP;
+        }
+        
         SocketChannel ch = SocketChannel.open();
         boolean success = false;
         try
@@ -103,7 +102,7 @@
 
             if( ch.connect( address ) )
             {
-                SocketSessionImpl session = newSession( ch, handler );
+                SocketSessionImpl session = newSession( ch, handler, filterChainBuilder );
                 success = true;
                 ConnectFuture future = new ConnectFuture();
                 future.setSession( session );
@@ -120,7 +119,7 @@
             }
         }
         
-        ConnectionRequest request = new ConnectionRequest( ch, getConnectTimeout(), handler );
+        ConnectionRequest request = new ConnectionRequest( ch, getConnectTimeout(), handler, filterChainBuilder );
         synchronized( this )
         {
             synchronized( connectQueue )
@@ -190,7 +189,7 @@
             try
             {
                 ch.finishConnect();
-                SocketSessionImpl session = newSession( ch, entry.handler );
+                SocketSessionImpl session = newSession( ch, entry.handler, entry.filterChainBuilder );
                 entry.setSession( session );
                 success = true;
             }
@@ -240,12 +239,14 @@
         }
     }
 
-    private SocketSessionImpl newSession( SocketChannel ch, IoHandler handler ) throws IOException
+    private SocketSessionImpl newSession( SocketChannel ch, IoHandler handler, IoFilterChainBuilder filterChainBuilder ) throws IOException
     {
-        SocketSessionImpl session = new SocketSessionImpl( ioProcessor, filters, ch, handler );
+        SocketSessionImpl session = new SocketSessionImpl( this, ioProcessor, ch, handler );
         try
         {
-            session.getManagerFilterChain().sessionCreated( session );
+            this.filterChainBuilder.buildFilterChain( session.getFilterChain() );
+            filterChainBuilder.buildFilterChain( session.getFilterChain() );
+            ( ( SocketFilterChain ) session.getFilterChain() ).sessionCreated( session );
         }
         catch( Throwable e )
         {
@@ -333,21 +334,16 @@
     private static class ConnectionRequest extends ConnectFuture
     {
         private final SocketChannel channel;
-        
         private final long deadline;
-
         private final IoHandler handler;
+        private final IoFilterChainBuilder filterChainBuilder;
 
-        private ConnectionRequest( SocketChannel channel, int timeout, IoHandler handler )
+        private ConnectionRequest( SocketChannel channel, int timeout, IoHandler handler, IoFilterChainBuilder filterChainBuilder )
         {
             this.channel = channel;
             this.deadline = System.currentTimeMillis() + timeout * 1000L;
             this.handler = handler;
+            this.filterChainBuilder = filterChainBuilder;
         }
-    }
-
-    public IoFilterChain getFilterChain()
-    {
-        return filters;
     }
 }

Copied: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketFilterChain.java (from r349561, directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionManagerFilterChain.java)
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketFilterChain.java?p2=directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketFilterChain.java&p1=directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionManagerFilterChain.java&r1=349561&r2=349659&rev=349659&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionManagerFilterChain.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketFilterChain.java Mon Nov 28 23:19:46 2005
@@ -6,9 +6,8 @@
 import org.apache.mina.common.CloseFuture;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.common.IoSessionManager;
 import org.apache.mina.common.IoFilter.WriteRequest;
-import org.apache.mina.common.support.IoSessionManagerFilterChain;
+import org.apache.mina.common.support.AbstractIoFilterChain;
 import org.apache.mina.util.Queue;
 
 /**
@@ -16,11 +15,11 @@
  * 
  * @author The Apache Directory Project
  */
-class SocketSessionManagerFilterChain extends IoSessionManagerFilterChain {
+class SocketFilterChain extends AbstractIoFilterChain {
 
-    public SocketSessionManagerFilterChain( IoSessionManager manager )
+    public SocketFilterChain( IoSession parent )
     {
-        super( manager );
+        super( parent );
     }
 
     protected void doWrite( IoSession session, WriteRequest writeRequest )

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketIoProcessor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketIoProcessor.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketIoProcessor.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketIoProcessor.java Mon Nov 28 23:19:46 2005
@@ -158,12 +158,12 @@
             catch( IOException e )
             {
                 registered = false;
-                session.getManagerFilterChain().exceptionCaught( session, e );
+                ( ( SocketFilterChain ) session.getFilterChain() ).exceptionCaught( session, e );
             }
 
             if( registered )
             {
-                session.getManagerFilterChain().sessionOpened( session );
+                ( ( SocketFilterChain ) session.getFilterChain() ).sessionOpened( session );
             }
         }
     }
@@ -207,13 +207,13 @@
             }
             catch( IOException e )
             {
-                session.getManagerFilterChain().exceptionCaught( session, e );
+                ( ( SocketFilterChain ) session.getFilterChain() ).exceptionCaught( session, e );
             }
             finally
             {
                 releaseWriteBuffers( session );
 
-                session.getManagerFilterChain().sessionClosed( session );
+                ( ( SocketFilterChain ) session.getFilterChain() ).sessionClosed( session );
                 session.getCloseFuture().setClosed();
             }
         }
@@ -273,7 +273,7 @@
                 ByteBuffer newBuf = ByteBuffer.allocate( readBytes );
                 newBuf.put( buf );
                 newBuf.flip();
-                session.getManagerFilterChain().messageReceived( session, newBuf );
+                ( ( SocketFilterChain ) session.getFilterChain() ).messageReceived( session, newBuf );
             }
             if( ret < 0 )
             {
@@ -284,7 +284,7 @@
         {
             if( e instanceof IOException )
                 scheduleRemove( session );
-            session.getManagerFilterChain().exceptionCaught( session, e );
+            ( ( SocketFilterChain ) session.getFilterChain() ).exceptionCaught( session, e );
         }
         finally
         {
@@ -342,7 +342,7 @@
             && ( currentTime - lastIoTime ) >= idleTime )
         {
             session.increaseIdleCount( status );
-            session.getManagerFilterChain().sessionIdle( session, status );
+            ( ( SocketFilterChain ) session.getFilterChain() ).sessionIdle( session, status );
         }
     }
 
@@ -356,9 +356,7 @@
             && key != null && key.isValid()
             && ( key.interestOps() & SelectionKey.OP_WRITE ) != 0 )
         {
-            session
-                    .getManagerFilterChain()
-                    .exceptionCaught( session, new WriteTimeoutException() );
+            ( ( SocketFilterChain ) session.getFilterChain() ).exceptionCaught( session, new WriteTimeoutException() );
         }
     }
 
@@ -406,7 +404,7 @@
             catch( IOException e )
             {
                 scheduleRemove( session );
-                session.getManagerFilterChain().exceptionCaught( session, e );
+                ( ( SocketFilterChain ) session.getFilterChain() ).exceptionCaught( session, e );
             }
         }
     }
@@ -424,7 +422,7 @@
             }
             catch( IllegalStateException e )
             {
-                session.getManagerFilterChain().exceptionCaught( session, e );
+                ( ( SocketFilterChain ) session.getFilterChain() ).exceptionCaught( session, e );
             }
             finally
             {
@@ -463,7 +461,7 @@
                 
                 req.getFuture().setWritten( true );
                 session.increaseWrittenWriteRequests();
-                session.getManagerFilterChain().messageSent( session, buf.reset() );
+                ( ( SocketFilterChain ) session.getFilterChain() ).messageSent( session, buf.reset() );
                 continue;
             }
 

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java Mon Nov 28 23:19:46 2005
@@ -27,11 +27,10 @@
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoSession;
+import org.apache.mina.common.IoSessionManager;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.common.support.BaseIoSession;
-import org.apache.mina.common.support.IoSessionFilterChain;
-import org.apache.mina.common.support.IoSessionManagerFilterChain;
 import org.apache.mina.transport.socket.nio.SocketSession;
 import org.apache.mina.util.Queue;
 
@@ -45,9 +44,9 @@
 {
     private static final int DEFAULT_READ_BUFFER_SIZE = 1024;
 
+    private final IoSessionManager manager;
     private final SocketIoProcessor ioProcessor;
-    private final IoSessionManagerFilterChain managerFilterChain;
-    private final IoSessionFilterChain filterChain;
+    private final SocketFilterChain filterChain;
     private final SocketChannel ch;
     private final Queue writeRequestQueue;
     private final IoHandler handler;
@@ -60,13 +59,13 @@
      * Creates a new instance.
      */
     public SocketSessionImpl(
+            IoSessionManager manager,
             SocketIoProcessor ioProcessor,
-            IoSessionManagerFilterChain managerFilterChain,
             SocketChannel ch, IoHandler defaultHandler )
     {
+        this.manager = manager;
         this.ioProcessor = ioProcessor;
-        this.managerFilterChain = managerFilterChain;
-        this.filterChain = new IoSessionFilterChain( this, managerFilterChain );
+        this.filterChain = new SocketFilterChain( this );
         this.ch = ch;
         this.writeRequestQueue = new Queue();
         this.handler = defaultHandler;
@@ -74,14 +73,14 @@
         this.localAddress = ch.socket().getLocalSocketAddress();
     }
     
-    SocketIoProcessor getIoProcessor()
+    public IoSessionManager getManager()
     {
-        return ioProcessor;
+        return manager;
     }
     
-    IoSessionManagerFilterChain getManagerFilterChain()
+    SocketIoProcessor getIoProcessor()
     {
-        return managerFilterChain;
+        return ioProcessor;
     }
     
     public IoFilterChain getFilterChain()

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java Mon Nov 28 23:19:46 2005
@@ -8,11 +8,10 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.mina.common.IoFilterChain;
+import org.apache.mina.common.IoFilterChainBuilder;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.support.BaseIoAcceptor;
 import org.apache.mina.transport.vmpipe.support.VmPipe;
-import org.apache.mina.transport.vmpipe.support.VmPipeSessionManagerFilterChain;
 
 /**
  * Binds the specified {@link IoHandler} to the specified
@@ -25,10 +24,7 @@
 {
     static final Map boundHandlers = new HashMap();
 
-    private final VmPipeSessionManagerFilterChain filterChain =
-        new VmPipeSessionManagerFilterChain( this );
-
-    public void bind( SocketAddress address, IoHandler handler ) throws IOException
+    public void bind( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder ) throws IOException
     {
         if( address == null )
             throw new NullPointerException( "address" );
@@ -38,6 +34,11 @@
             throw new IllegalArgumentException(
                     "address must be VmPipeAddress." );
 
+        if( filterChainBuilder == null )
+        {
+            filterChainBuilder = IoFilterChainBuilder.NOOP;
+        }
+
         synchronized( boundHandlers )
         {
             if( boundHandlers.containsKey( address ) )
@@ -48,8 +49,7 @@
             boundHandlers.put( address, 
                                new VmPipe( this,
                                           ( VmPipeAddress ) address,
-                                          filterChain,
-                                          handler ) );
+                                          handler, filterChainBuilder ) );
         }
     }
 
@@ -63,10 +63,5 @@
         {
             boundHandlers.remove( address );
         }
-    }
-    
-    public IoFilterChain getFilterChain()
-    {
-        return filterChain;
     }
 }

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java Mon Nov 28 23:19:46 2005
@@ -7,12 +7,11 @@
 import java.net.SocketAddress;
 
 import org.apache.mina.common.ConnectFuture;
-import org.apache.mina.common.IoFilterChain;
+import org.apache.mina.common.IoFilterChainBuilder;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.support.BaseIoConnector;
 import org.apache.mina.transport.vmpipe.support.VmPipe;
 import org.apache.mina.transport.vmpipe.support.VmPipeSessionImpl;
-import org.apache.mina.transport.vmpipe.support.VmPipeSessionManagerFilterChain;
 import org.apache.mina.util.AnonymousSocketAddress;
 
 /**
@@ -24,20 +23,12 @@
  */
 public class VmPipeConnector extends BaseIoConnector
 {
-    private final VmPipeSessionManagerFilterChain filterChain =
-        new VmPipeSessionManagerFilterChain( this );
-
-    public IoFilterChain getFilterChain()
+    public ConnectFuture connect( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder ) throws IOException 
     {
-        return filterChain;
+        return connect( address, null, handler, filterChainBuilder );
     }
 
-    public ConnectFuture connect( SocketAddress address, IoHandler handler ) throws IOException 
-    {
-        return connect( address, null, handler );
-    }
-
-    public ConnectFuture connect( SocketAddress address, SocketAddress localAddress, IoHandler handler ) throws IOException
+    public ConnectFuture connect( SocketAddress address, SocketAddress localAddress, IoHandler handler, IoFilterChainBuilder filterChainBuilder ) throws IOException
     {
         if( address == null )
             throw new NullPointerException( "address" );
@@ -47,15 +38,23 @@
             throw new IllegalArgumentException(
                                                 "address must be VmPipeAddress." );
 
+        if( filterChainBuilder == null )
+        {
+            filterChainBuilder = IoFilterChainBuilder.NOOP;
+        }
+
         VmPipe entry = ( VmPipe ) VmPipeAcceptor.boundHandlers.get( address );
         if( entry == null )
             throw new IOException( "Endpoint unavailable: " + address );
 
-        VmPipeSessionImpl session = new VmPipeSessionImpl( new Object(), // lock
-                                                   AnonymousSocketAddress.INSTANCE,
-                                                   filterChain,
-                                                   handler,
-                                                   entry );
+        VmPipeSessionImpl session =
+            new VmPipeSessionImpl(
+                    this,
+                    new Object(), // lock
+                    AnonymousSocketAddress.INSTANCE,
+                    handler,
+                    filterChainBuilder,
+                    entry );
 
         ConnectFuture future = new ConnectFuture();
         future.setSession( session );

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/support/VmPipe.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/support/VmPipe.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/support/VmPipe.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/support/VmPipe.java Mon Nov 28 23:19:46 2005
@@ -3,6 +3,7 @@
  */
 package org.apache.mina.transport.vmpipe.support;
 
+import org.apache.mina.common.IoFilterChainBuilder;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.transport.vmpipe.VmPipeAcceptor;
 import org.apache.mina.transport.vmpipe.VmPipeAddress;
@@ -11,18 +12,18 @@
 {
     private final VmPipeAcceptor acceptor;
     private final VmPipeAddress address;
-    private final VmPipeSessionManagerFilterChain managerFilterChain;
     private final IoHandler handler;
+    private final IoFilterChainBuilder filterChainBuilder;
     
     public VmPipe( VmPipeAcceptor acceptor,
                    VmPipeAddress address,
-                   VmPipeSessionManagerFilterChain managerFilterChain,
-                   IoHandler handler )
+                   IoHandler handler,
+                   IoFilterChainBuilder filterChainBuilder )
     {
         this.acceptor = acceptor;
         this.address = address;
-        this.managerFilterChain = managerFilterChain;
         this.handler = handler;
+        this.filterChainBuilder = filterChainBuilder;
     }
 
     public VmPipeAcceptor getAcceptor()
@@ -39,9 +40,9 @@
     {
         return handler;
     }
-
-    public VmPipeSessionManagerFilterChain getManagerFilterChain()
+    
+    public IoFilterChainBuilder getFilterChainBuilder()
     {
-        return managerFilterChain;
+        return filterChainBuilder;
     }
 }

Copied: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/support/VmPipeFilterChain.java (from r349561, directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionManagerFilterChain.java)
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/support/VmPipeFilterChain.java?p2=directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/support/VmPipeFilterChain.java&p1=directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionManagerFilterChain.java&r1=349561&r2=349659&rev=349659&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionManagerFilterChain.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/support/VmPipeFilterChain.java Mon Nov 28 23:19:46 2005
@@ -3,15 +3,14 @@
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.CloseFuture;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.common.IoSessionManager;
 import org.apache.mina.common.IoFilter.WriteRequest;
-import org.apache.mina.common.support.IoSessionManagerFilterChain;
+import org.apache.mina.common.support.AbstractIoFilterChain;
 
-public class VmPipeSessionManagerFilterChain extends IoSessionManagerFilterChain {
+public class VmPipeFilterChain extends AbstractIoFilterChain {
 
-    public VmPipeSessionManagerFilterChain( IoSessionManager manager )
+    public VmPipeFilterChain( IoSession session )
     {
-        super( manager );
+        super( session );
     }
 
     public void messageReceived( IoSession session, Object message )
@@ -76,8 +75,8 @@
                     s.increaseWrittenBytes( byteCount );
                     s.increaseWrittenWriteRequests();
     
-                    s.getManagerFilterChain().messageSent( s, message );
-                    s.remoteSession.getManagerFilterChain()
+                    ( ( VmPipeFilterChain ) s.getFilterChain() ).messageSent( s, message );
+                    ( ( VmPipeFilterChain ) s.remoteSession.getFilterChain() )
                                 .messageReceived( s.remoteSession, messageCopy );
                     
                     writeRequest.getFuture().setWritten( true );
@@ -97,7 +96,7 @@
         {
             if( !closeFuture.isClosed() )
             {
-                s.getManagerFilterChain().sessionClosed( session );
+                ( ( VmPipeFilterChain ) s.getFilterChain() ).sessionClosed( session );
                 closeFuture.setClosed();
                 s.remoteSession.close();
             }

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/support/VmPipeIdleStatusChecker.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/support/VmPipeIdleStatusChecker.java?rev=349659&r1=349561&r2=349659&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/support/VmPipeIdleStatusChecker.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/vmpipe/support/VmPipeIdleStatusChecker.java Mon Nov 28 23:19:46 2005
@@ -8,6 +8,7 @@
 import java.util.Map;
 
 import org.apache.mina.common.IdleStatus;
+import org.apache.mina.common.support.AbstractIoFilterChain;
 
 /**
  * Dectects idle sessions and fires <tt>sessionIdle</tt> events to them. 
@@ -110,7 +111,7 @@
             && ( currentTime - lastIoTime ) >= idleTime )
         {
             session.increaseIdleCount( status );
-            session.getManagerFilterChain().sessionIdle( session, status );
+            ( ( AbstractIoFilterChain ) session.getFilterChain() ).sessionIdle( session, status );
         }
     }
 



Mime
View raw message