You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by el...@apache.org on 2008/06/24 11:55:53 UTC

svn commit: r671108 [2/6] - in /mina/trunk: core/src/main/java/org/apache/mina/common/ core/src/main/java/org/apache/mina/common/buffer/ core/src/main/java/org/apache/mina/common/file/ core/src/main/java/org/apache/mina/common/filterchain/ core/src/mai...

Added: mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/DefaultIoFilterChainBuilder.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/DefaultIoFilterChainBuilder.java?rev=671108&view=auto
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/DefaultIoFilterChainBuilder.java (added)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/DefaultIoFilterChainBuilder.java Tue Jun 24 02:55:42 2008
@@ -0,0 +1,558 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.filterchain;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Random;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.mina.common.filterchain.IoFilter.NextFilter;
+import org.apache.mina.common.filterchain.IoFilterChain.Entry;
+import org.apache.mina.common.session.IoSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The default implementation of {@link IoFilterChainBuilder} which is useful
+ * in most cases.  {@link DefaultIoFilterChainBuilder} has an identical interface
+ * with {@link IoFilter}; it contains a list of {@link IoFilter}s that you can
+ * modify. The {@link IoFilter}s which are added to this builder will be appended
+ * to the {@link IoFilterChain} when {@link #buildFilterChain(IoFilterChain)} is
+ * invoked.
+ * <p>
+ * However, the identical interface doesn't mean that it behaves in an exactly
+ * same way with {@link IoFilterChain}.  {@link DefaultIoFilterChainBuilder}
+ * doesn't manage the life cycle of the {@link IoFilter}s at all, and the
+ * existing {@link IoSession}s won't get affected by the changes in this builder.
+ * {@link IoFilterChainBuilder}s affect only newly created {@link IoSession}s.
+ *
+ * <pre>
+ * IoAcceptor acceptor = ...;
+ * DefaultIoFilterChainBuilder builder = acceptor.getFilterChain();
+ * builder.addLast( "myFilter", new MyFilter() );
+ * ...
+ * </pre>
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev: 594846 $, $Date: 2007-11-14 13:03:07 +0100 (Wed, 14 Nov 2007) $
+ */
+public class DefaultIoFilterChainBuilder implements IoFilterChainBuilder {
+    
+    private final Logger logger = LoggerFactory.getLogger(getClass());
+    private final List<Entry> entries;
+
+    /**
+     * Creates a new instance with an empty filter list.
+     */
+    public DefaultIoFilterChainBuilder() {
+        entries = new CopyOnWriteArrayList<Entry>();
+    }
+
+    /**
+     * Creates a new copy of the specified {@link DefaultIoFilterChainBuilder}.
+     */
+    public DefaultIoFilterChainBuilder(DefaultIoFilterChainBuilder filterChain) {
+        if (filterChain == null) {
+            throw new NullPointerException("filterChain");
+        }
+        entries = new CopyOnWriteArrayList<Entry>(filterChain.entries);
+    }
+
+    /**
+     * @see IoFilterChain#getEntry(String)
+     */
+    public Entry getEntry(String name) {
+        for (Entry e: entries) {
+            if (e.getName().equals(name)) {
+                return e;
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * @see IoFilterChain#getEntry(IoFilter)
+     */
+    public Entry getEntry(IoFilter filter) {
+        for (Entry e: entries) {
+            if (e.getFilter() == filter) {
+                return e;
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * @see IoFilterChain#getEntry(Class)
+     */
+    public Entry getEntry(Class<? extends IoFilter> filterType) {
+        for (Entry e: entries) {
+            if (filterType.isAssignableFrom(e.getFilter().getClass())) {
+                return e;
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * @see IoFilterChain#get(String)
+     */
+    public IoFilter get(String name) {
+        Entry e = getEntry(name);
+        if (e == null) {
+            return null;
+        }
+
+        return e.getFilter();
+    }
+
+    /**
+     * @see IoFilterChain#get(Class)
+     */
+    public IoFilter get(Class<? extends IoFilter> filterType) {
+        Entry e = getEntry(filterType);
+        if (e == null) {
+            return null;
+        }
+
+        return e.getFilter();
+    }
+
+    /**
+     * @see IoFilterChain#getAll()
+     */
+    public List<Entry> getAll() {
+        return new ArrayList<Entry>(entries);
+    }
+
+    /**
+     * @see IoFilterChain#getAllReversed()
+     */
+    public List<Entry> getAllReversed() {
+        List<Entry> result = getAll();
+        Collections.reverse(result);
+        return result;
+    }
+
+    /**
+     * @see IoFilterChain#contains(String)
+     */
+    public boolean contains(String name) {
+        return getEntry(name) != null;
+    }
+
+    /**
+     * @see IoFilterChain#contains(IoFilter)
+     */
+    public boolean contains(IoFilter filter) {
+        return getEntry(filter) != null;
+    }
+
+    /**
+     * @see IoFilterChain#contains(Class)
+     */
+    public boolean contains(Class<? extends IoFilter> filterType) {
+        return getEntry(filterType) != null;
+    }
+
+    /**
+     * @see IoFilterChain#addFirst(String, IoFilter)
+     */
+    public synchronized void addFirst(String name, IoFilter filter) {
+        register(0, new EntryImpl(name, filter));
+    }
+
+    /**
+     * @see IoFilterChain#addLast(String, IoFilter)
+     */
+    public synchronized void addLast(String name, IoFilter filter) {
+        register(entries.size(), new EntryImpl(name, filter));
+    }
+
+    /**
+     * @see IoFilterChain#addBefore(String, String, IoFilter)
+     */
+    public synchronized void addBefore(String baseName, String name,
+            IoFilter filter) {
+        checkBaseName(baseName);
+
+        for (ListIterator<Entry> i = entries.listIterator(); i.hasNext();) {
+            Entry base = i.next();
+            if (base.getName().equals(baseName)) {
+                register(i.previousIndex(), new EntryImpl(name, filter));
+                break;
+            }
+        }
+    }
+
+    /**
+     * @see IoFilterChain#addAfter(String, String, IoFilter)
+     */
+    public synchronized void addAfter(String baseName, String name,
+            IoFilter filter) {
+        checkBaseName(baseName);
+
+        for (ListIterator<Entry> i = entries.listIterator(); i.hasNext();) {
+            Entry base = i.next();
+            if (base.getName().equals(baseName)) {
+                register(i.nextIndex(), new EntryImpl(name, filter));
+                break;
+            }
+        }
+    }
+
+    /**
+     * @see IoFilterChain#remove(String)
+     */
+    public synchronized IoFilter remove(String name) {
+        if (name == null) {
+            throw new NullPointerException("name");
+        }
+
+        for (ListIterator<Entry> i = entries.listIterator(); i.hasNext();) {
+            Entry e = i.next();
+            if (e.getName().equals(name)) {
+                entries.remove(i.previousIndex());
+                return e.getFilter();
+            }
+        }
+
+        throw new IllegalArgumentException("Unknown filter name: " + name);
+    }
+
+    /**
+     * @see IoFilterChain#remove(IoFilter)
+     */
+    public synchronized IoFilter remove(IoFilter filter) {
+        if (filter == null) {
+            throw new NullPointerException("filter");
+        }
+
+        for (ListIterator<Entry> i = entries.listIterator(); i.hasNext();) {
+            Entry e = i.next();
+            if (e.getFilter() == filter) {
+                entries.remove(i.previousIndex());
+                return e.getFilter();
+            }
+        }
+
+        throw new IllegalArgumentException("Filter not found: " + filter.getClass().getName());
+    }
+
+    /**
+     * @see IoFilterChain#remove(Class)
+     */
+    public synchronized IoFilter remove(Class<? extends IoFilter> filterType) {
+        if (filterType == null) {
+            throw new NullPointerException("filterType");
+        }
+
+        for (ListIterator<Entry> i = entries.listIterator(); i.hasNext();) {
+            Entry e = i.next();
+            if (filterType.isAssignableFrom(e.getFilter().getClass())) {
+                entries.remove(i.previousIndex());
+                return e.getFilter();
+            }
+        }
+
+        throw new IllegalArgumentException("Filter not found: " + filterType.getName());
+    }
+
+    public synchronized IoFilter replace(String name, IoFilter newFilter) {
+        checkBaseName(name);
+        EntryImpl e = (EntryImpl) get(name);
+        IoFilter oldFilter = e.getFilter();
+        e.setFilter(newFilter);
+        return oldFilter;
+    }
+
+    public synchronized void replace(IoFilter oldFilter, IoFilter newFilter) {
+        for (Entry e : entries) {
+            if (e.getFilter() == oldFilter) {
+                ((EntryImpl) e).setFilter(newFilter);
+                return;
+            }
+        }
+        throw new IllegalArgumentException("Filter not found: "
+                + oldFilter.getClass().getName());
+    }
+
+    public synchronized void replace(Class<? extends IoFilter> oldFilterType,
+            IoFilter newFilter) {
+        for (Entry e : entries) {
+            if (oldFilterType.isAssignableFrom(e.getFilter().getClass())) {
+                ((EntryImpl) e).setFilter(newFilter);
+                return;
+            }
+        }
+        throw new IllegalArgumentException("Filter not found: "
+                + oldFilterType.getName());
+    }
+
+    /**
+     * @see IoFilterChain#clear()
+     */
+    public synchronized void clear() {
+        entries.clear();
+    }
+    
+    /**
+     * Clears the current list of filters and adds the specified
+     * filter mapping to this builder.  Please note that you must specify
+     * a {@link Map} implementation that iterates the filter mapping in the
+     * order of insertion such as {@link LinkedHashMap}.  Otherwise, it will
+     * throw an {@link IllegalArgumentException}.
+     */
+    public void setFilters(Map<String, ? extends IoFilter> filters) {
+        if (filters == null) {
+            throw new NullPointerException("filters");
+        }
+        
+        if (!isOrderedMap(filters)) {
+            throw new IllegalArgumentException(
+                    "filters is not an ordered map. Please try " + 
+                    LinkedHashMap.class.getName() + ".");
+        }
+
+        filters = new LinkedHashMap<String, IoFilter>(filters);
+        for (Map.Entry<String, ? extends IoFilter> e: filters.entrySet()) {
+            if (e.getKey() == null) {
+                throw new NullPointerException("filters contains a null key.");
+            }
+            if (e.getValue() == null) {
+                throw new NullPointerException("filters contains a null value.");
+            }
+        }
+        
+        synchronized (this) {
+            clear();
+            for (Map.Entry<String, ? extends IoFilter> e: filters.entrySet()) {
+                addLast(e.getKey(), e.getValue());
+            }
+        }
+    }
+    
+    @SuppressWarnings("unchecked")
+    private boolean isOrderedMap(Map map) {
+        Class<?> mapType = map.getClass();
+        if (LinkedHashMap.class.isAssignableFrom(mapType)) {
+            if (logger.isDebugEnabled()) {
+                logger.debug(mapType.getSimpleName() + " is an ordered map.");
+            }
+            return true;
+        }
+        
+        if (logger.isDebugEnabled()) {
+            logger.debug(mapType.getName() + " is not a " + LinkedHashMap.class.getSimpleName());
+        }
+
+        // Detect Jakarta Commons Collections OrderedMap implementations.
+        Class<?> type = mapType;
+        while (type != null) {
+            for (Class<?> i: type.getInterfaces()) {
+                if (i.getName().endsWith("OrderedMap")) {
+                    if (logger.isDebugEnabled()) {
+                        logger.debug(
+                                mapType.getSimpleName() +
+                                " is an ordered map (guessed from that it " +
+                                " implements OrderedMap interface.)");
+                    }
+                    return true;
+                }
+            }
+            type = type.getSuperclass();
+        }
+        
+        if (logger.isDebugEnabled()) {
+            logger.debug(
+                    mapType.getName() +
+                    " doesn't implement OrderedMap interface.");
+        }
+        
+        // Last resort: try to create a new instance and test if it maintains
+        // the insertion order.
+        logger.debug(
+                "Last resort; trying to create a new map instance with a " +
+                "default constructor and test if insertion order is " +
+                "maintained.");
+        
+        Map newMap;
+        try {
+            newMap = (Map) mapType.newInstance();
+        } catch (Exception e) {
+            if (logger.isDebugEnabled()) {
+                logger.debug(
+                        "Failed to create a new map instance of '" + 
+                        mapType.getName() +"'.", e);
+            }
+            return false;
+        }
+        
+        Random rand = new Random();
+        List<String> expectedNames = new ArrayList<String>();
+        IoFilter dummyFilter = new IoFilterAdapter();
+        for (int i = 0; i < 65536; i ++) {
+            String filterName;
+            do {
+                filterName = String.valueOf(rand.nextInt());
+            } while (newMap.containsKey(filterName));
+            
+            newMap.put(filterName, dummyFilter);
+            expectedNames.add(filterName);
+
+            Iterator<String> it = expectedNames.iterator();
+            for (Object key: newMap.keySet()) {
+                if (!it.next().equals(key)) {
+                    if (logger.isDebugEnabled()) {
+                        logger.debug(
+                                "The specified map didn't pass the insertion " +
+                                "order test after " + (i + 1) + " tries.");
+                    }
+                    return false;
+                }
+            }
+        }
+        
+        if (logger.isDebugEnabled()) {
+            logger.debug(
+                    "The specified map passed the insertion order test.");
+        }
+        return true;
+    }
+
+    public void buildFilterChain(IoFilterChain chain) throws Exception {
+        for (Entry e : entries) {
+            chain.addLast(e.getName(), e.getFilter());
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuffer buf = new StringBuffer();
+        buf.append("{ ");
+
+        boolean empty = true;
+
+        for (Entry e : entries) {
+            if (!empty) {
+                buf.append(", ");
+            } else {
+                empty = false;
+            }
+
+            buf.append('(');
+            buf.append(e.getName());
+            buf.append(':');
+            buf.append(e.getFilter());
+            buf.append(')');
+        }
+
+        if (empty) {
+            buf.append("empty");
+        }
+
+        buf.append(" }");
+
+        return buf.toString();
+    }
+
+    private void checkBaseName(String baseName) {
+        if (baseName == null) {
+            throw new NullPointerException("baseName");
+        }
+
+        if (!contains(baseName)) {
+            throw new IllegalArgumentException("Unknown filter name: "
+                    + baseName);
+        }
+    }
+
+    private void register(int index, Entry e) {
+        if (contains(e.getName())) {
+            throw new IllegalArgumentException(
+                    "Other filter is using the same name: " + e.getName());
+        }
+
+        entries.add(index, e);
+    }
+
+    private class EntryImpl implements Entry {
+        private final String name;
+        private volatile IoFilter filter;
+
+        private EntryImpl(String name, IoFilter filter) {
+            if (name == null) {
+                throw new NullPointerException("name");
+            }
+            if (filter == null) {
+                throw new NullPointerException("filter");
+            }
+
+            this.name = name;
+            this.filter = filter;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public IoFilter getFilter() {
+            return filter;
+        }
+
+        private void setFilter(IoFilter filter) {
+            this.filter = filter;
+        }
+
+        public NextFilter getNextFilter() {
+            throw new IllegalStateException();
+        }
+
+        @Override
+        public String toString() {
+            return "(" + getName() + ':' + filter + ')';
+        }
+
+        public void addAfter(String name, IoFilter filter) {
+            DefaultIoFilterChainBuilder.this.addAfter(getName(), name, filter);
+        }
+
+        public void addBefore(String name, IoFilter filter) {
+            DefaultIoFilterChainBuilder.this.addBefore(getName(), name, filter);
+        }
+
+        public void remove() {
+            DefaultIoFilterChainBuilder.this.remove(getName());
+        }
+
+        public void replace(IoFilter newFilter) {
+            DefaultIoFilterChainBuilder.this.replace(getName(), newFilter);
+        }
+    }
+}

Added: mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilter.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilter.java?rev=671108&view=auto
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilter.java (added)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilter.java Tue Jun 24 02:55:42 2008
@@ -0,0 +1,271 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.filterchain;
+
+import org.apache.mina.common.session.TrafficMask;
+import org.apache.mina.common.service.IoHandler;
+import org.apache.mina.common.session.IdleStatus;
+import org.apache.mina.common.session.IoSession;
+import org.apache.mina.common.write.WriteRequest;
+import org.apache.mina.filter.util.ReferenceCountingFilter;
+
+/**
+ * A filter which intercepts {@link IoHandler} events like Servlet
+ * filters.  Filters can be used for these purposes:
+ * <ul>
+ *   <li>Event logging,</li>
+ *   <li>Performance measurement,</li>
+ *   <li>Authorization,</li>
+ *   <li>Overload control,</li>
+ *   <li>Message transformation (e.g. encryption and decryption, ...),</li>
+ *   <li>and many more.</li>
+ * </ul>
+ * <p>
+ * <strong>Please NEVER implement your filters to wrap
+ * {@link IoSession}s.</strong> Users can cache the reference to the
+ * session, which might malfunction if any filters are added or removed later.
+ *
+ * <h3>The Life Cycle</h3>
+ * {@link IoFilter}s are activated only when they are inside {@link IoFilterChain}.
+ * <p>
+ * When you add an {@link IoFilter} to an {@link IoFilterChain}:
+ * <ol>
+ *   <li>{@link #init()} is invoked by {@link ReferenceCountingFilter} if
+ *       the filter is added at the first time.</li>
+ *   <li>{@link #onPreAdd(IoFilterChain, String, NextFilter)} is invoked to notify
+ *       that the filter will be added to the chain.</li>
+ *   <li>The filter is added to the chain, and all events and I/O requests
+ *       pass through the filter from now.</li>
+ *   <li>{@link #onPostAdd(IoFilterChain, String, NextFilter)} is invoked to notify
+ *       that the filter is added to the chain.</li>
+ *   <li>The filter is removed from the chain if {@link #onPostAdd(IoFilterChain, String, org.apache.mina.common.filterchain.IoFilter.NextFilter)}
+ *       threw an exception.  {@link #destroy()} is also invoked by
+ *       {@link ReferenceCountingFilter} if the filter is the last filter which
+ *       was added to {@link IoFilterChain}s.</li>
+ * </ol>
+ * <p>
+ * When you remove an {@link IoFilter} from an {@link IoFilterChain}:
+ * <ol>
+ *   <li>{@link #onPreRemove(IoFilterChain, String, NextFilter)} is invoked to
+ *       notify that the filter will be removed from the chain.</li>
+ *   <li>The filter is removed from the chain, and any events and I/O requests
+ *       don't pass through the filter from now.</li>
+ *   <li>{@link #onPostRemove(IoFilterChain, String, NextFilter)} is invoked to
+ *       notify that the filter is removed from the chain.</li>
+ *   <li>{@link #destroy()} is invoked by {@link ReferenceCountingFilter} if
+ *       the removed filter was the last one.</li>
+ * </ol>
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev: 591770 $, $Date: 2007-11-04 13:22:44 +0100 (Sun, 04 Nov 2007) $
+ *
+ * @see IoFilterAdapter
+ */
+public interface IoFilter {
+    /**
+     * Invoked by {@link ReferenceCountingFilter} when this filter
+     * is added to a {@link IoFilterChain} at the first time, so you can
+     * initialize shared resources.  Please note that this method is never
+     * called if you don't wrap a filter with {@link ReferenceCountingFilter}.
+     */
+    void init() throws Exception;
+
+    /**
+     * Invoked by {@link ReferenceCountingFilter} when this filter
+     * is not used by any {@link IoFilterChain} anymore, so you can destroy
+     * shared resources.  Please note that this method is never called if
+     * you don't wrap a filter with {@link ReferenceCountingFilter}.
+     */
+    void destroy() throws Exception;
+
+    /**
+     * Invoked before this filter is added to the specified <tt>parent</tt>.
+     * Please note that this method can be invoked more than once if
+     * this filter is added to more than one parents.  This method is not
+     * invoked before {@link #init()} is invoked.
+     *
+     * @param parent the parent who called this method
+     * @param name the name assigned to this filter
+     * @param nextFilter the {@link NextFilter} for this filter.  You can reuse
+     *                   this object until this filter is removed from the chain.
+     */
+    void onPreAdd(IoFilterChain parent, String name, NextFilter nextFilter)
+            throws Exception;
+
+    /**
+     * Invoked after this filter is added to the specified <tt>parent</tt>.
+     * Please note that this method can be invoked more than once if
+     * this filter is added to more than one parents.  This method is not
+     * invoked before {@link #init()} is invoked.
+     *
+     * @param parent the parent who called this method
+     * @param name the name assigned to this filter
+     * @param nextFilter the {@link NextFilter} for this filter.  You can reuse
+     *                   this object until this filter is removed from the chain.
+     */
+    void onPostAdd(IoFilterChain parent, String name, NextFilter nextFilter)
+            throws Exception;
+
+    /**
+     * Invoked before this filter is removed from the specified <tt>parent</tt>.
+     * Please note that this method can be invoked more than once if
+     * this filter is removed from more than one parents.
+     * This method is always invoked before {@link #destroy()} is invoked.
+     *
+     * @param parent the parent who called this method
+     * @param name the name assigned to this filter
+     * @param nextFilter the {@link NextFilter} for this filter.  You can reuse
+     *                   this object until this filter is removed from the chain.
+     */
+    void onPreRemove(IoFilterChain parent, String name, NextFilter nextFilter)
+            throws Exception;
+
+    /**
+     * Invoked after this filter is removed from the specified <tt>parent</tt>.
+     * Please note that this method can be invoked more than once if
+     * this filter is removed from more than one parents.
+     * This method is always invoked before {@link #destroy()} is invoked.
+     *
+     * @param parent the parent who called this method
+     * @param name the name assigned to this filter
+     * @param nextFilter the {@link NextFilter} for this filter.  You can reuse
+     *                   this object until this filter is removed from the chain.
+     */
+    void onPostRemove(IoFilterChain parent, String name, NextFilter nextFilter)
+            throws Exception;
+
+    /**
+     * Filters {@link IoHandler#sessionCreated(IoSession)} event.
+     */
+    void sessionCreated(NextFilter nextFilter, IoSession session)
+            throws Exception;
+
+    /**
+     * Filters {@link IoHandler#sessionOpened(IoSession)} event.
+     */
+    void sessionOpened(NextFilter nextFilter, IoSession session)
+            throws Exception;
+
+    /**
+     * Filters {@link IoHandler#sessionClosed(IoSession)} event.
+     */
+    void sessionClosed(NextFilter nextFilter, IoSession session)
+            throws Exception;
+
+    /**
+     * Filters {@link IoHandler#sessionIdle(IoSession,IdleStatus)}
+     * event.
+     */
+    void sessionIdle(NextFilter nextFilter, IoSession session, IdleStatus status)
+            throws Exception;
+
+    /**
+     * Filters {@link IoHandler#exceptionCaught(IoSession,Throwable)}
+     * event.
+     */
+    void exceptionCaught(NextFilter nextFilter, IoSession session,
+            Throwable cause) throws Exception;
+
+    /**
+     * Filters {@link IoHandler#messageReceived(IoSession,Object)}
+     * event.
+     */
+    void messageReceived(NextFilter nextFilter, IoSession session,
+            Object message) throws Exception;
+
+    /**
+     * Filters {@link IoHandler#messageSent(IoSession,Object)}
+     * event.
+     */
+    void messageSent(NextFilter nextFilter, IoSession session,
+            WriteRequest writeRequest) throws Exception;
+
+    /**
+     * Filters {@link IoSession#close()} method invocation.
+     */
+    void filterClose(NextFilter nextFilter, IoSession session) throws Exception;
+
+    /**
+     * Filters {@link IoSession#write(Object)} method invocation.
+     */
+    void filterWrite(NextFilter nextFilter, IoSession session,
+            WriteRequest writeRequest) throws Exception;
+    
+    /**
+     * Filters {@link IoSession#setTrafficMask(TrafficMask)} method invocation.
+     */
+    void filterSetTrafficMask(
+            NextFilter nextFilter, IoSession session, TrafficMask trafficMask) throws Exception;
+
+    /**
+     * Represents the next {@link IoFilter} in {@link IoFilterChain}.
+     */
+    public interface NextFilter {
+        /**
+         * Forwards <tt>sessionCreated</tt> event to next filter.
+         */
+        void sessionCreated(IoSession session);
+
+        /**
+         * Forwards <tt>sessionOpened</tt> event to next filter.
+         */
+        void sessionOpened(IoSession session);
+
+        /**
+         * Forwards <tt>sessionClosed</tt> event to next filter.
+         */
+        void sessionClosed(IoSession session);
+
+        /**
+         * Forwards <tt>sessionIdle</tt> event to next filter.
+         */
+        void sessionIdle(IoSession session, IdleStatus status);
+
+        /**
+         * Forwards <tt>exceptionCaught</tt> event to next filter.
+         */
+        void exceptionCaught(IoSession session, Throwable cause);
+
+        /**
+         * Forwards <tt>messageReceived</tt> event to next filter.
+         */
+        void messageReceived(IoSession session, Object message);
+
+        /**
+         * Forwards <tt>messageSent</tt> event to next filter.
+         */
+        void messageSent(IoSession session, WriteRequest writeRequest);
+
+        /**
+         * Forwards <tt>filterWrite</tt> event to next filter.
+         */
+        void filterWrite(IoSession session, WriteRequest writeRequest);
+
+        /**
+         * Forwards <tt>filterClose</tt> event to next filter.
+         */
+        void filterClose(IoSession session);
+        
+        /**
+         * Forwards <tt>filterSetTrafficMask</tt> event to next filter.
+         */
+        void filterSetTrafficMask(IoSession session, TrafficMask trafficMask);
+    }
+}

Added: mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterAdapter.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterAdapter.java?rev=671108&view=auto
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterAdapter.java (added)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterAdapter.java Tue Jun 24 02:55:42 2008
@@ -0,0 +1,107 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.filterchain;
+
+import org.apache.mina.common.session.TrafficMask;
+import org.apache.mina.common.session.IdleStatus;
+import org.apache.mina.common.session.IoSession;
+import org.apache.mina.common.write.WriteRequest;
+
+/**
+ * An abstract adapter class for {@link IoFilter}.  You can extend
+ * this class and selectively override required event filter methods only.  All
+ * methods forwards events to the next filter by default.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev: 591770 $, $Date: 2007-11-04 13:22:44 +0100 (Sun, 04 Nov 2007) $
+ */
+public class IoFilterAdapter implements IoFilter {
+    public void init() throws Exception {
+    }
+
+    public void destroy() throws Exception {
+    }
+
+    public void onPreAdd(IoFilterChain parent, String name,
+            NextFilter nextFilter) throws Exception {
+    }
+
+    public void onPostAdd(IoFilterChain parent, String name,
+            NextFilter nextFilter) throws Exception {
+    }
+
+    public void onPreRemove(IoFilterChain parent, String name,
+            NextFilter nextFilter) throws Exception {
+    }
+
+    public void onPostRemove(IoFilterChain parent, String name,
+            NextFilter nextFilter) throws Exception {
+    }
+
+    public void sessionCreated(NextFilter nextFilter, IoSession session)
+            throws Exception {
+        nextFilter.sessionCreated(session);
+    }
+
+    public void sessionOpened(NextFilter nextFilter, IoSession session)
+            throws Exception {
+        nextFilter.sessionOpened(session);
+    }
+
+    public void sessionClosed(NextFilter nextFilter, IoSession session)
+            throws Exception {
+        nextFilter.sessionClosed(session);
+    }
+
+    public void sessionIdle(NextFilter nextFilter, IoSession session,
+            IdleStatus status) throws Exception {
+        nextFilter.sessionIdle(session, status);
+    }
+
+    public void exceptionCaught(NextFilter nextFilter, IoSession session,
+            Throwable cause) throws Exception {
+        nextFilter.exceptionCaught(session, cause);
+    }
+
+    public void messageReceived(NextFilter nextFilter, IoSession session,
+            Object message) throws Exception {
+        nextFilter.messageReceived(session, message);
+    }
+
+    public void messageSent(NextFilter nextFilter, IoSession session,
+            WriteRequest writeRequest) throws Exception {
+        nextFilter.messageSent(session, writeRequest);
+    }
+
+    public void filterWrite(NextFilter nextFilter, IoSession session,
+            WriteRequest writeRequest) throws Exception {
+        nextFilter.filterWrite(session, writeRequest);
+    }
+
+    public void filterClose(NextFilter nextFilter, IoSession session)
+            throws Exception {
+        nextFilter.filterClose(session);
+    }
+
+    public void filterSetTrafficMask(NextFilter nextFilter, IoSession session,
+            TrafficMask trafficMask) throws Exception {
+        nextFilter.filterSetTrafficMask(session, trafficMask);
+    }
+}
\ No newline at end of file

Added: mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterChain.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterChain.java?rev=671108&view=auto
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterChain.java (added)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterChain.java Tue Jun 24 02:55:42 2008
@@ -0,0 +1,342 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.filterchain;
+
+import java.util.List;
+
+import org.apache.mina.common.session.TrafficMask;
+import org.apache.mina.common.filterchain.IoFilter.NextFilter;
+import org.apache.mina.common.service.IoHandler;
+import org.apache.mina.common.session.IdleStatus;
+import org.apache.mina.common.session.IoSession;
+import org.apache.mina.common.write.WriteRequest;
+
+/**
+ * A container of {@link IoFilter}s that forwards {@link IoHandler} events
+ * to the consisting filters and terminal {@link IoHandler} sequentially.
+ * Every {@link IoSession} has its own {@link IoFilterChain} (1-to-1 relationship).
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev: 593474 $, $Date: 2007-11-09 11:14:12 +0100 (Fri, 09 Nov 2007) $
+ */
+public interface IoFilterChain {
+    /**
+     * Returns the parent {@link IoSession} of this chain.
+     * @return {@link IoSession}
+     */
+    IoSession getSession();
+
+    /**
+     * Returns the {@link Entry} with the specified <tt>name</tt> in this chain.
+     * @return <tt>null</tt> if there's no such name in this chain
+     */
+    Entry getEntry(String name);
+
+    /**
+     * Returns the {@link Entry} with the specified <tt>filter</tt> in this chain.
+     * @return <tt>null</tt> if there's no such filter in this chain
+     */
+    Entry getEntry(IoFilter filter);
+
+    /**
+     * Returns the {@link Entry} with the specified <tt>filterType</tt>
+     * in this chain.  If there's more than one filter with the specified
+     * type, the first match will be chosen.
+     * @return <tt>null</tt> if there's no such name in this chain
+     */
+    Entry getEntry(Class<? extends IoFilter> filterType);
+
+    /**
+     * Returns the {@link IoFilter} with the specified <tt>name</tt> in this chain.
+     * @return <tt>null</tt> if there's no such name in this chain
+     */
+    IoFilter get(String name);
+
+    /**
+     * Returns the {@link IoFilter} with the specified <tt>filterType</tt>
+     * in this chain. If there's more than one filter with the specified
+     * type, the first match will be chosen.
+     * @return <tt>null</tt> if there's no such name in this chain
+     */
+    IoFilter get(Class<? extends IoFilter> filterType);
+
+    /**
+     * Returns the {@link NextFilter} of the {@link IoFilter} with the
+     * specified <tt>name</tt> in this chain.
+     * @return <tt>null</tt> if there's no such name in this chain
+     */
+    NextFilter getNextFilter(String name);
+
+    /**
+     * Returns the {@link NextFilter} of the specified {@link IoFilter}
+     * in this chain.
+     * @return <tt>null</tt> if there's no such name in this chain
+     */
+    NextFilter getNextFilter(IoFilter filter);
+
+    /**
+     * Returns the {@link NextFilter} of the specified <tt>filterType</tt>
+     * in this chain.  If there's more than one filter with the specified
+     * type, the first match will be chosen.
+     * @return <tt>null</tt> if there's no such name in this chain
+     */
+    NextFilter getNextFilter(Class<? extends IoFilter> filterType);
+
+    /**
+     * Returns the list of all {@link Entry}s this chain contains.
+     */
+    List<Entry> getAll();
+
+    /**
+     * Returns the reversed list of all {@link Entry}s this chain contains.
+     */
+    List<Entry> getAllReversed();
+
+    /**
+     * Returns <tt>true</tt> if this chain contains an {@link IoFilter} with the
+     * specified <tt>name</tt>.
+     */
+    boolean contains(String name);
+
+    /**
+     * Returns <tt>true</tt> if this chain contains the specified <tt>filter</tt>.
+     */
+    boolean contains(IoFilter filter);
+
+    /**
+     * Returns <tt>true</tt> if this chain contains an {@link IoFilter} of the
+     * specified <tt>filterType</tt>.
+     */
+    boolean contains(Class<? extends IoFilter> filterType);
+
+    /**
+     * Adds the specified filter with the specified name at the beginning of this chain.
+     * @throws IoFilterLifeCycleException
+     *             if {@link IoFilter#onPostAdd(IoFilterChain, String, NextFilter)} or
+     *             {@link IoFilter#init()} throws an exception.
+     */
+    void addFirst(String name, IoFilter filter);
+
+    /**
+     * Adds the specified filter with the specified name at the end of this chain.
+     * @throws IoFilterLifeCycleException
+     *             if {@link IoFilter#onPostAdd(IoFilterChain, String, NextFilter)} or
+     *             {@link IoFilter#init()} throws an exception.
+     */
+    void addLast(String name, IoFilter filter);
+
+    /**
+     * Adds the specified filter with the specified name just before the filter whose name is
+     * <code>baseName</code> in this chain.
+     * @throws IoFilterLifeCycleException
+     *             if {@link IoFilter#onPostAdd(IoFilterChain, String, NextFilter)} or
+     *             {@link IoFilter#init()} throws an exception.
+     */
+    void addBefore(String baseName, String name, IoFilter filter);
+
+    /**
+     * Adds the specified filter with the specified name just after the filter whose name is
+     * <code>baseName</code> in this chain.
+     * @throws IoFilterLifeCycleException
+     *             if {@link IoFilter#onPostAdd(IoFilterChain, String, NextFilter)} or
+     *             {@link IoFilter#init()} throws an exception.
+     */
+    void addAfter(String baseName, String name, IoFilter filter);
+
+    /**
+     * Replace the filter with the specified name with the specified new
+     * filter.
+     *
+     * @return the old filter
+     * @throws IllegalArgumentException if there's no such filter
+     */
+    IoFilter replace(String name, IoFilter newFilter);
+
+    /**
+     * Replace the filter with the specified name with the specified new
+     * filter.
+     *
+     * @throws IllegalArgumentException if there's no such filter
+     */
+    void replace(IoFilter oldFilter, IoFilter newFilter);
+
+    /**
+     * Replace the filter of the specified type with the specified new
+     * filter.  If there's more than one filter with the specified type,
+     * the first match will be replaced.
+     *
+     * @throws IllegalArgumentException if there's no such filter
+     */
+    IoFilter replace(Class<? extends IoFilter> oldFilterType, IoFilter newFilter);
+
+    /**
+     * Removes the filter with the specified name from this chain.
+     * @throws IoFilterLifeCycleException
+     *             if {@link IoFilter#onPostRemove(IoFilterChain, String, NextFilter)} or
+     *             {@link IoFilter#destroy()} throws an exception.
+     */
+    IoFilter remove(String name);
+
+    /**
+     * Replace the filter with the specified name with the specified new
+     * filter.
+     *
+     * @throws IllegalArgumentException if there's no such filter
+     */
+    void remove(IoFilter filter);
+
+    /**
+     * Replace the filter of the specified type with the specified new
+     * filter.  If there's more than one filter with the specified type,
+     * the first match will be replaced.
+     *
+     * @throws IllegalArgumentException if there's no such filter
+     */
+    IoFilter remove(Class<? extends IoFilter> filterType);
+
+    /**
+     * Removes all filters added to this chain.
+     * @throws Exception if {@link IoFilter#onPostRemove(IoFilterChain, String, NextFilter)} thrown an exception.
+     */
+    void clear() throws Exception;
+
+    /**
+     * Fires a {@link IoHandler#sessionCreated(IoSession)} event.  Most users don't need to
+     * call this method at all.  Please use this method only when you implement a new transport
+     * or fire a virtual event.
+     */
+    public void fireSessionCreated();
+
+    /**
+     * Fires a {@link IoHandler#sessionOpened(IoSession)} event.  Most users don't need to call
+     * this method at all.  Please use this method only when you implement a new transport or
+     * fire a virtual event.
+     */
+    public void fireSessionOpened();
+
+    /**
+     * Fires a {@link IoHandler#sessionClosed(IoSession)} event.  Most users don't need to call
+     * this method at all.  Please use this method only when you implement a new transport or
+     * fire a virtual event.
+     */
+    public void fireSessionClosed();
+
+    /**
+     * Fires a {@link IoHandler#sessionIdle(IoSession, IdleStatus)} event.  Most users don't
+     * need to call this method at all.  Please use this method only when you implement a new
+     * transport or fire a virtual event.
+     */
+    public void fireSessionIdle(IdleStatus status);
+
+    /**
+     * Fires a {@link #fireMessageReceived(Object)} event.  Most users don't need to
+     * call this method at all.  Please use this method only when you implement a new transport
+     * or fire a virtual event.
+     */
+    public void fireMessageReceived(Object message);
+
+    /**
+     * Fires a {@link IoHandler#sessionOpened(IoSession)} event.  Most users don't need to call
+     * this method at all.  Please use this method only when you implement a new transport or
+     * fire a virtual event.
+     */
+    public void fireMessageSent(WriteRequest request);
+
+    /**
+     * Fires a {@link IoHandler#exceptionCaught(IoSession, Throwable)} event.  Most users don't
+     * need to call this method at all.  Please use this method only when you implement a new
+     * transport or fire a virtual event.
+     */
+    public void fireExceptionCaught(Throwable cause);
+
+    /**
+     * Fires a {@link IoSession#write(Object)} event.  Most users don't need to call this
+     * method at all.  Please use this method only when you implement a new transport or fire a
+     * virtual event.
+     */
+    public void fireFilterWrite(WriteRequest writeRequest);
+
+    /**
+     * Fires a {@link IoSession#close()} event.  Most users don't need to call this method at
+     * all.  Please use this method only when you implement a new transport or fire a virtual
+     * event.
+     */
+    public void fireFilterClose();
+
+    /**
+     * Fires a {@link IoSession#setTrafficMask(TrafficMask)} event.  Most users don't need to call this method at
+     * all.  Please use this method only when you implement a new transport or fire a virtual
+     * event.
+     */
+    public void fireFilterSetTrafficMask(TrafficMask trafficMask);
+
+    /**
+     * Represents a name-filter pair that an {@link IoFilterChain} contains.
+     *
+     * @author The Apache MINA Project (dev@mina.apache.org)
+     * @version $Rev: 593474 $, $Date: 2007-11-09 11:14:12 +0100 (Fri, 09 Nov 2007) $
+     */
+    public interface Entry {
+        /**
+         * Returns the name of the filter.
+         */
+        String getName();
+
+        /**
+         * Returns the filter.
+         */
+        IoFilter getFilter();
+
+        /**
+         * Returns the {@link NextFilter} of the filter.
+         *
+         * @throws IllegalStateException if the {@link NextFilter} is not available
+         */
+        NextFilter getNextFilter();
+        
+        /**
+         * Adds the specified filter with the specified name just before this entry.
+         * @throws IoFilterLifeCycleException
+         *             if {@link IoFilter#onPostAdd(IoFilterChain, String, NextFilter)} or
+         *             {@link IoFilter#init()} throws an exception.
+         */
+        void addBefore(String name, IoFilter filter);
+
+        /**
+         * Adds the specified filter with the specified name just after this entry.
+         * @throws IoFilterLifeCycleException
+         *             if {@link IoFilter#onPostAdd(IoFilterChain, String, NextFilter)} or
+         *             {@link IoFilter#init()} throws an exception.
+         */
+        void addAfter(String name, IoFilter filter);
+
+        /**
+         * Replace the filter of this entry with the specified new filter.
+         *
+         * @throws IllegalArgumentException if there's no such filter
+         */
+        void replace(IoFilter newFilter);
+        
+        /**
+         * Removes this entry from the chain it belongs to.
+         */
+        void remove();
+    }
+}

Added: mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterChainBuilder.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterChainBuilder.java?rev=671108&view=auto
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterChainBuilder.java (added)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterChainBuilder.java Tue Jun 24 02:55:42 2008
@@ -0,0 +1,58 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.filterchain;
+
+import org.apache.mina.common.session.IoSession;
+
+/**
+ * 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 MINA Project (dev@mina.apache.org)
+ * @version $Rev: 576217 $, $Date: 2007-09-17 01:55:27 +0200 (Mon, 17 Sep 2007) $
+ */
+public interface IoFilterChainBuilder {
+    /**
+     * An implementation which does nothing.
+     */
+    IoFilterChainBuilder NOOP = new IoFilterChainBuilder() {
+        public void buildFilterChain(IoFilterChain chain) throws Exception {
+        }
+
+        @Override
+        public String toString() {
+            return "NOOP";
+        }
+    };
+
+    /**
+     * Modifies the specified <tt>chain</tt>.
+     */
+    void buildFilterChain(IoFilterChain chain) throws Exception;
+}

Added: mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterEvent.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterEvent.java?rev=671108&view=auto
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterEvent.java (added)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterEvent.java Tue Jun 24 02:55:42 2008
@@ -0,0 +1,93 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.filterchain;
+
+import org.apache.mina.common.session.TrafficMask;
+import org.apache.mina.common.filterchain.IoFilter.NextFilter;
+import org.apache.mina.common.session.IdleStatus;
+import org.apache.mina.common.session.IoEvent;
+import org.apache.mina.common.session.IoEventType;
+import org.apache.mina.common.session.IoSession;
+import org.apache.mina.common.write.WriteRequest;
+
+/**
+ * An I/O event or an I/O request that MINA provides for {@link IoFilter}s.
+ * Most users won't need to use this class.  It is usually used by internal
+ * components to store I/O events.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev: 591770 $, $Date: 2007-11-04 13:22:44 +0100 (Sun, 04 Nov 2007) $
+ */
+public class IoFilterEvent extends IoEvent {
+
+    private final NextFilter nextFilter;
+
+    public IoFilterEvent(NextFilter nextFilter, IoEventType type,
+            IoSession session, Object parameter) {
+        super(type, session, parameter);
+
+        if (nextFilter == null) {
+            throw new NullPointerException("nextFilter");
+        }
+        this.nextFilter = nextFilter;
+    }
+
+    public NextFilter getNextFilter() {
+        return nextFilter;
+    }
+
+    @Override
+    public void fire() {
+        switch (getType()) {
+        case MESSAGE_RECEIVED:
+            getNextFilter().messageReceived(getSession(), getParameter());
+            break;
+        case MESSAGE_SENT:
+            getNextFilter().messageSent(getSession(), (WriteRequest) getParameter());
+            break;
+        case WRITE:
+            getNextFilter().filterWrite(getSession(), (WriteRequest) getParameter());
+            break;
+        case SET_TRAFFIC_MASK:
+            getNextFilter().filterSetTrafficMask(getSession(), (TrafficMask) getParameter());
+            break;
+        case CLOSE:
+            getNextFilter().filterClose(getSession());
+            break;
+        case EXCEPTION_CAUGHT:
+            getNextFilter().exceptionCaught(getSession(), (Throwable) getParameter());
+            break;
+        case SESSION_IDLE:
+            getNextFilter().sessionIdle(getSession(), (IdleStatus) getParameter());
+            break;
+        case SESSION_OPENED:
+            getNextFilter().sessionOpened(getSession());
+            break;
+        case SESSION_CREATED:
+            getNextFilter().sessionCreated(getSession());
+            break;
+        case SESSION_CLOSED:
+            getNextFilter().sessionClosed(getSession());
+            break;
+        default:
+            throw new IllegalArgumentException("Unknown event type: " + getType());
+        }
+    }
+}

Added: mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterLifeCycleException.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterLifeCycleException.java?rev=671108&view=auto
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterLifeCycleException.java (added)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/filterchain/IoFilterLifeCycleException.java Tue Jun 24 02:55:42 2008
@@ -0,0 +1,48 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.filterchain;
+
+
+/**
+ * A {@link RuntimeException} which is thrown when {@link IoFilter#init()}
+ * or {@link IoFilter#onPostAdd(IoFilterChain, String, org.apache.mina.common.filterchain.IoFilter.NextFilter)}
+ * failed.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev: 576217 $, $Date: 2007-09-17 01:55:27 +0200 (Mon, 17 Sep 2007) $
+ */
+public class IoFilterLifeCycleException extends RuntimeException {
+    private static final long serialVersionUID = -5542098881633506449L;
+
+    public IoFilterLifeCycleException() {
+    }
+
+    public IoFilterLifeCycleException(String message) {
+        super(message);
+    }
+
+    public IoFilterLifeCycleException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public IoFilterLifeCycleException(Throwable cause) {
+        super(cause);
+    }
+}

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/future/CloseFuture.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/CloseFuture.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/future/CloseFuture.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/future/CloseFuture.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/CloseFuture.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/CloseFuture.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/future/CloseFuture.java Tue Jun 24 02:55:42 2008
@@ -17,7 +17,8 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.future;
+
 
 /**
  * An {@link IoFuture} for asynchronous close requests.

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/future/CompositeIoFuture.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/CompositeIoFuture.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/future/CompositeIoFuture.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/future/CompositeIoFuture.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/CompositeIoFuture.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/CompositeIoFuture.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/future/CompositeIoFuture.java Tue Jun 24 02:55:42 2008
@@ -17,10 +17,12 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.future;
 
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.mina.common.IoUtil;
+
 /**
  * An {@link IoFuture} of {@link IoFuture}s.  It is useful when you want to
  * get notified when all {@link IoFuture}s are complete.  It is not recommended

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/future/ConnectFuture.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/ConnectFuture.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/future/ConnectFuture.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/future/ConnectFuture.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/ConnectFuture.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/ConnectFuture.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/future/ConnectFuture.java Tue Jun 24 02:55:42 2008
@@ -17,7 +17,9 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.future;
+
+import org.apache.mina.common.session.IoSession;
 
 /**
  * An {@link IoFuture} for asynchronous connect requests.

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultCloseFuture.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/DefaultCloseFuture.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultCloseFuture.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultCloseFuture.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/DefaultCloseFuture.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/DefaultCloseFuture.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultCloseFuture.java Tue Jun 24 02:55:42 2008
@@ -17,7 +17,9 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.future;
+
+import org.apache.mina.common.session.IoSession;
 
 
 /**

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultConnectFuture.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/DefaultConnectFuture.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultConnectFuture.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultConnectFuture.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/DefaultConnectFuture.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/DefaultConnectFuture.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultConnectFuture.java Tue Jun 24 02:55:42 2008
@@ -17,7 +17,10 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.future;
+
+import org.apache.mina.common.RuntimeIoException;
+import org.apache.mina.common.session.IoSession;
 
 
 /**

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultIoFuture.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/DefaultIoFuture.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultIoFuture.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultIoFuture.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/DefaultIoFuture.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/DefaultIoFuture.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultIoFuture.java Tue Jun 24 02:55:42 2008
@@ -17,12 +17,17 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.future;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.mina.common.ExceptionMonitor;
+import org.apache.mina.common.polling.AbstractPollingIoProcessor;
+import org.apache.mina.common.service.IoProcessor;
+import org.apache.mina.common.session.IoSession;
+
 
 /**
  * A default implementation of {@link IoFuture} associated with
@@ -262,7 +267,7 @@
     /**
      * Sets the result of the asynchronous operation, and mark it as finished.
      */
-    protected void setValue(Object newValue) {
+    public void setValue(Object newValue) {
         synchronized (lock) {
             // Allow only once.
             if (ready) {

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultReadFuture.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/DefaultReadFuture.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultReadFuture.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultReadFuture.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/DefaultReadFuture.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/DefaultReadFuture.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultReadFuture.java Tue Jun 24 02:55:42 2008
@@ -17,10 +17,13 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.future;
 
 import java.io.IOException;
 
+import org.apache.mina.common.RuntimeIoException;
+import org.apache.mina.common.session.IoSession;
+
 
 /**
  * A default implementation of {@link WriteFuture}.

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultWriteFuture.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/DefaultWriteFuture.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultWriteFuture.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultWriteFuture.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/DefaultWriteFuture.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/DefaultWriteFuture.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/future/DefaultWriteFuture.java Tue Jun 24 02:55:42 2008
@@ -17,7 +17,9 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.future;
+
+import org.apache.mina.common.session.IoSession;
 
 
 /**

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/future/IoFuture.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/IoFuture.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/future/IoFuture.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/future/IoFuture.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/IoFuture.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/IoFuture.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/future/IoFuture.java Tue Jun 24 02:55:42 2008
@@ -17,10 +17,12 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.future;
 
 import java.util.concurrent.TimeUnit;
 
+import org.apache.mina.common.session.IoSession;
+
 /**
  * Represents the completion of an asynchronous I/O operation on an 
  * {@link IoSession}.

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/future/IoFutureListener.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/IoFutureListener.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/future/IoFutureListener.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/future/IoFutureListener.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/IoFutureListener.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/IoFutureListener.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/future/IoFutureListener.java Tue Jun 24 02:55:42 2008
@@ -17,10 +17,12 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.future;
 
 import java.util.EventListener;
 
+import org.apache.mina.common.session.IoSession;
+
 /**
  * Something interested in being notified when the completion
  * of an asynchronous I/O operation : {@link IoFuture}. 

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/future/ReadFuture.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/ReadFuture.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/future/ReadFuture.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/future/ReadFuture.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/ReadFuture.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/ReadFuture.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/future/ReadFuture.java Tue Jun 24 02:55:42 2008
@@ -17,7 +17,9 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.future;
+
+import org.apache.mina.common.session.IoSession;
 
 /**
  * An {@link IoFuture} for {@link IoSession#read() asynchronous read requests}. 

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/future/WriteFuture.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/WriteFuture.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/future/WriteFuture.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/future/WriteFuture.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/WriteFuture.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/WriteFuture.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/future/WriteFuture.java Tue Jun 24 02:55:42 2008
@@ -17,7 +17,8 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.future;
+
 
 /**
  * An {@link IoFuture} for asynchronous write requests.

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/polling/AbstractPollingConnectionlessIoAcceptor.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/AbstractPollingConnectionlessIoAcceptor.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/polling/AbstractPollingConnectionlessIoAcceptor.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/polling/AbstractPollingConnectionlessIoAcceptor.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/AbstractPollingConnectionlessIoAcceptor.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/AbstractPollingConnectionlessIoAcceptor.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/polling/AbstractPollingConnectionlessIoAcceptor.java Tue Jun 24 02:55:42 2008
@@ -17,7 +17,7 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.polling;
 
 import java.net.SocketAddress;
 import java.util.Collections;
@@ -31,6 +31,23 @@
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.Executor;
 
+import org.apache.mina.common.ExceptionMonitor;
+import org.apache.mina.common.RuntimeIoException;
+import org.apache.mina.common.buffer.IoBuffer;
+import org.apache.mina.common.future.IoFuture;
+import org.apache.mina.common.service.AbstractIoAcceptor;
+import org.apache.mina.common.service.IoAcceptor;
+import org.apache.mina.common.service.IoProcessor;
+import org.apache.mina.common.service.AbstractIoAcceptor.AcceptorOperationFuture;
+import org.apache.mina.common.session.AbstractIoSession;
+import org.apache.mina.common.session.ExpiringSessionRecycler;
+import org.apache.mina.common.session.IdleStatusChecker;
+import org.apache.mina.common.session.IoSession;
+import org.apache.mina.common.session.IoSessionConfig;
+import org.apache.mina.common.session.IoSessionRecycler;
+import org.apache.mina.common.write.WriteRequest;
+import org.apache.mina.common.write.WriteRequestQueue;
+
 /**
  * {@link IoAcceptor} for datagram transport (UDP/IP).
  *

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/polling/AbstractPollingIoAcceptor.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/AbstractPollingIoAcceptor.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/polling/AbstractPollingIoAcceptor.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/polling/AbstractPollingIoAcceptor.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/AbstractPollingIoAcceptor.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/AbstractPollingIoAcceptor.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/polling/AbstractPollingIoAcceptor.java Tue Jun 24 02:55:42 2008
@@ -17,7 +17,7 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.polling;
 
 import java.net.SocketAddress;
 import java.util.Collections;
@@ -32,6 +32,19 @@
 import java.util.concurrent.Executor;
 import java.util.concurrent.Executors;
 
+import org.apache.mina.common.ExceptionMonitor;
+import org.apache.mina.common.RuntimeIoException;
+import org.apache.mina.common.filterchain.IoFilter;
+import org.apache.mina.common.future.IoFuture;
+import org.apache.mina.common.service.AbstractIoAcceptor;
+import org.apache.mina.common.service.IoAcceptor;
+import org.apache.mina.common.service.IoHandler;
+import org.apache.mina.common.service.IoProcessor;
+import org.apache.mina.common.service.SimpleIoProcessorPool;
+import org.apache.mina.common.service.AbstractIoAcceptor.AcceptorOperationFuture;
+import org.apache.mina.common.session.AbstractIoSession;
+import org.apache.mina.common.session.IoSession;
+import org.apache.mina.common.session.IoSessionConfig;
 import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 
 /**

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/polling/AbstractPollingIoConnector.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/AbstractPollingIoConnector.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/polling/AbstractPollingIoConnector.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/polling/AbstractPollingIoConnector.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/AbstractPollingIoConnector.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/AbstractPollingIoConnector.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/polling/AbstractPollingIoConnector.java Tue Jun 24 02:55:42 2008
@@ -17,7 +17,7 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.polling;
 
 import java.net.ConnectException;
 import java.net.SocketAddress;
@@ -27,6 +27,22 @@
 import java.util.concurrent.Executor;
 import java.util.concurrent.Executors;
 
+import org.apache.mina.common.ExceptionMonitor;
+import org.apache.mina.common.RuntimeIoException;
+import org.apache.mina.common.filterchain.IoFilter;
+import org.apache.mina.common.future.ConnectFuture;
+import org.apache.mina.common.future.DefaultConnectFuture;
+import org.apache.mina.common.future.IoFuture;
+import org.apache.mina.common.service.AbstractIoConnector;
+import org.apache.mina.common.service.IoConnector;
+import org.apache.mina.common.service.IoHandler;
+import org.apache.mina.common.service.IoProcessor;
+import org.apache.mina.common.service.SimpleIoProcessorPool;
+import org.apache.mina.common.session.AbstractIoSession;
+import org.apache.mina.common.session.IoSession;
+import org.apache.mina.common.session.IoSessionConfig;
+import org.apache.mina.common.session.IoSessionInitializer;
+
 /**
  * TODO Add documentation
  * 

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/polling/AbstractPollingIoProcessor.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/AbstractPollingIoProcessor.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/polling/AbstractPollingIoProcessor.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/polling/AbstractPollingIoProcessor.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/AbstractPollingIoProcessor.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/AbstractPollingIoProcessor.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/polling/AbstractPollingIoProcessor.java Tue Jun 24 02:55:42 2008
@@ -17,7 +17,7 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.polling;
 
 import java.io.IOException;
 import java.nio.channels.SelectionKey;
@@ -31,6 +31,18 @@
 import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.mina.common.ExceptionMonitor;
+import org.apache.mina.common.buffer.IoBuffer;
+import org.apache.mina.common.file.FileRegion;
+import org.apache.mina.common.future.DefaultIoFuture;
+import org.apache.mina.common.service.AbstractIoService;
+import org.apache.mina.common.service.IoProcessor;
+import org.apache.mina.common.session.AbstractIoSession;
+import org.apache.mina.common.session.IdleStatusChecker;
+import org.apache.mina.common.session.IoSessionConfig;
+import org.apache.mina.common.write.WriteRequest;
+import org.apache.mina.common.write.WriteRequestQueue;
+import org.apache.mina.common.write.WriteToClosedSessionException;
 import org.apache.mina.util.NamePreservingRunnable;
 
 /**

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/service/AbstractIoAcceptor.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoAcceptor.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/service/AbstractIoAcceptor.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/service/AbstractIoAcceptor.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoAcceptor.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoAcceptor.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/service/AbstractIoAcceptor.java Tue Jun 24 02:55:42 2008
@@ -17,7 +17,7 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.service;
 
 import java.io.IOException;
 import java.net.SocketAddress;
@@ -30,6 +30,10 @@
 import java.util.concurrent.Executor;
 import java.util.concurrent.Executors;
 
+import org.apache.mina.common.RuntimeIoException;
+import org.apache.mina.common.session.IoSession;
+import org.apache.mina.common.session.IoSessionConfig;
+
 
 /**
  * A base implementation of {@link IoAcceptor}.
@@ -400,7 +404,7 @@
         }
     }
     
-    protected static class AcceptorOperationFuture extends ServiceOperationFuture {
+    public static class AcceptorOperationFuture extends ServiceOperationFuture {
         private final List<SocketAddress> localAddresses;
         
         public AcceptorOperationFuture(List<? extends SocketAddress> localAddresses) {

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/service/AbstractIoConnector.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoConnector.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/service/AbstractIoConnector.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/service/AbstractIoConnector.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoConnector.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoConnector.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/service/AbstractIoConnector.java Tue Jun 24 02:55:42 2008
@@ -17,12 +17,20 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.service;
 
 import java.net.SocketAddress;
 import java.util.concurrent.Executor;
 import java.util.concurrent.Executors;
 
+import org.apache.mina.common.future.ConnectFuture;
+import org.apache.mina.common.future.IoFuture;
+import org.apache.mina.common.future.IoFutureListener;
+import org.apache.mina.common.session.IdleStatus;
+import org.apache.mina.common.session.IoSession;
+import org.apache.mina.common.session.IoSessionConfig;
+import org.apache.mina.common.session.IoSessionInitializer;
+
 /**
  * A base implementation of {@link IoConnector}.
  *

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/service/AbstractIoService.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoService.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/service/AbstractIoService.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/service/AbstractIoService.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoService.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/AbstractIoService.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/service/AbstractIoService.java Tue Jun 24 02:55:42 2008
@@ -17,7 +17,7 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.service;
 
 import java.util.AbstractSet;
 import java.util.Iterator;
@@ -31,6 +31,24 @@
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.mina.common.ExceptionMonitor;
+import org.apache.mina.common.IoUtil;
+import org.apache.mina.common.filterchain.DefaultIoFilterChain;
+import org.apache.mina.common.filterchain.DefaultIoFilterChainBuilder;
+import org.apache.mina.common.filterchain.IoFilterChainBuilder;
+import org.apache.mina.common.future.ConnectFuture;
+import org.apache.mina.common.future.DefaultIoFuture;
+import org.apache.mina.common.future.IoFuture;
+import org.apache.mina.common.future.WriteFuture;
+import org.apache.mina.common.session.AbstractIoSession;
+import org.apache.mina.common.session.DefaultIoSessionDataStructureFactory;
+import org.apache.mina.common.session.IdleStatus;
+import org.apache.mina.common.session.IdleStatusChecker;
+import org.apache.mina.common.session.IoSession;
+import org.apache.mina.common.session.IoSessionConfig;
+import org.apache.mina.common.session.IoSessionDataStructureFactory;
+import org.apache.mina.common.session.IoSessionInitializationException;
+import org.apache.mina.common.session.IoSessionInitializer;
 import org.apache.mina.util.NamePreservingRunnable;
 
 
@@ -388,7 +406,7 @@
         return readBytes.get();
     }
 
-    protected final void increaseReadBytes(long increment, long currentTime) {
+    public final void increaseReadBytes(long increment, long currentTime) {
         readBytes.addAndGet(increment);
         lastReadTime = currentTime;
         idleCountForBoth = 0;
@@ -402,7 +420,7 @@
         return readMessages.get();
     }
 
-    protected final void increaseReadMessages(long currentTime) {
+    public final void increaseReadMessages(long currentTime) {
         readMessages.incrementAndGet();
         lastReadTime = currentTime;
         idleCountForBoth = 0;
@@ -551,7 +569,7 @@
         return scheduledWriteBytes.get();
     }
 
-    protected final void increaseScheduledWriteBytes(int increment) {
+    public final void increaseScheduledWriteBytes(int increment) {
         scheduledWriteBytes.addAndGet(increment);
     }
 
@@ -562,11 +580,11 @@
         return scheduledWriteMessages.get();
     }
 
-    protected final void increaseScheduledWriteMessages() {
+    public final void increaseScheduledWriteMessages() {
         scheduledWriteMessages.incrementAndGet();
     }
 
-    protected final void decreaseScheduledWriteMessages() {
+    public final void decreaseScheduledWriteMessages() {
         scheduledWriteMessages.decrementAndGet();
     }
 
@@ -613,7 +631,7 @@
         return writtenBytes.get();
     }
 
-    protected final void increaseWrittenBytes(long increment, long currentTime) {
+    public final void increaseWrittenBytes(long increment, long currentTime) {
         writtenBytes.addAndGet(increment);
         lastWriteTime = currentTime;
         idleCountForBoth = 0;
@@ -627,7 +645,7 @@
         return writtenMessages.get();
     }
 
-    protected final void increaseWrittenMessages(long currentTime) {
+    public final void increaseWrittenMessages(long currentTime) {
         writtenMessages.incrementAndGet();
         lastWriteTime = currentTime;
         idleCountForBoth = 0;
@@ -761,7 +779,7 @@
         }
     }
 
-    protected final void notifyIdleness(long currentTime) {
+    public final void notifyIdleness(long currentTime) {
         updateThroughput(currentTime);
 
         synchronized (idlenessCheckLock) {
@@ -945,7 +963,7 @@
         };
     }
 
-    protected final IoServiceListenerSupport getListeners() {
+    public final IoServiceListenerSupport getListeners() {
         return listeners;
     }
 

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/service/DefaultTransportMetadata.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/DefaultTransportMetadata.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/service/DefaultTransportMetadata.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/service/DefaultTransportMetadata.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/DefaultTransportMetadata.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/DefaultTransportMetadata.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/service/DefaultTransportMetadata.java Tue Jun 24 02:55:42 2008
@@ -17,12 +17,13 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.service;
 
 import java.net.SocketAddress;
 import java.util.Collections;
 import java.util.Set;
 
+import org.apache.mina.common.session.IoSessionConfig;
 import org.apache.mina.util.IdentityHashSet;
 
 

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/service/IoAcceptor.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/IoAcceptor.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/service/IoAcceptor.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/service/IoAcceptor.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/IoAcceptor.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/IoAcceptor.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/service/IoAcceptor.java Tue Jun 24 02:55:42 2008
@@ -17,13 +17,15 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.service;
 
 import java.io.IOException;
 import java.net.SocketAddress;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.mina.common.session.IoSession;
+
 /**
  * Accepts incoming connection, communicates with clients, and fires events to
  * {@link IoHandler}s.

Copied: mina/trunk/core/src/main/java/org/apache/mina/common/service/IoConnector.java (from r669829, mina/trunk/core/src/main/java/org/apache/mina/common/IoConnector.java)
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/service/IoConnector.java?p2=mina/trunk/core/src/main/java/org/apache/mina/common/service/IoConnector.java&p1=mina/trunk/core/src/main/java/org/apache/mina/common/IoConnector.java&r1=669829&r2=671108&rev=671108&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/IoConnector.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/service/IoConnector.java Tue Jun 24 02:55:42 2008
@@ -17,10 +17,14 @@
  *  under the License.
  *
  */
-package org.apache.mina.common;
+package org.apache.mina.common.service;
 
 import java.net.SocketAddress;
 
+import org.apache.mina.common.future.ConnectFuture;
+import org.apache.mina.common.session.IoSession;
+import org.apache.mina.common.session.IoSessionInitializer;
+
 /**
  * Connects to endpoint, communicates with the server, and fires events to
  * {@link IoHandler}s.