You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2005/12/01 06:19:07 UTC

svn commit: r350169 [5/16] - in /directory/network: branches/chain_refactor/src/java/org/apache/mina/common/ trunk/src/examples/org/apache/mina/examples/echoserver/ trunk/src/examples/org/apache/mina/examples/httpserver/ trunk/src/examples/org/apache/m...

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoFilterChain.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoFilterChain.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoFilterChain.java Wed Nov 30 21:17:41 2005
@@ -1,129 +1,159 @@
-/*
- *   @(#) $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;
-
-import java.util.List;
-
-import org.apache.mina.common.IoFilter.NextFilter;
-
-/**
- * A container of {@link IoFilter}s that forwards {@link IoHandler} events
- * to the consisting filters and terminal {@link IoHandler} sequentially.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public interface IoFilterChain {
-    /**
-     * Returns the parent of this chain.
-     * @return {@link IoSessionManager} or {@link IoSession}
-     */
-    Object getParent();
-    
-    /**
-     * Returns the {@link IoFilter} with the specified <tt>name</tt> in this chain.
-     * @return <tt>null</tt> if there's no such filter in this chain
-     */
-    IoFilter get( String name );
-    
-    /**
-     * Returns the name of the specified {@link IoFilter} in this chain.
-     * @return <tt>null</tt> if there's no such filter in this chain.
-     */
-    String getName( IoFilter filter );
-    
-    /**
-     * Returns the {@link NextFilter} of the {@link IoFilter} with the specified
-     * <tt>name</tt> in this chain.
-     */
-    NextFilter getNextFilter( String name );
-
-    /**
-     * Returns the {@link NextFilter} of the specified <tt>filter</tt> in this chain.
-     */
-    NextFilter getNextFilter( IoFilter filter );
-
-    /**
-     * Returns the list of all filters this chain contains.
-     */
-    List getAll();
-    
-    /**
-     * Returns the reversed list of all filters this chain contains.
-     */
-    List getAllReversed();
-
-    /**
-     * Adds the specified filter with the specified name at the beginning of this chain.
-     * @throws Exception if {@link IoFilter#init(IoFilterChain, NextFilter)} thrown an exception.
-     */
-    void addFirst( String name, IoFilter filter ) throws Exception;
-
-    /**
-     * Adds the specified filter with the specified name at the end of this chain.
-     * @throws Exception if {@link IoFilter#init(IoFilterChain, NextFilter)} thrown an exception.
-     */
-    void addLast( String name, IoFilter filter ) throws Exception;
-
-    /**
-     * Adds the specified filter with the specified name just before the filter whose name is
-     * <code>baseName</code> in this chain.
-     * @throws Exception if {@link IoFilter#init(IoFilterChain, NextFilter)} thrown an exception.
-     */
-    void addBefore( String baseName, String name, IoFilter filter ) throws Exception;
-
-    /**
-     * Adds the specified filter with the specified name just before the specified
-     * <code>baseFilter</code> in this chain.
-     * @throws Exception if {@link IoFilter#init(IoFilterChain, NextFilter)} thrown an exception.
-     */
-    void addBefore( IoFilter baseFilter, String name, IoFilter filter ) throws Exception;
-
-    /**
-     * Adds the specified filter with the specified name just after the filter whose name is
-     * <code>baseName</code> in this chain.
-     * @throws Exception if {@link IoFilter#init(IoFilterChain, NextFilter)} thrown an exception.
-     */
-    void addAfter( String baseName, String name, IoFilter filter ) throws Exception;
-
-    /**
-     * Adds the specified filter with the specified name just after the
-     * specified <tt>baseFilter</tt> in this chain.
-     * @throws Exception if {@link IoFilter#init(IoFilterChain, NextFilter)} thrown an exception.
-     */
-    void addAfter( IoFilter baseFilter, String name, IoFilter filter ) throws Exception;
-
-    /**
-     * Removes the filter with the specified name from this chain.
-     * @throws Exception if {@link IoFilter#destroy(IoFilterChain, NextFilter)} thrown an exception.
-     */
-    IoFilter remove( String name ) throws Exception;
-
-    /**
-     * Removes the specifiec <tt>filter</tt> from this chain.
-     * @throws Exception if {@link IoFilter#destroy(IoFilterChain, NextFilter)} thrown an exception.
-     */
-    void remove( IoFilter filter ) throws Exception;
-
-    /**
-     * Removes all filters added to this chain.
-     * @throws Exception if {@link IoFilter#destroy(IoFilterChain, NextFilter)} thrown an exception.
-     */
-    void clear() throws Exception;
-}
+/*
+ *   @(#) $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;
+
+import java.util.List;
+
+import org.apache.mina.common.IoFilter.NextFilter;
+
+/**
+ * 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 Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+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 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 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 list of all {@link Entry}s this chain contains.
+     */
+    List getAll();
+    
+    /**
+     * Returns the reversed list of all {@link Entry}s this chain contains.
+     */
+    List 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 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 );
+
+    /**
+     * 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 );
+
+    /**
+     * Removes all filters added to this chain.
+     * @throws Exception if {@link IoFilter#onPostRemove(IoFilterChain, String, NextFilter)} thrown an exception.
+     */
+    void clear() throws Exception;
+    
+    /**
+     * Represents a name-filter pair that an {@link IoFilterChain} contains.
+     *
+     * @author The Apache Directory Project (dev@directory.apache.org)
+     * @version $Rev$, $Date$
+     */
+    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();
+    }
+}

Added: directory/network/trunk/src/java/org/apache/mina/common/IoFilterChainBuilder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoFilterChainBuilder.java?rev=350169&view=auto
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoFilterChainBuilder.java (added)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoFilterChainBuilder.java Wed Nov 30 21:17:41 2005
@@ -0,0 +1,58 @@
+/*
+ *   @(#) $Id: IoFilterChainBuilder.java 349941 2005-11-30 13:10:31Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.mina.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: 349941 $, $Date: 2005-11-30 22:10:31 +0900 (Wed, 30 Nov 2005) $
+ */
+public interface IoFilterChainBuilder
+{
+    /**
+     * An implementation which does nothing.
+     */
+    IoFilterChainBuilder NOOP = new IoFilterChainBuilder()
+    {
+        public void buildFilterChain( IoFilterChain chain ) throws Exception
+        {
+        }
+        
+        public String toString()
+        {
+            return "NOOP";
+        }
+    };
+    
+    /**
+     * Modifies the specified <tt>chain</tt>.
+     */
+    void buildFilterChain( IoFilterChain chain ) throws Exception;
+}

Added: directory/network/trunk/src/java/org/apache/mina/common/IoFilterLifeCycleException.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoFilterLifeCycleException.java?rev=350169&view=auto
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoFilterLifeCycleException.java (added)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoFilterLifeCycleException.java Wed Nov 30 21:17:41 2005
@@ -0,0 +1,51 @@
+/*
+ *   @(#) $Id: IoFilterLifeCycleException.java 350147 2005-12-01 04:06:11Z trustin $
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.mina.common;
+
+/**
+ * A {@link RuntimeException} which is thrown when {@link IoFilter#init()}
+ * or {@link IoFilter#onPostAdd(IoFilterChain, String, org.apache.mina.common.IoFilter.NextFilter)}
+ * failed.
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev: 350147 $, $Date: 2005-12-01 13:06:11 +0900 $
+ */
+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 );
+    }
+}

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoHandler.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoHandler.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoHandler.java Wed Nov 30 21:17:41 2005
@@ -1,81 +1,81 @@
-/*
- *   @(#) $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;
-
-import java.io.IOException;
-
-/**
- * Handles all protocol events fired by MINA.
- * There are 6 event handler methods, and they are all invoked by MINA
- * automatically.
- * <p>
- * Please refer to
- * <a href="../../../../../xref-examples/org/apache/mina/examples/reverser/ReverseIoHandler.html"><code>ReverseIoHandler</code></a>
- * example.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- * 
- * @see IoHandlerAdapter
- */
-public interface IoHandler
-{
-    /**
-     * Invoked when the session is created.  Initialize default socket
-     * parameters and user-defined attributes here.
-     */
-    void sessionCreated( IoSession session ) throws Exception;
-    
-    /**
-     * Invoked when the connection is opened.  This method is not invoked if the
-     * transport type is UDP.
-     */
-    void sessionOpened( IoSession session ) throws Exception;
-
-    /**
-     * Invoked when the connection is closed.  This method is not invoked if the
-     * transport type is UDP.
-     */
-    void sessionClosed( IoSession session ) throws Exception;
-
-    /**
-     * Invoked when the connection is idle.  Refer to {@link IdleStatus}.  This
-     * method is not invoked if the transport type is UDP.
-     */
-    void sessionIdle( IoSession session, IdleStatus status ) throws Exception;
-
-    /**
-     * Invoked when any exception is thrown by user {@link IoHandler}
-     * implementation or by MINA.  If <code>cause</code> is instanceof
-     * {@link IOException}, MINA will close the connection automatically.
-     */
-    void exceptionCaught( IoSession session, Throwable cause ) throws Exception;
-
-    /**
-     * Invoked when protocol message is received.  Implement your protocol flow
-     * here.
-     */
-    void messageReceived( IoSession session, Object message ) throws Exception;
-
-    /**
-     * Invoked when protocol message that user requested by
-     * {@link IoSession#write(Object)} is sent out actually.
-     */
-    void messageSent( IoSession session, Object message ) throws Exception;
+/*
+ *   @(#) $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;
+
+import java.io.IOException;
+
+/**
+ * Handles all protocol events fired by MINA.
+ * There are 6 event handler methods, and they are all invoked by MINA
+ * automatically.
+ * <p>
+ * Please refer to
+ * <a href="../../../../../xref-examples/org/apache/mina/examples/reverser/ReverseIoHandler.html"><code>ReverseIoHandler</code></a>
+ * example.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ * 
+ * @see IoHandlerAdapter
+ */
+public interface IoHandler
+{
+    /**
+     * Invoked when the session is created.  Initialize default socket
+     * parameters and user-defined attributes here.
+     */
+    void sessionCreated( IoSession session ) throws Exception;
+    
+    /**
+     * Invoked when the connection is opened.  This method is not invoked if the
+     * transport type is UDP.
+     */
+    void sessionOpened( IoSession session ) throws Exception;
+
+    /**
+     * Invoked when the connection is closed.  This method is not invoked if the
+     * transport type is UDP.
+     */
+    void sessionClosed( IoSession session ) throws Exception;
+
+    /**
+     * Invoked when the connection is idle.  Refer to {@link IdleStatus}.  This
+     * method is not invoked if the transport type is UDP.
+     */
+    void sessionIdle( IoSession session, IdleStatus status ) throws Exception;
+
+    /**
+     * Invoked when any exception is thrown by user {@link IoHandler}
+     * implementation or by MINA.  If <code>cause</code> is instanceof
+     * {@link IOException}, MINA will close the connection automatically.
+     */
+    void exceptionCaught( IoSession session, Throwable cause ) throws Exception;
+
+    /**
+     * Invoked when protocol message is received.  Implement your protocol flow
+     * here.
+     */
+    void messageReceived( IoSession session, Object message ) throws Exception;
+
+    /**
+     * Invoked when protocol message that user requested by
+     * {@link IoSession#write(Object)} is sent out actually.
+     */
+    void messageSent( IoSession session, Object message ) throws Exception;
 }

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoHandlerAdapter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoHandlerAdapter.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoHandlerAdapter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoHandlerAdapter.java Wed Nov 30 21:17:41 2005
@@ -1,61 +1,61 @@
-/*
- *   @(#) $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;
-
-import org.apache.mina.util.SessionUtil;
-
-/**
- * An abstract adapter class for {@link IoHandler}.  You can extend this
- * class and selectively override required event handler methods only.  All
- * methods do nothing by default. 
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public class IoHandlerAdapter implements IoHandler
-{
-    public void sessionCreated( IoSession session ) throws Exception
-    {
-        SessionUtil.initialize( session );
-    }
-
-    public void sessionOpened( IoSession session ) throws Exception
-    {
-    }
-
-    public void sessionClosed( IoSession session ) throws Exception
-    {
-    }
-
-    public void sessionIdle( IoSession session, IdleStatus status ) throws Exception
-    {
-    }
-
-    public void exceptionCaught( IoSession session, Throwable cause ) throws Exception
-    {
-    }
-
-    public void messageReceived( IoSession session, Object message ) throws Exception
-    {
-    }
-
-    public void messageSent( IoSession session, Object message ) throws Exception
-    {
-    }
+/*
+ *   @(#) $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;
+
+import org.apache.mina.util.SessionUtil;
+
+/**
+ * An abstract adapter class for {@link IoHandler}.  You can extend this
+ * class and selectively override required event handler methods only.  All
+ * methods do nothing by default. 
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class IoHandlerAdapter implements IoHandler
+{
+    public void sessionCreated( IoSession session ) throws Exception
+    {
+        SessionUtil.initialize( session );
+    }
+
+    public void sessionOpened( IoSession session ) throws Exception
+    {
+    }
+
+    public void sessionClosed( IoSession session ) throws Exception
+    {
+    }
+
+    public void sessionIdle( IoSession session, IdleStatus status ) throws Exception
+    {
+    }
+
+    public void exceptionCaught( IoSession session, Throwable cause ) throws Exception
+    {
+    }
+
+    public void messageReceived( IoSession session, Object message ) throws Exception
+    {
+    }
+
+    public void messageSent( IoSession session, Object message ) throws Exception
+    {
+    }
 }

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoSession.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoSession.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoSession.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoSession.java Wed Nov 30 21:17:41 2005
@@ -1,291 +1,296 @@
-/*
- *   @(#) $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;
-
-import java.net.SocketAddress;
-import java.util.Set;
-
-/**
- * A handle which represents connection between two endpoints regardless of 
- * transport types.
- * <p>
- * Session provides user-defined attributes.  User-defined attributes are
- * application-specific data which is associated with a session.
- * It often contains objects that represents the state of a higher-level protocol
- * and becomes a way to exchange data between filters and handlers.
- * 
- * <h2>Adjusting Transport Type Specific Properties</h2>
- * <p>
- * You can simply downcast the session to an appropriate subclass.
- * </p>
- *   
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public interface IoSession {
-
-    /**
-     * Returns the {@link IoHandler} which handles this session.
-     */
-    IoHandler getHandler();
-
-    /**
-     * Returns the filter chain that only affects this session.
-     */
-    IoFilterChain getFilterChain();
-
-    /**
-     * Writes the specified <code>message</code> to remote peer.  This
-     * operation is asynchronous; {@link IoHandler#messageSent(IoSession, Object)}
-     * will be invoked when the message is actually sent to remote peer.
-     * You can also ait for the returned {@link WriteFuture} if you want
-     * to wait for the session actually closed.
-     */
-    WriteFuture write( Object message );
-
-    /**
-     * Closes this session immediately.  This operation is asynthronous.
-     * Wait for the returned {@link CloseFuture} if you want to wait for
-     * the session actually closed.
-     */
-    CloseFuture close();
-
-    /**
-     * Returns an attachment of this session.
-     * This method is identical with <tt>getAttribute( "" )</tt>.
-     */
-    Object getAttachment();
-
-    /**
-     * Sets an attachment of this session.
-     * This method is identical with <tt>setAttribute( "", attachment )</tt>.
-     * 
-     * @return Old attachment.  <tt>null</tt> if it is new.
-     */
-    Object setAttachment( Object attachment );
-    
-    /**
-     * Returns the value of user-defined attribute of this session.
-     * 
-     * @param key the key of the attribute
-     * @return <tt>null</tt> if there is no attribute with the specified key
-     */
-    Object getAttribute( String key );
-    
-    /**
-     * Sets a user-defined attribute.
-     * 
-     * @param key the key of the attribute
-     * @param value the value of the attribute
-     * @return The old value of the attribute.  <tt>null</tt> if it is new.
-     */
-    Object setAttribute( String key, Object value );
-    
-    /**
-     * Sets a user defined attribute without a value.  This is useful when
-     * you just want to put a 'mark' attribute.  Its value is set to
-     * {@link Boolean#TRUE}.
-     * 
-     * @param key the key of the attribute
-     * @return The old value of the attribute.  <tt>null</tt> if it is new.
-     */
-    Object setAttribute( String key );
-    
-    /**
-     * Removes a user-defined attribute with the specified key.
-     * 
-     * @return The old value of the attribute.  <tt>null</tt> if not found.
-     */
-    Object removeAttribute( String key );
-    
-    /**
-     * Returns <tt>true</tt> if this session contains the attribute with
-     * the specified <tt>key</tt>.
-     */
-    boolean containsAttribute( String key );
-    
-    /**
-     * Returns the set of keys of all user-defined attributes.
-     */
-    Set getAttributeKeys();
-    
-    /**
-     * Returns transport type of this session.
-     */
-    TransportType getTransportType();
-
-    /**
-     * Returns <code>true</code> if this session is connected with remote peer.
-     */
-    boolean isConnected();
-    
-    /**
-     * Returns <code>true</tt> if and only if this session is being closed
-     * (but not disconnected yet) or is closed.
-     */
-    boolean isClosing();
-    
-    /**
-     * Returns the {@link CloseFuture} of this session.  This method returns
-     * the same instance whenever user calls it.
-     */
-    CloseFuture getCloseFuture();
-
-    /**
-     * Returns the socket address of remote peer. 
-     */
-    SocketAddress getRemoteAddress();
-
-    /**
-     * Returns the socket address of local machine which is associated with this
-     * session.
-     */
-    SocketAddress getLocalAddress();
-
-    /**
-     * Returns idle time for the specified type of idleness in seconds.
-     */
-    int getIdleTime( IdleStatus status );
-
-    /**
-     * Returns idle time for the specified type of idleness in milliseconds.
-     */
-    long getIdleTimeInMillis( IdleStatus status );
-
-    /**
-     * Sets idle time for the specified type of idleness in seconds.
-     */
-    void setIdleTime( IdleStatus status, int idleTime );
-    
-    /**
-     * Returns write timeout in seconds.
-     */
-    int getWriteTimeout();
-
-    /**
-     * Returns write timeout in milliseconds.
-     */
-    long getWriteTimeoutInMillis();
-
-    /**
-     * Sets write timeout in seconds.
-     */
-    void setWriteTimeout( int writeTimeout );
-    
-    /**
-     * Returns the current {@link TrafficMask} of this session.
-     */
-    TrafficMask getTrafficMask();
-    
-    /**
-     * Sets the {@link TrafficMask} of this session which will result
-     * the parent {@link IoSessionManager} to start to control the traffic
-     * of this session immediately.
-     */
-    void setTrafficMask( TrafficMask trafficMask );
-
-    /**
-     * A shortcut method for {@link #setTrafficMask(TrafficMask)} that
-     * suspends read operations for this session.
-     */
-    void suspendRead();
-    
-    /**
-     * A shortcut method for {@link #setTrafficMask(TrafficMask)} that
-     * suspends write operations for this session.
-     */
-    void suspendWrite();
-    
-    /**
-     * A shortcut method for {@link #setTrafficMask(TrafficMask)} that
-     * resumes read operations for this session.
-     */
-    void resumeRead();
-    
-    /**
-     * A shortcut method for {@link #setTrafficMask(TrafficMask)} that
-     * resumes write operations for this session.
-     */
-    void resumeWrite();
-    
-    /**
-     * Returns the total number of bytes which were read from this session.
-     */
-    long getReadBytes();
-
-    /**
-     * Returns the total number of bytes which were written to this session.
-     */
-    long getWrittenBytes();
-    
-    /**
-     * Returns the total number of write requests which were written to this session.
-     */
-    long getWrittenWriteRequests();
-    
-    /**
-     * Returns the number of write requests which are scheduled to be written
-     * to this session.
-     */
-    int getScheduledWriteRequests();
-
-    /**
-     * Returns the time in millis when this session is created.
-     */
-    long getCreationTime();
-    
-    /**
-     * Returns the time in millis when I/O occurred lastly.
-     */
-    long getLastIoTime();
-
-    /**
-     * Returns the time in millis when read operation occurred lastly.
-     */
-    long getLastReadTime();
-
-    /**
-     * Returns the time in millis when write operation occurred lastly.
-     */
-    long getLastWriteTime();
-
-    /**
-     * Returns <code>true</code> if this session is idle for the specified 
-     * {@link IdleStatus}.
-     */
-    boolean isIdle( IdleStatus status );
-
-    /**
-     * Returns the number of the fired continuous <tt>sessionIdle</tt> events
-     * for the specified {@link IdleStatus}.
-     * <p>
-     * If <tt>sessionIdle</tt> event is fired first after some time after I/O,
-     * <tt>idleCount</tt> becomes <tt>1</tt>.  <tt>idleCount</tt> resets to
-     * <tt>0</tt> if any I/O occurs again, otherwise it increases to
-     * <tt>2</tt> and so on if <tt>sessionIdle</tt> event is fired again without
-     * any I/O between two (or more) <tt>sessionIdle</tt> events.
-     */
-    int getIdleCount( IdleStatus status );
-    
-    /**
-     * Returns the time in millis when the last <tt>sessionIdle</tt> event
-     * is fired for the specified {@link IdleStatus}.
-     */
-    long getLastIdleTime( IdleStatus status );
-}
+/*
+ *   @(#) $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;
+
+import java.net.SocketAddress;
+import java.util.Set;
+
+/**
+ * A handle which represents connection between two endpoints regardless of 
+ * transport types.
+ * <p>
+ * Session provides user-defined attributes.  User-defined attributes are
+ * application-specific data which is associated with a session.
+ * It often contains objects that represents the state of a higher-level protocol
+ * and becomes a way to exchange data between filters and handlers.
+ * 
+ * <h2>Adjusting Transport Type Specific Properties</h2>
+ * <p>
+ * You can simply downcast the session to an appropriate subclass.
+ * </p>
+ *   
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public interface IoSession {
+    
+    /**
+     * Returns the {@link IoSessionManager} which manages this session.
+     */
+    IoSessionManager getManager();
+
+    /**
+     * Returns the {@link IoHandler} which handles this session.
+     */
+    IoHandler getHandler();
+
+    /**
+     * Returns the filter chain that only affects this session.
+     */
+    IoFilterChain getFilterChain();
+
+    /**
+     * Writes the specified <code>message</code> to remote peer.  This
+     * operation is asynchronous; {@link IoHandler#messageSent(IoSession, Object)}
+     * will be invoked when the message is actually sent to remote peer.
+     * You can also ait for the returned {@link WriteFuture} if you want
+     * to wait for the session actually closed.
+     */
+    WriteFuture write( Object message );
+
+    /**
+     * Closes this session immediately.  This operation is asynthronous.
+     * Wait for the returned {@link CloseFuture} if you want to wait for
+     * the session actually closed.
+     */
+    CloseFuture close();
+
+    /**
+     * Returns an attachment of this session.
+     * This method is identical with <tt>getAttribute( "" )</tt>.
+     */
+    Object getAttachment();
+
+    /**
+     * Sets an attachment of this session.
+     * This method is identical with <tt>setAttribute( "", attachment )</tt>.
+     * 
+     * @return Old attachment.  <tt>null</tt> if it is new.
+     */
+    Object setAttachment( Object attachment );
+    
+    /**
+     * Returns the value of user-defined attribute of this session.
+     * 
+     * @param key the key of the attribute
+     * @return <tt>null</tt> if there is no attribute with the specified key
+     */
+    Object getAttribute( String key );
+    
+    /**
+     * Sets a user-defined attribute.
+     * 
+     * @param key the key of the attribute
+     * @param value the value of the attribute
+     * @return The old value of the attribute.  <tt>null</tt> if it is new.
+     */
+    Object setAttribute( String key, Object value );
+    
+    /**
+     * Sets a user defined attribute without a value.  This is useful when
+     * you just want to put a 'mark' attribute.  Its value is set to
+     * {@link Boolean#TRUE}.
+     * 
+     * @param key the key of the attribute
+     * @return The old value of the attribute.  <tt>null</tt> if it is new.
+     */
+    Object setAttribute( String key );
+    
+    /**
+     * Removes a user-defined attribute with the specified key.
+     * 
+     * @return The old value of the attribute.  <tt>null</tt> if not found.
+     */
+    Object removeAttribute( String key );
+    
+    /**
+     * Returns <tt>true</tt> if this session contains the attribute with
+     * the specified <tt>key</tt>.
+     */
+    boolean containsAttribute( String key );
+    
+    /**
+     * Returns the set of keys of all user-defined attributes.
+     */
+    Set getAttributeKeys();
+    
+    /**
+     * Returns transport type of this session.
+     */
+    TransportType getTransportType();
+
+    /**
+     * Returns <code>true</code> if this session is connected with remote peer.
+     */
+    boolean isConnected();
+    
+    /**
+     * Returns <code>true</tt> if and only if this session is being closed
+     * (but not disconnected yet) or is closed.
+     */
+    boolean isClosing();
+    
+    /**
+     * Returns the {@link CloseFuture} of this session.  This method returns
+     * the same instance whenever user calls it.
+     */
+    CloseFuture getCloseFuture();
+
+    /**
+     * Returns the socket address of remote peer. 
+     */
+    SocketAddress getRemoteAddress();
+
+    /**
+     * Returns the socket address of local machine which is associated with this
+     * session.
+     */
+    SocketAddress getLocalAddress();
+
+    /**
+     * Returns idle time for the specified type of idleness in seconds.
+     */
+    int getIdleTime( IdleStatus status );
+
+    /**
+     * Returns idle time for the specified type of idleness in milliseconds.
+     */
+    long getIdleTimeInMillis( IdleStatus status );
+
+    /**
+     * Sets idle time for the specified type of idleness in seconds.
+     */
+    void setIdleTime( IdleStatus status, int idleTime );
+    
+    /**
+     * Returns write timeout in seconds.
+     */
+    int getWriteTimeout();
+
+    /**
+     * Returns write timeout in milliseconds.
+     */
+    long getWriteTimeoutInMillis();
+
+    /**
+     * Sets write timeout in seconds.
+     */
+    void setWriteTimeout( int writeTimeout );
+    
+    /**
+     * Returns the current {@link TrafficMask} of this session.
+     */
+    TrafficMask getTrafficMask();
+    
+    /**
+     * Sets the {@link TrafficMask} of this session which will result
+     * the parent {@link IoSessionManager} to start to control the traffic
+     * of this session immediately.
+     */
+    void setTrafficMask( TrafficMask trafficMask );
+
+    /**
+     * A shortcut method for {@link #setTrafficMask(TrafficMask)} that
+     * suspends read operations for this session.
+     */
+    void suspendRead();
+    
+    /**
+     * A shortcut method for {@link #setTrafficMask(TrafficMask)} that
+     * suspends write operations for this session.
+     */
+    void suspendWrite();
+    
+    /**
+     * A shortcut method for {@link #setTrafficMask(TrafficMask)} that
+     * resumes read operations for this session.
+     */
+    void resumeRead();
+    
+    /**
+     * A shortcut method for {@link #setTrafficMask(TrafficMask)} that
+     * resumes write operations for this session.
+     */
+    void resumeWrite();
+    
+    /**
+     * Returns the total number of bytes which were read from this session.
+     */
+    long getReadBytes();
+
+    /**
+     * Returns the total number of bytes which were written to this session.
+     */
+    long getWrittenBytes();
+    
+    /**
+     * Returns the total number of write requests which were written to this session.
+     */
+    long getWrittenWriteRequests();
+    
+    /**
+     * Returns the number of write requests which are scheduled to be written
+     * to this session.
+     */
+    int getScheduledWriteRequests();
+
+    /**
+     * Returns the time in millis when this session is created.
+     */
+    long getCreationTime();
+    
+    /**
+     * Returns the time in millis when I/O occurred lastly.
+     */
+    long getLastIoTime();
+
+    /**
+     * Returns the time in millis when read operation occurred lastly.
+     */
+    long getLastReadTime();
+
+    /**
+     * Returns the time in millis when write operation occurred lastly.
+     */
+    long getLastWriteTime();
+
+    /**
+     * Returns <code>true</code> if this session is idle for the specified 
+     * {@link IdleStatus}.
+     */
+    boolean isIdle( IdleStatus status );
+
+    /**
+     * Returns the number of the fired continuous <tt>sessionIdle</tt> events
+     * for the specified {@link IdleStatus}.
+     * <p>
+     * If <tt>sessionIdle</tt> event is fired first after some time after I/O,
+     * <tt>idleCount</tt> becomes <tt>1</tt>.  <tt>idleCount</tt> resets to
+     * <tt>0</tt> if any I/O occurs again, otherwise it increases to
+     * <tt>2</tt> and so on if <tt>sessionIdle</tt> event is fired again without
+     * any I/O between two (or more) <tt>sessionIdle</tt> events.
+     */
+    int getIdleCount( IdleStatus status );
+    
+    /**
+     * Returns the time in millis when the last <tt>sessionIdle</tt> event
+     * is fired for the specified {@link IdleStatus}.
+     */
+    long getLastIdleTime( IdleStatus status );
+}

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoSessionManager.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoSessionManager.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoSessionManager.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoSessionManager.java Wed Nov 30 21:17:41 2005
@@ -1,55 +1,78 @@
-/*
- *   @(#) $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;
-
-import org.apache.mina.common.support.DefaultExceptionMonitor;
-
-/**
- * Base interface for all acceptors and connectors that manage
- * sessions.
- * <p>
- * You can monitor any uncaught exceptions by setting {@link ExceptionMonitor}
- * by calling {@link #setExceptionMonitor(ExceptionMonitor)}.  The default
- * monitor is {@link DefaultExceptionMonitor}.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public interface IoSessionManager {
-    
-    /**
-     * Returns the filter chain that filters all events which is related
-     * with sessions this manager manages.
-     */
-    IoFilterChain getFilterChain();
-    
-    /**
-     * Returns the current exception monitor.
-     */
-    ExceptionMonitor getExceptionMonitor();
-
-    /**
-     * Sets the uncaught exception monitor.  If <code>null</code> is specified,
-     * a new instance of {@link DefaultExceptionMonitor} will be set.
-     * 
-     * @param monitor A new instance of {@link DefaultExceptionMonitor} is set
-     *                if <tt>null</tt> is specified.
-     */
-    void setExceptionMonitor( ExceptionMonitor monitor );
-}
+/*
+ *   @(#) $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;
+
+import org.apache.mina.common.support.DefaultExceptionMonitor;
+
+/**
+ * Base interface for all acceptors and connectors that manage
+ * sessions.
+ * <p>
+ * You can monitor any uncaught exceptions by setting {@link ExceptionMonitor}
+ * by calling {@link #setExceptionMonitor(ExceptionMonitor)}.  The default
+ * monitor is {@link DefaultExceptionMonitor}.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public interface IoSessionManager {
+    
+    /**
+     * Returns the {@link IoFilterChainBuilder} which will modify the
+     * {@link IoFilterChain} of all {@link IoSession}s which is managed
+     * by this manager.
+     * The default value is an empty {@link DefaultIoFilterChainBuilder}.
+     */
+    IoFilterChainBuilder getFilterChainBuilder();
+    
+    /**
+     * Sets the {@link IoFilterChainBuilder} which will modify 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
+     * an empty {@link DefaultIoFilterChainBuilder}.
+     */
+    void setFilterChainBuilder( IoFilterChainBuilder builder );
+    
+    /**
+     * A shortcut for <tt>( ( DefaultIoFilterChainBuilder ) </tt>{@link #getFilterChainBuilder()}<tt> )</tt>.
+     * Please note that the returned object is not a <b>real</b> {@link IoFilterChain}
+     * but a {@link DefaultIoFilterChainBuilder}.  Modifying the returned builder
+     * won't affect the existing {@link IoSession}s at all, because
+     * {@link IoFilterChainBuilder}s affect only newly created {@link IoSession}s.
+     *
+     * @throws IllegalStateException if the current {@link IoFilterChainBuilder} is
+     *                               not a {@link DefaultIoFilterChainBuilder}
+     */
+    DefaultIoFilterChainBuilder getFilterChain();
+
+    /**
+     * Returns the current exception monitor.
+     */
+    ExceptionMonitor getExceptionMonitor();
+
+    /**
+     * Sets the uncaught exception monitor.  If <code>null</code> is specified,
+     * a new instance of {@link DefaultExceptionMonitor} will be set.
+     * 
+     * @param monitor A new instance of {@link DefaultExceptionMonitor} is set
+     *                if <tt>null</tt> is specified.
+     */
+    void setExceptionMonitor( ExceptionMonitor monitor );
+}

Modified: directory/network/trunk/src/java/org/apache/mina/common/TransportType.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/TransportType.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/TransportType.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/TransportType.java Wed Nov 30 21:17:41 2005
@@ -1,221 +1,221 @@
-/*
- *   @(#) $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;
-
-import java.io.InvalidObjectException;
-import java.io.ObjectStreamException;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * Represents network transport types.
- * MINA provides three transport types by default:
- * <ul>
- *   <li>{@link #SOCKET} - TCP/IP</li>
- *   <li>{@link #DATAGRAM} - UDP/IP</li>
- *   <li>{@link #VM_PIPE} - in-VM pipe support (only available in protocol
- *       layer</li>
- * </ul>
- * <p>
- * You can also create your own transport type.  Please refer to
- * {@link #TransportType(String[], boolean)}.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public final class TransportType implements Serializable
-{
-    private static final long serialVersionUID = 3258132470497883447L;
-    
-    private static final Map name2type = new HashMap();
-    
-    private static void register( String[] names, TransportType type )
-    {
-        synchronized( name2type )
-        {
-            for( int i = names.length - 1; i >= 0; i -- )
-            {
-                if( name2type.containsKey( names[i] ) )
-                {
-                    throw new IllegalArgumentException(
-                            "Transport type name '" + names[i] + "' is already taken." );
-                }
-            }
-
-            for( int i = names.length - 1; i >= 0; i -- )
-            {
-                name2type.put( names[i].toUpperCase(), type );
-            }
-        }
-    }
-
-    /**
-     * Transport type: TCP/IP (Registry name: <tt>"SOCKET"</tt> or <tt>"TCP"</tt>)
-     */
-    public static final TransportType SOCKET =
-        new TransportType( new String[] { "SOCKET", "TCP" }, false );
-
-    /**
-     * Transport type: UDP/IP (Registry name: <tt>"DATAGRAM"</tt> or <tt>"UDP"</tt>)
-     */
-    public static final TransportType DATAGRAM =
-        new TransportType( new String[] { "DATAGRAM", "UDP" }, true );
-
-    /**
-     * Transport type: in-VM pipe (Registry name: <tt>"VM_PIPE"</tt>) 
-     * Please refer to
-     * <a href="../protocol/vmpipe/package-summary.htm"><tt>org.apache.mina.protocol.vmpipe</tt></a>
-     * package.
-     */
-    public static final TransportType VM_PIPE =
-        new TransportType( new String[] { "VM_PIPE" }, Object.class, false );
-    
-
-    /**
-     * Returns the transport type of the specified name.
-     * All names are case-insensitive.
-     * 
-     * @param name the name of the transport type
-     * @return the transport type
-     * @throws IllegalArgumentException if the specified name is not available.
-     */
-    public static TransportType getInstance( String name )
-    {
-        TransportType type = (TransportType) name2type.get( name.toUpperCase() );
-        if( type != null )
-        {
-            return type;
-        }
-        
-        throw new IllegalArgumentException("Unknown transport type name: " + name);
-    }
-
-    private final String[] names;
-
-    private final transient boolean connectionless;
-    
-    private final transient Class envelopeType;
-
-    /**
-     * Creates a new instance.  New transport type is automatically registered
-     * to internal registry so that you can look it up using {@link #getInstance(String)}.
-     * 
-     * @param names the name or aliases of this transport type
-     * @param connectionless <tt>true</tt> if and only if this transport type is connectionless
-     * 
-     * @throws IllegalArgumentException if <tt>names</tt> are already registered or empty
-     */
-    public TransportType( String[] names, boolean connectionless )
-    {
-        this( names, ByteBuffer.class, connectionless );
-    }
-
-    /**
-     * Creates a new instance.  New transport type is automatically registered
-     * to internal registry so that you can look it up using {@link #getInstance(String)}.
-     * 
-     * @param names the name or aliases of this transport type
-     * @param connectionless <tt>true</tt> if and only if this transport type is connectionless
-     * 
-     * @throws IllegalArgumentException if <tt>names</tt> are already registered or empty
-     */
-    public TransportType( String[] names, Class envelopeType, boolean connectionless )
-    {
-        if( names == null )
-        {
-            throw new NullPointerException( "names" );
-        }
-        if( names.length == 0 )
-        {
-            throw new IllegalArgumentException( "names is empty" );
-        }
-        if( envelopeType == null )
-        {
-            throw new NullPointerException( "envelopeType" );
-        }
-
-        for( int i = 0; i < names.length; i ++ )
-        {
-            if( names[ i ] == null )
-            {
-                throw new NullPointerException( "strVals[" + i + "]" );
-            }
-            
-            names[ i ] = names[ i ].toUpperCase();
-        }
-
-        register( names, this );
-        this.names = names;
-        this.connectionless = connectionless;
-        this.envelopeType = envelopeType;
-    }
-
-    /**
-     * Returns <code>true</code> if the session of this transport type is
-     * connectionless.
-     */
-    public boolean isConnectionless()
-    {
-        return connectionless;
-    }
-    
-    public Class getEnvelopeType()
-    {
-        return envelopeType;
-    }
-    
-    /**
-     * Returns the known names of this transport type.
-     */
-    public Set getNames()
-    {
-        Set result = new TreeSet();
-        for( int i = names.length - 1; i >= 0; i -- )
-        {
-            result.add( names[ i ] );
-        }
-        
-        return result;
-    }
-
-    public String toString()
-    {
-        return names[0];
-    }
-    
-    private Object readResolve() throws ObjectStreamException
-    {
-        for( int i = names.length - 1; i >= 0; i -- )
-        {
-            try
-            {
-                return getInstance( names[ i ] );
-            }
-            catch( IllegalArgumentException e )
-            {
-                // ignore
-            }
-        }
-        
-        throw new InvalidObjectException( "Unknown transport type." );
-    }
-}
+/*
+ *   @(#) $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;
+
+import java.io.InvalidObjectException;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ * Represents network transport types.
+ * MINA provides three transport types by default:
+ * <ul>
+ *   <li>{@link #SOCKET} - TCP/IP</li>
+ *   <li>{@link #DATAGRAM} - UDP/IP</li>
+ *   <li>{@link #VM_PIPE} - in-VM pipe support (only available in protocol
+ *       layer</li>
+ * </ul>
+ * <p>
+ * You can also create your own transport type.  Please refer to
+ * {@link #TransportType(String[], boolean)}.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public final class TransportType implements Serializable
+{
+    private static final long serialVersionUID = 3258132470497883447L;
+    
+    private static final Map name2type = new HashMap();
+    
+    private static void register( String[] names, TransportType type )
+    {
+        synchronized( name2type )
+        {
+            for( int i = names.length - 1; i >= 0; i -- )
+            {
+                if( name2type.containsKey( names[i] ) )
+                {
+                    throw new IllegalArgumentException(
+                            "Transport type name '" + names[i] + "' is already taken." );
+                }
+            }
+
+            for( int i = names.length - 1; i >= 0; i -- )
+            {
+                name2type.put( names[i].toUpperCase(), type );
+            }
+        }
+    }
+
+    /**
+     * Transport type: TCP/IP (Registry name: <tt>"SOCKET"</tt> or <tt>"TCP"</tt>)
+     */
+    public static final TransportType SOCKET =
+        new TransportType( new String[] { "SOCKET", "TCP" }, false );
+
+    /**
+     * Transport type: UDP/IP (Registry name: <tt>"DATAGRAM"</tt> or <tt>"UDP"</tt>)
+     */
+    public static final TransportType DATAGRAM =
+        new TransportType( new String[] { "DATAGRAM", "UDP" }, true );
+
+    /**
+     * Transport type: in-VM pipe (Registry name: <tt>"VM_PIPE"</tt>) 
+     * Please refer to
+     * <a href="../protocol/vmpipe/package-summary.htm"><tt>org.apache.mina.protocol.vmpipe</tt></a>
+     * package.
+     */
+    public static final TransportType VM_PIPE =
+        new TransportType( new String[] { "VM_PIPE" }, Object.class, false );
+    
+
+    /**
+     * Returns the transport type of the specified name.
+     * All names are case-insensitive.
+     * 
+     * @param name the name of the transport type
+     * @return the transport type
+     * @throws IllegalArgumentException if the specified name is not available.
+     */
+    public static TransportType getInstance( String name )
+    {
+        TransportType type = (TransportType) name2type.get( name.toUpperCase() );
+        if( type != null )
+        {
+            return type;
+        }
+        
+        throw new IllegalArgumentException("Unknown transport type name: " + name);
+    }
+
+    private final String[] names;
+
+    private final transient boolean connectionless;
+    
+    private final transient Class envelopeType;
+
+    /**
+     * Creates a new instance.  New transport type is automatically registered
+     * to internal registry so that you can look it up using {@link #getInstance(String)}.
+     * 
+     * @param names the name or aliases of this transport type
+     * @param connectionless <tt>true</tt> if and only if this transport type is connectionless
+     * 
+     * @throws IllegalArgumentException if <tt>names</tt> are already registered or empty
+     */
+    public TransportType( String[] names, boolean connectionless )
+    {
+        this( names, ByteBuffer.class, connectionless );
+    }
+
+    /**
+     * Creates a new instance.  New transport type is automatically registered
+     * to internal registry so that you can look it up using {@link #getInstance(String)}.
+     * 
+     * @param names the name or aliases of this transport type
+     * @param connectionless <tt>true</tt> if and only if this transport type is connectionless
+     * 
+     * @throws IllegalArgumentException if <tt>names</tt> are already registered or empty
+     */
+    public TransportType( String[] names, Class envelopeType, boolean connectionless )
+    {
+        if( names == null )
+        {
+            throw new NullPointerException( "names" );
+        }
+        if( names.length == 0 )
+        {
+            throw new IllegalArgumentException( "names is empty" );
+        }
+        if( envelopeType == null )
+        {
+            throw new NullPointerException( "envelopeType" );
+        }
+
+        for( int i = 0; i < names.length; i ++ )
+        {
+            if( names[ i ] == null )
+            {
+                throw new NullPointerException( "strVals[" + i + "]" );
+            }
+            
+            names[ i ] = names[ i ].toUpperCase();
+        }
+
+        register( names, this );
+        this.names = names;
+        this.connectionless = connectionless;
+        this.envelopeType = envelopeType;
+    }
+
+    /**
+     * Returns <code>true</code> if the session of this transport type is
+     * connectionless.
+     */
+    public boolean isConnectionless()
+    {
+        return connectionless;
+    }
+    
+    public Class getEnvelopeType()
+    {
+        return envelopeType;
+    }
+    
+    /**
+     * Returns the known names of this transport type.
+     */
+    public Set getNames()
+    {
+        Set result = new TreeSet();
+        for( int i = names.length - 1; i >= 0; i -- )
+        {
+            result.add( names[ i ] );
+        }
+        
+        return result;
+    }
+
+    public String toString()
+    {
+        return names[0];
+    }
+    
+    private Object readResolve() throws ObjectStreamException
+    {
+        for( int i = names.length - 1; i >= 0; i -- )
+        {
+            try
+            {
+                return getInstance( names[ i ] );
+            }
+            catch( IllegalArgumentException e )
+            {
+                // ignore
+            }
+        }
+        
+        throw new InvalidObjectException( "Unknown transport type." );
+    }
+}

Modified: directory/network/trunk/src/java/org/apache/mina/common/WriteTimeoutException.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/WriteTimeoutException.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/WriteTimeoutException.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/WriteTimeoutException.java Wed Nov 30 21:17:41 2005
@@ -1,49 +1,49 @@
-/*
- *   @(#) $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;
-
-import java.io.IOException;
-
-/**
- * An {@link IOException} which is thrown when write buffer is not flushed for
- * {@link IoSession#getWriteTimeout()} seconds.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$, 
- */
-public class WriteTimeoutException extends IOException
-{
-    private static final long serialVersionUID = 3906931157944579121L;
-
-	/**
-     * Creates a new exception.
-     */
-    public WriteTimeoutException()
-    {
-        super();
-    }
-
-    /**
-     * Creates a new exception.
-     */
-    public WriteTimeoutException( String s )
-    {
-        super( s );
-    }
+/*
+ *   @(#) $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;
+
+import java.io.IOException;
+
+/**
+ * An {@link IOException} which is thrown when write buffer is not flushed for
+ * {@link IoSession#getWriteTimeout()} seconds.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$, 
+ */
+public class WriteTimeoutException extends IOException
+{
+    private static final long serialVersionUID = 3906931157944579121L;
+
+	/**
+     * Creates a new exception.
+     */
+    public WriteTimeoutException()
+    {
+        super();
+    }
+
+    /**
+     * Creates a new exception.
+     */
+    public WriteTimeoutException( String s )
+    {
+        super( s );
+    }
 }