directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r350169 [4/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...
Date Thu, 01 Dec 2005 05:19:07 GMT
Modified: directory/network/trunk/src/java/org/apache/mina/common/ByteBufferProxy.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/ByteBufferProxy.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/ByteBufferProxy.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/ByteBufferProxy.java Wed Nov 30 21:17:41 2005
@@ -1,560 +1,560 @@
-/*
- *   @(#) $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.FilterOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.ByteOrder;
-import java.nio.CharBuffer;
-import java.nio.DoubleBuffer;
-import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
-import java.nio.LongBuffer;
-import java.nio.ShortBuffer;
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CharsetEncoder;
-
-/**
- * A {@link ByteBuffer} that wraps a buffer and proxies any operations to it.
- * <p>
- * You can think this class like a {@link FilterOutputStream}.  All operations
- * are proxied by default so that you can extend this class and override existing
- * operations selectively.  You can introduce new operations, too.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public class ByteBufferProxy extends ByteBuffer
-{
-
-    /**
-     * The buffer proxied by this proxy.
-     */
-    protected ByteBuffer buf;
-
-    /**
-     * Create a new instance.
-     * @param buf the buffer to be proxied
-     */
-    protected ByteBufferProxy( ByteBuffer buf )
-    {
-        if( buf == null )
-        {
-            throw new NullPointerException( "buf" );
-        }
-        this.buf = buf;
-    }
-
-    public void acquire()
-    {
-        buf.acquire();
-    }
-
-    public void release()
-    {
-        buf.release();
-    }
-
-    public boolean isDirect()
-    {
-        return buf.isDirect();
-    }
-
-    public java.nio.ByteBuffer buf()
-    {
-        return buf.buf();
-    }
-
-    public int capacity()
-    {
-        return buf.capacity();
-    }
-
-    public int position()
-    {
-        return buf.position();
-    }
-
-    public ByteBuffer position( int newPosition )
-    {
-        buf.position( newPosition );
-        return this;
-    }
-
-    public int limit()
-    {
-        return buf.limit();
-    }
-
-    public ByteBuffer limit( int newLimit )
-    {
-        buf.limit( newLimit );
-        return this;
-    }
-
-    public ByteBuffer mark()
-    {
-        buf.mark();
-        return this;
-    }
-
-    public ByteBuffer reset()
-    {
-        buf.reset();
-        return this;
-    }
-
-    public ByteBuffer clear()
-    {
-        buf.clear();
-        return this;
-    }
-
-    public ByteBuffer flip()
-    {
-        buf.flip();
-        return this;
-    }
-
-    public ByteBuffer rewind()
-    {
-        buf.rewind();
-        return this;
-    }
-
-    public int remaining()
-    {
-        return buf.remaining();
-    }
-
-    public boolean hasRemaining()
-    {
-        return buf.hasRemaining();
-    }
-
-    public byte get()
-    {
-        return buf.get();
-    }
-
-    public short getUnsigned()
-    {
-        return buf.getUnsigned();
-    }
-
-    public ByteBuffer put( byte b )
-    {
-        buf.put( b );
-        return this;
-    }
-
-    public byte get( int index )
-    {
-        return buf.get( index );
-    }
-
-    public short getUnsigned( int index )
-    {
-        return buf.getUnsigned( index );
-    }
-
-    public ByteBuffer put( int index, byte b )
-    {
-        buf.put( index, b );
-        return this;
-    }
-
-    public ByteBuffer get( byte[] dst, int offset, int length )
-    {
-        buf.get( dst, offset, length );
-        return this;
-    }
-
-    public ByteBuffer get( byte[] dst )
-    {
-        buf.get( dst );
-        return this;
-    }
-
-    public ByteBuffer put( ByteBuffer src )
-    {
-        buf.put( src );
-        return this;
-    }
-
-    public ByteBuffer put( java.nio.ByteBuffer src )
-    {
-        buf.put( src );
-        return this;
-    }
-
-    public ByteBuffer put( byte[] src, int offset, int length )
-    {
-        buf.put( src, offset, length );
-        return this;
-    }
-
-    public ByteBuffer put( byte[] src )
-    {
-        buf.put( src );
-        return this;
-    }
-
-    public ByteBuffer compact()
-    {
-        buf.compact();
-        return this;
-    }
-
-    public String toString()
-    {
-        return buf.toString();
-    }
-
-    public int hashCode()
-    {
-        return buf.hashCode();
-    }
-
-    public boolean equals( Object ob )
-    {
-        return buf.equals( ob );
-    }
-
-    public int compareTo( ByteBuffer that )
-    {
-        return buf.compareTo( that );
-    }
-
-    public ByteOrder order()
-    {
-        return buf.order();
-    }
-
-    public ByteBuffer order( ByteOrder bo )
-    {
-        buf.order( bo );
-        return this;
-    }
-
-    public char getChar()
-    {
-        return buf.getChar();
-    }
-
-    public ByteBuffer putChar( char value )
-    {
-        buf.putChar( value );
-        return this;
-    }
-
-    public char getChar( int index )
-    {
-        return buf.getChar( index );
-    }
-
-    public ByteBuffer putChar( int index, char value )
-    {
-        buf.putChar( index, value );
-        return this;
-    }
-
-    public CharBuffer asCharBuffer()
-    {
-        return buf.asCharBuffer();
-    }
-
-    public short getShort()
-    {
-        return buf.getShort();
-    }
-
-    public int getUnsignedShort()
-    {
-        return buf.getUnsignedShort();
-    }
-
-    public ByteBuffer putShort( short value )
-    {
-        buf.putShort( value );
-        return this;
-    }
-
-    public short getShort( int index )
-    {
-        return buf.getShort( index );
-    }
-
-    public int getUnsignedShort( int index )
-    {
-        return buf.getUnsignedShort( index );
-    }
-
-    public ByteBuffer putShort( int index, short value )
-    {
-        buf.putShort( index, value );
-        return this;
-    }
-
-    public ShortBuffer asShortBuffer()
-    {
-        return buf.asShortBuffer();
-    }
-
-    public int getInt()
-    {
-        return buf.getInt();
-    }
-
-    public long getUnsignedInt()
-    {
-        return buf.getUnsignedInt();
-    }
-
-    public ByteBuffer putInt( int value )
-    {
-        buf.putInt( value );
-        return this;
-    }
-
-    public int getInt( int index )
-    {
-        return buf.getInt( index );
-    }
-
-    public long getUnsignedInt( int index )
-    {
-        return buf.getUnsignedInt( index );
-    }
-
-    public ByteBuffer putInt( int index, int value )
-    {
-        buf.putInt( index, value );
-        return this;
-    }
-
-    public IntBuffer asIntBuffer()
-    {
-        return buf.asIntBuffer();
-    }
-
-    public long getLong()
-    {
-        return buf.getLong();
-    }
-
-    public ByteBuffer putLong( long value )
-    {
-        buf.putLong( value );
-        return this;
-    }
-
-    public long getLong( int index )
-    {
-        return buf.getLong( index );
-    }
-
-    public ByteBuffer putLong( int index, long value )
-    {
-        buf.putLong( index, value );
-        return this;
-    }
-
-    public LongBuffer asLongBuffer()
-    {
-        return buf.asLongBuffer();
-    }
-
-    public float getFloat()
-    {
-        return buf.getFloat();
-    }
-
-    public ByteBuffer putFloat( float value )
-    {
-        buf.putFloat( value );
-        return this;
-    }
-
-    public float getFloat( int index )
-    {
-        return buf.getFloat( index );
-    }
-
-    public ByteBuffer putFloat( int index, float value )
-    {
-        buf.putFloat( index, value );
-        return this;
-    }
-
-    public FloatBuffer asFloatBuffer()
-    {
-        return buf.asFloatBuffer();
-    }
-
-    public double getDouble()
-    {
-        return buf.getDouble();
-    }
-
-    public ByteBuffer putDouble( double value )
-    {
-        buf.putDouble( value );
-        return this;
-    }
-
-    public double getDouble( int index )
-    {
-        return buf.getDouble( index );
-    }
-
-    public ByteBuffer putDouble( int index, double value )
-    {
-        buf.putDouble( index, value );
-        return this;
-    }
-
-    public DoubleBuffer asDoubleBuffer()
-    {
-        return buf.asDoubleBuffer();
-    }
-
-    public String getHexDump()
-    {
-        return buf.getHexDump();
-    }
-
-    public String getString( int fieldSize, CharsetDecoder decoder )
-            throws CharacterCodingException
-    {
-        return buf.getString( fieldSize, decoder );
-    }
-
-    public String getString( CharsetDecoder decoder )
-            throws CharacterCodingException
-    {
-        return buf.getString( decoder );
-    }
-    
-    public String getPascalString( CharsetDecoder decoder )
-            throws CharacterCodingException
-    {
-        return buf.getPascalString( decoder );
-    }
-
-    public ByteBuffer putString( CharSequence in, int fieldSize,
-                                CharsetEncoder encoder )
-            throws CharacterCodingException
-    {
-        buf.putString( in, fieldSize, encoder );
-        return this;
-    }
-
-    public ByteBuffer putString( CharSequence in, CharsetEncoder encoder )
-            throws CharacterCodingException
-    {
-        buf.putString( in, encoder );
-        return this;
-    }
-    
-    public ByteBuffer putPascalString( CharSequence in, CharsetEncoder encoder )
-            throws CharacterCodingException
-    {
-        buf.putPascalString( in, encoder );
-        return this;
-    }
-
-    public ByteBuffer skip( int size )
-    {
-        buf.skip( size );
-        return this;
-    }
-
-    public ByteBuffer fill( byte value, int size )
-    {
-        buf.fill( value, size );
-        return this;
-    }
-
-    public ByteBuffer fillAndReset( byte value, int size )
-    {
-        buf.fillAndReset( value, size );
-        return this;
-    }
-
-    public ByteBuffer fill( int size )
-    {
-        buf.fill( size );
-        return this;
-    }
-
-    public ByteBuffer fillAndReset( int size )
-    {
-        buf.fillAndReset( size );
-        return this;
-    }
-
-    public boolean isAutoExpand()
-    {
-        return buf.isAutoExpand();
-    }
-
-    public ByteBuffer setAutoExpand( boolean autoExpand )
-    {
-        buf.setAutoExpand( autoExpand );
-        return this;
-    }
-    
-    public boolean isPooled()
-    {
-        return buf.isPooled();
-    }
-    
-    public void setPooled( boolean pooled )
-    {
-        buf.setPooled( pooled );
-    }
-    
-    public Object getObject() throws ClassNotFoundException
-    {
-        return buf.getObject();
-    }
-
-    public Object getObject( ClassLoader classLoader ) throws ClassNotFoundException
-    {
-        return buf.getObject( classLoader );
-    }
-
-    public ByteBuffer putObject( Object o )
-    {
-        buf.putObject( o );
-        return this;
-    }
-    
-    public InputStream asInputStream()
-    {
-        return buf.asInputStream();
-    }
-    
-    public OutputStream asOutputStream()
-    {
-        return buf.asOutputStream();
-    }
-}
+/*
+ *   @(#) $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.FilterOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteOrder;
+import java.nio.CharBuffer;
+import java.nio.DoubleBuffer;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+import java.nio.LongBuffer;
+import java.nio.ShortBuffer;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+
+/**
+ * A {@link ByteBuffer} that wraps a buffer and proxies any operations to it.
+ * <p>
+ * You can think this class like a {@link FilterOutputStream}.  All operations
+ * are proxied by default so that you can extend this class and override existing
+ * operations selectively.  You can introduce new operations, too.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class ByteBufferProxy extends ByteBuffer
+{
+
+    /**
+     * The buffer proxied by this proxy.
+     */
+    protected ByteBuffer buf;
+
+    /**
+     * Create a new instance.
+     * @param buf the buffer to be proxied
+     */
+    protected ByteBufferProxy( ByteBuffer buf )
+    {
+        if( buf == null )
+        {
+            throw new NullPointerException( "buf" );
+        }
+        this.buf = buf;
+    }
+
+    public void acquire()
+    {
+        buf.acquire();
+    }
+
+    public void release()
+    {
+        buf.release();
+    }
+
+    public boolean isDirect()
+    {
+        return buf.isDirect();
+    }
+
+    public java.nio.ByteBuffer buf()
+    {
+        return buf.buf();
+    }
+
+    public int capacity()
+    {
+        return buf.capacity();
+    }
+
+    public int position()
+    {
+        return buf.position();
+    }
+
+    public ByteBuffer position( int newPosition )
+    {
+        buf.position( newPosition );
+        return this;
+    }
+
+    public int limit()
+    {
+        return buf.limit();
+    }
+
+    public ByteBuffer limit( int newLimit )
+    {
+        buf.limit( newLimit );
+        return this;
+    }
+
+    public ByteBuffer mark()
+    {
+        buf.mark();
+        return this;
+    }
+
+    public ByteBuffer reset()
+    {
+        buf.reset();
+        return this;
+    }
+
+    public ByteBuffer clear()
+    {
+        buf.clear();
+        return this;
+    }
+
+    public ByteBuffer flip()
+    {
+        buf.flip();
+        return this;
+    }
+
+    public ByteBuffer rewind()
+    {
+        buf.rewind();
+        return this;
+    }
+
+    public int remaining()
+    {
+        return buf.remaining();
+    }
+
+    public boolean hasRemaining()
+    {
+        return buf.hasRemaining();
+    }
+
+    public byte get()
+    {
+        return buf.get();
+    }
+
+    public short getUnsigned()
+    {
+        return buf.getUnsigned();
+    }
+
+    public ByteBuffer put( byte b )
+    {
+        buf.put( b );
+        return this;
+    }
+
+    public byte get( int index )
+    {
+        return buf.get( index );
+    }
+
+    public short getUnsigned( int index )
+    {
+        return buf.getUnsigned( index );
+    }
+
+    public ByteBuffer put( int index, byte b )
+    {
+        buf.put( index, b );
+        return this;
+    }
+
+    public ByteBuffer get( byte[] dst, int offset, int length )
+    {
+        buf.get( dst, offset, length );
+        return this;
+    }
+
+    public ByteBuffer get( byte[] dst )
+    {
+        buf.get( dst );
+        return this;
+    }
+
+    public ByteBuffer put( ByteBuffer src )
+    {
+        buf.put( src );
+        return this;
+    }
+
+    public ByteBuffer put( java.nio.ByteBuffer src )
+    {
+        buf.put( src );
+        return this;
+    }
+
+    public ByteBuffer put( byte[] src, int offset, int length )
+    {
+        buf.put( src, offset, length );
+        return this;
+    }
+
+    public ByteBuffer put( byte[] src )
+    {
+        buf.put( src );
+        return this;
+    }
+
+    public ByteBuffer compact()
+    {
+        buf.compact();
+        return this;
+    }
+
+    public String toString()
+    {
+        return buf.toString();
+    }
+
+    public int hashCode()
+    {
+        return buf.hashCode();
+    }
+
+    public boolean equals( Object ob )
+    {
+        return buf.equals( ob );
+    }
+
+    public int compareTo( ByteBuffer that )
+    {
+        return buf.compareTo( that );
+    }
+
+    public ByteOrder order()
+    {
+        return buf.order();
+    }
+
+    public ByteBuffer order( ByteOrder bo )
+    {
+        buf.order( bo );
+        return this;
+    }
+
+    public char getChar()
+    {
+        return buf.getChar();
+    }
+
+    public ByteBuffer putChar( char value )
+    {
+        buf.putChar( value );
+        return this;
+    }
+
+    public char getChar( int index )
+    {
+        return buf.getChar( index );
+    }
+
+    public ByteBuffer putChar( int index, char value )
+    {
+        buf.putChar( index, value );
+        return this;
+    }
+
+    public CharBuffer asCharBuffer()
+    {
+        return buf.asCharBuffer();
+    }
+
+    public short getShort()
+    {
+        return buf.getShort();
+    }
+
+    public int getUnsignedShort()
+    {
+        return buf.getUnsignedShort();
+    }
+
+    public ByteBuffer putShort( short value )
+    {
+        buf.putShort( value );
+        return this;
+    }
+
+    public short getShort( int index )
+    {
+        return buf.getShort( index );
+    }
+
+    public int getUnsignedShort( int index )
+    {
+        return buf.getUnsignedShort( index );
+    }
+
+    public ByteBuffer putShort( int index, short value )
+    {
+        buf.putShort( index, value );
+        return this;
+    }
+
+    public ShortBuffer asShortBuffer()
+    {
+        return buf.asShortBuffer();
+    }
+
+    public int getInt()
+    {
+        return buf.getInt();
+    }
+
+    public long getUnsignedInt()
+    {
+        return buf.getUnsignedInt();
+    }
+
+    public ByteBuffer putInt( int value )
+    {
+        buf.putInt( value );
+        return this;
+    }
+
+    public int getInt( int index )
+    {
+        return buf.getInt( index );
+    }
+
+    public long getUnsignedInt( int index )
+    {
+        return buf.getUnsignedInt( index );
+    }
+
+    public ByteBuffer putInt( int index, int value )
+    {
+        buf.putInt( index, value );
+        return this;
+    }
+
+    public IntBuffer asIntBuffer()
+    {
+        return buf.asIntBuffer();
+    }
+
+    public long getLong()
+    {
+        return buf.getLong();
+    }
+
+    public ByteBuffer putLong( long value )
+    {
+        buf.putLong( value );
+        return this;
+    }
+
+    public long getLong( int index )
+    {
+        return buf.getLong( index );
+    }
+
+    public ByteBuffer putLong( int index, long value )
+    {
+        buf.putLong( index, value );
+        return this;
+    }
+
+    public LongBuffer asLongBuffer()
+    {
+        return buf.asLongBuffer();
+    }
+
+    public float getFloat()
+    {
+        return buf.getFloat();
+    }
+
+    public ByteBuffer putFloat( float value )
+    {
+        buf.putFloat( value );
+        return this;
+    }
+
+    public float getFloat( int index )
+    {
+        return buf.getFloat( index );
+    }
+
+    public ByteBuffer putFloat( int index, float value )
+    {
+        buf.putFloat( index, value );
+        return this;
+    }
+
+    public FloatBuffer asFloatBuffer()
+    {
+        return buf.asFloatBuffer();
+    }
+
+    public double getDouble()
+    {
+        return buf.getDouble();
+    }
+
+    public ByteBuffer putDouble( double value )
+    {
+        buf.putDouble( value );
+        return this;
+    }
+
+    public double getDouble( int index )
+    {
+        return buf.getDouble( index );
+    }
+
+    public ByteBuffer putDouble( int index, double value )
+    {
+        buf.putDouble( index, value );
+        return this;
+    }
+
+    public DoubleBuffer asDoubleBuffer()
+    {
+        return buf.asDoubleBuffer();
+    }
+
+    public String getHexDump()
+    {
+        return buf.getHexDump();
+    }
+
+    public String getString( int fieldSize, CharsetDecoder decoder )
+            throws CharacterCodingException
+    {
+        return buf.getString( fieldSize, decoder );
+    }
+
+    public String getString( CharsetDecoder decoder )
+            throws CharacterCodingException
+    {
+        return buf.getString( decoder );
+    }
+    
+    public String getPascalString( CharsetDecoder decoder )
+            throws CharacterCodingException
+    {
+        return buf.getPascalString( decoder );
+    }
+
+    public ByteBuffer putString( CharSequence in, int fieldSize,
+                                CharsetEncoder encoder )
+            throws CharacterCodingException
+    {
+        buf.putString( in, fieldSize, encoder );
+        return this;
+    }
+
+    public ByteBuffer putString( CharSequence in, CharsetEncoder encoder )
+            throws CharacterCodingException
+    {
+        buf.putString( in, encoder );
+        return this;
+    }
+    
+    public ByteBuffer putPascalString( CharSequence in, CharsetEncoder encoder )
+            throws CharacterCodingException
+    {
+        buf.putPascalString( in, encoder );
+        return this;
+    }
+
+    public ByteBuffer skip( int size )
+    {
+        buf.skip( size );
+        return this;
+    }
+
+    public ByteBuffer fill( byte value, int size )
+    {
+        buf.fill( value, size );
+        return this;
+    }
+
+    public ByteBuffer fillAndReset( byte value, int size )
+    {
+        buf.fillAndReset( value, size );
+        return this;
+    }
+
+    public ByteBuffer fill( int size )
+    {
+        buf.fill( size );
+        return this;
+    }
+
+    public ByteBuffer fillAndReset( int size )
+    {
+        buf.fillAndReset( size );
+        return this;
+    }
+
+    public boolean isAutoExpand()
+    {
+        return buf.isAutoExpand();
+    }
+
+    public ByteBuffer setAutoExpand( boolean autoExpand )
+    {
+        buf.setAutoExpand( autoExpand );
+        return this;
+    }
+    
+    public boolean isPooled()
+    {
+        return buf.isPooled();
+    }
+    
+    public void setPooled( boolean pooled )
+    {
+        buf.setPooled( pooled );
+    }
+    
+    public Object getObject() throws ClassNotFoundException
+    {
+        return buf.getObject();
+    }
+
+    public Object getObject( ClassLoader classLoader ) throws ClassNotFoundException
+    {
+        return buf.getObject( classLoader );
+    }
+
+    public ByteBuffer putObject( Object o )
+    {
+        buf.putObject( o );
+        return this;
+    }
+    
+    public InputStream asInputStream()
+    {
+        return buf.asInputStream();
+    }
+    
+    public OutputStream asOutputStream()
+    {
+        return buf.asOutputStream();
+    }
+}

Modified: directory/network/trunk/src/java/org/apache/mina/common/ConnectFuture.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/ConnectFuture.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/ConnectFuture.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/ConnectFuture.java Wed Nov 30 21:17:41 2005
@@ -40,6 +40,16 @@
 public class ConnectFuture extends IoFuture
 {
     /**
+     * Returns a new {@link ConnectFuture} which is already marked as 'failed to connect'.
+     */
+    public static ConnectFuture newFailedFuture( IOException exception )
+    {
+        ConnectFuture failedFuture = new ConnectFuture();
+        failedFuture.setException( exception );
+        return failedFuture;
+    }
+
+    /**
      * Returns {@link IoSession} which is the result of connect operation.
      * 
      * @return <tt>null</tt> if the connect operation is not finished yet

Added: directory/network/trunk/src/java/org/apache/mina/common/DefaultIoFilterChainBuilder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/DefaultIoFilterChainBuilder.java?rev=350169&view=auto
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/DefaultIoFilterChainBuilder.java (added)
+++ directory/network/trunk/src/java/org/apache/mina/common/DefaultIoFilterChainBuilder.java Wed Nov 30 21:17:41 2005
@@ -0,0 +1,349 @@
+/*
+ *   @(#) $Id: DefaultIoFilterChainBuilder.java 350135 2005-12-01 03:43:29Z 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;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+import org.apache.mina.common.IoFilter.NextFilter;
+import org.apache.mina.common.IoFilterChain.Entry;
+
+/**
+ * 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 Directory Project (dev@directory.apache.org)
+ * @version $Rev: 350135 $, $Date: 2005-12-01 12:43:29 +0900 $
+ */
+public class DefaultIoFilterChainBuilder implements IoFilterChainBuilder
+{
+    private List entries = new ArrayList();
+    private final Map entriesByName = new HashMap();
+    
+    /**
+     * Creates a new instance with an empty filter list.
+     */
+    public DefaultIoFilterChainBuilder()
+    {
+    }
+
+    /**
+     * @see IoFilterChain#getEntry(String)
+     */
+    public synchronized Entry getEntry( String name )
+    {
+        return ( Entry ) entriesByName.get( name );
+    }
+
+    /**
+     * @see IoFilterChain#get(String)
+     */
+    public synchronized IoFilter get( String name )
+    {
+        Entry e = getEntry( name );
+        if( e == null )
+        {
+            return null;
+        }
+        
+        return e.getFilter();
+    }
+    
+    /**
+     * @see IoFilterChain#getAll()
+     */
+    public List getAll()
+    {
+        return new ArrayList( entries );
+    }
+    
+    /**
+     * @see IoFilterChain#getAllReversed()
+     */
+    public List getAllReversed()
+    {
+        List 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 )
+    {
+        for( Iterator i = entries.iterator(); i.hasNext(); )
+        {
+            Entry e = ( Entry ) i.next();
+            if( e.getFilter() == filter )
+            {
+                return true;
+            }
+        }
+        
+        return false;
+    }
+    
+    /**
+     * @see IoFilterChain#contains(Class)
+     */
+    public boolean contains( Class filterType )
+    {
+        for( Iterator i = entries.iterator(); i.hasNext(); )
+        {
+            Entry e = ( Entry ) i.next();
+            if( filterType.isAssignableFrom( e.getFilter().getClass() ) )
+            {
+                return true;
+            }
+        }
+        
+        return false;
+    }
+    
+    /**
+     * @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 i = entries.listIterator(); i.hasNext(); )
+        {
+            Entry base = ( Entry ) 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 );
+        
+        List entries = new ArrayList( this.entries );
+        
+        for( ListIterator i = entries.listIterator(); i.hasNext(); )
+        {
+            Entry base = ( Entry ) 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 i = entries.listIterator(); i.hasNext(); )
+        {
+            Entry e = ( Entry ) i.next();
+            if( e.getName().equals( name ) )
+            {
+                deregister( i.previousIndex(), e );
+                return e.getFilter();
+            }
+        }
+        
+        throw new IllegalArgumentException( "Unknown filter name: " + name );
+    }
+
+    /**
+     * @see IoFilterChain#clear()
+     */
+    public synchronized void clear() throws Exception
+    {
+        entries = new ArrayList();
+        entriesByName.clear();
+    }
+    
+    public void buildFilterChain( IoFilterChain chain ) throws Exception
+    {
+        for( Iterator i = entries.iterator(); i.hasNext(); )
+        {
+            Entry e = ( Entry ) i.next();
+            chain.addLast( e.getName(), e.getFilter() );
+        }
+    }
+    
+    public String toString()
+    {
+        StringBuffer buf = new StringBuffer();
+        buf.append( "{ " );
+        
+        boolean empty = true;
+        
+        for( Iterator i = entries.iterator(); i.hasNext(); )
+        {
+            Entry e = ( Entry ) i.next();
+            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( !entriesByName.containsKey( baseName ) )
+        {
+            throw new IllegalArgumentException( "Unknown filter name: " + baseName );
+        }
+    }
+
+    private void register( int index, Entry e )
+    {
+        if( entriesByName.containsKey( e.getName() ) )
+        {
+            throw new IllegalArgumentException( "Other filter is using the same name: " + e.getName() );
+        }
+
+        List newEntries = new ArrayList( entries );
+        newEntries.add( index, e );
+        this.entries = newEntries;
+        entriesByName.put( e.getName(), e );
+    }
+    
+    private void deregister( int index, Entry e )
+    {
+        List newEntries = new ArrayList( entries );
+        newEntries.remove( index );
+        this.entries = newEntries;
+        entriesByName.remove( e.getName() );
+    }
+
+    private static class EntryImpl implements Entry
+    {
+        private final String name;
+        private final 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;
+        }
+
+        public NextFilter getNextFilter()
+        {
+            throw new IllegalStateException();
+        }
+    }
+}

Modified: directory/network/trunk/src/java/org/apache/mina/common/ExceptionMonitor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/ExceptionMonitor.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/ExceptionMonitor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/ExceptionMonitor.java Wed Nov 30 21:17:41 2005
@@ -1,38 +1,38 @@
-/*
- *   @(#) $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;
-
-/**
- * Monitors uncaught exceptions.  {@link #exceptionCaught(Object, Throwable)} is
- * invoked when there are any uncaught exceptions.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- * 
- * @see DefaultExceptionMonitor
- */
-public interface ExceptionMonitor
-{
-    /**
-     * Invoked when there are any uncaught exceptions.
-     */
-    void exceptionCaught( Object source, Throwable cause );
+/*
+ *   @(#) $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;
+
+/**
+ * Monitors uncaught exceptions.  {@link #exceptionCaught(Object, Throwable)} is
+ * invoked when there are any uncaught exceptions.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ * 
+ * @see DefaultExceptionMonitor
+ */
+public interface ExceptionMonitor
+{
+    /**
+     * Invoked when there are any uncaught exceptions.
+     */
+    void exceptionCaught( Object source, Throwable cause );
 }

Modified: directory/network/trunk/src/java/org/apache/mina/common/IdleStatus.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IdleStatus.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IdleStatus.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IdleStatus.java Wed Nov 30 21:17:41 2005
@@ -1,77 +1,77 @@
-/*
- *   @(#) $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;
-
-
-/**
- * Represents the type of idleness of {@link IoSession} or
- * {@link IoSession}.  There are three types of idleness:
- * <ul>
- *   <li>{@link #READER_IDLE} - No data is coming from the remote peer.</li>
- *   <li>{@link #WRITER_IDLE} - Session is not writing any data.</li>
- *   <li>{@link #BOTH_IDLE} - Both {@link #READER_IDLE} and {@link #WRITER_IDLE}.</li>
- * </ul>
- * <p>
- * Idle time settings are all disabled by default.  You can enable them
- * using {@link IoSession#setIdleTime(IdleStatus,int)}.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public class IdleStatus
-{
-    /**
-     * Represents the session status that no data is coming from the remote
-     * peer.
-     */
-    public static final IdleStatus READER_IDLE = new IdleStatus( "reader idle" );
-
-    /**
-     * Represents the session status that the session is not writing any data.
-     */
-    public static final IdleStatus WRITER_IDLE = new IdleStatus( "writer idle" );
-
-    /**
-     * Represents both {@link #READER_IDLE} and {@link #WRITER_IDLE}.
-     */
-    public static final IdleStatus BOTH_IDLE = new IdleStatus( "both idle" );
-
-    private final String strValue;
-
-    /**
-     * Creates a new instance.
-     */
-    private IdleStatus( String strValue )
-    {
-        this.strValue = strValue;
-    }
-
-    /**
-     * Returns the string representation of this status.
-     * <ul>
-     *   <li>{@link #READER_IDLE} - <tt>"reader idle"</tt></li>
-     *   <li>{@link #WRITER_IDLE} - <tt>"writer idle"</tt></li>
-     *   <li>{@link #BOTH_IDLE} - <tt>"both idle"</tt></li>
-     * </ul>
-     */
-    public String toString()
-    {
-        return strValue;
-    }
+/*
+ *   @(#) $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;
+
+
+/**
+ * Represents the type of idleness of {@link IoSession} or
+ * {@link IoSession}.  There are three types of idleness:
+ * <ul>
+ *   <li>{@link #READER_IDLE} - No data is coming from the remote peer.</li>
+ *   <li>{@link #WRITER_IDLE} - Session is not writing any data.</li>
+ *   <li>{@link #BOTH_IDLE} - Both {@link #READER_IDLE} and {@link #WRITER_IDLE}.</li>
+ * </ul>
+ * <p>
+ * Idle time settings are all disabled by default.  You can enable them
+ * using {@link IoSession#setIdleTime(IdleStatus,int)}.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class IdleStatus
+{
+    /**
+     * Represents the session status that no data is coming from the remote
+     * peer.
+     */
+    public static final IdleStatus READER_IDLE = new IdleStatus( "reader idle" );
+
+    /**
+     * Represents the session status that the session is not writing any data.
+     */
+    public static final IdleStatus WRITER_IDLE = new IdleStatus( "writer idle" );
+
+    /**
+     * Represents both {@link #READER_IDLE} and {@link #WRITER_IDLE}.
+     */
+    public static final IdleStatus BOTH_IDLE = new IdleStatus( "both idle" );
+
+    private final String strValue;
+
+    /**
+     * Creates a new instance.
+     */
+    private IdleStatus( String strValue )
+    {
+        this.strValue = strValue;
+    }
+
+    /**
+     * Returns the string representation of this status.
+     * <ul>
+     *   <li>{@link #READER_IDLE} - <tt>"reader idle"</tt></li>
+     *   <li>{@link #WRITER_IDLE} - <tt>"writer idle"</tt></li>
+     *   <li>{@link #BOTH_IDLE} - <tt>"both idle"</tt></li>
+     * </ul>
+     */
+    public String toString()
+    {
+        return strValue;
+    }
 }

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoAcceptor.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoAcceptor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoAcceptor.java Wed Nov 30 21:17:41 2005
@@ -1,87 +1,98 @@
-/*
- *   @(#) $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;
-import java.net.SocketAddress;
-
-/**
- * Accepts incoming connection, communicates with clients, and fires events to
- * {@link IoHandler}s.
- * <p>
- * Please refer to
- * <a href="../../../../../xref-examples/org/apache/mina/examples/echoserver/Main.html">EchoServer</a>
- * example. 
- * <p>
- * You should bind to the desired socket address to accept incoming
- * connections, and then events for incoming connections will be sent to
- * the specified default {@link IoHandler}.
- * <p>
- * Threads accept incoming connections start automatically when
- * {@link #bind(SocketAddress, IoHandler)} is invoked, and stop when all
- * addresses are unbound.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public interface IoAcceptor extends IoSessionManager
-{
-    /**
-     * Binds to the specified <code>address</code> and handles incoming
-     * connections with the specified <code>handler</code>.
-     * 
-     * @throws IOException if failed to bind
-     */
-    void bind( SocketAddress address, IoHandler handler ) throws IOException;
-
-    /**
-     * Unbinds from the specified <code>address</code> and disconnects all clients
-     * connected there.
-     */
-    void unbind( SocketAddress address );
-    
-    /**
-     * (Optional) Returns an {@link IoSession} that is bound to the specified
-     * <tt>localAddress</tt> and <tt>remoteAddress</tt> which reuses
-     * the <tt>localAddress</tt> that is already bound by {@link IoAcceptor}
-     * via {@link #bind(SocketAddress, IoHandler)}.
-     * <p>
-     * This operation is optional.  Please throw {@link UnsupportedOperationException}
-     * if the transport type doesn't support this operation.  This operation is
-     * usually implemented for connectionless transport types.
-     * 
-     * @throws UnsupportedOperationException if this operation is not supported
-     * @throws IllegalArgumentException if the specified <tt>localAddress</tt> is
-     *                                  not bound yet. (see {@link #bind(SocketAddress, IoHandler)})
-     */
-    IoSession newSession( SocketAddress remoteAddress, SocketAddress localAddress );
-    
-    // TODO: DIRMINA-93
-    /**
-     * Returns <tt>true</tt> if and only if all clients are disconnected
-     * when this acceptor unbinds the related local address.
-     */
-    //boolean isDisconnectClientsOnUnbind();
-    
-    /**
-     * Sets whether all clients are disconnected from this acceptor unbinds the
-     * related local address.  The default value is <tt>true</tt>.
-     */
-    //void setDisconnectClientsOnUnbind( boolean disconnectClientsOnUnbind );
+/*
+ *   @(#) $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;
+import java.net.SocketAddress;
+
+/**
+ * Accepts incoming connection, communicates with clients, and fires events to
+ * {@link IoHandler}s.
+ * <p>
+ * Please refer to
+ * <a href="../../../../../xref-examples/org/apache/mina/examples/echoserver/Main.html">EchoServer</a>
+ * example. 
+ * <p>
+ * You should bind to the desired socket address to accept incoming
+ * connections, and then events for incoming connections will be sent to
+ * the specified default {@link IoHandler}.
+ * <p>
+ * Threads accept incoming connections start automatically when
+ * {@link #bind(SocketAddress, IoHandler)} is invoked, and stop when all
+ * addresses are unbound.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public interface IoAcceptor extends IoSessionManager
+{
+    /**
+     * Binds to the specified <code>address</code> and handles incoming
+     * connections with the specified <code>handler</code>.
+     * 
+     * @throws IOException if failed to bind
+     */
+    void bind( SocketAddress address, IoHandler handler ) throws IOException;
+
+    /**
+     * Binds to the specified <code>address</code> and handles incoming
+     * connections with the specified <code>handler</code>.
+     *
+     * @param filterChainBuilder
+     *            an {@link IoFilterChainBuilder} that will modify the
+     *            {@link IoFilterChain} of a newly created {@link IoSession}
+     * @throws IOException if failed to bind
+     */
+    void bind( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder ) throws IOException;
+
+    /**
+     * Unbinds from the specified <code>address</code> and disconnects all clients
+     * connected there.
+     */
+    void unbind( SocketAddress address );
+    
+    /**
+     * (Optional) Returns an {@link IoSession} that is bound to the specified
+     * <tt>localAddress</tt> and <tt>remoteAddress</tt> which reuses
+     * the <tt>localAddress</tt> that is already bound by {@link IoAcceptor}
+     * via {@link #bind(SocketAddress, IoHandler)}.
+     * <p>
+     * This operation is optional.  Please throw {@link UnsupportedOperationException}
+     * if the transport type doesn't support this operation.  This operation is
+     * usually implemented for connectionless transport types.
+     * 
+     * @throws UnsupportedOperationException if this operation is not supported
+     * @throws IllegalArgumentException if the specified <tt>localAddress</tt> is
+     *                                  not bound yet. (see {@link #bind(SocketAddress, IoHandler)})
+     */
+    IoSession newSession( SocketAddress remoteAddress, SocketAddress localAddress );
+    
+    // TODO: DIRMINA-93
+    /**
+     * Returns <tt>true</tt> if and only if all clients are disconnected
+     * when this acceptor unbinds the related local address.
+     */
+    //boolean isDisconnectClientsOnUnbind();
+    
+    /**
+     * Sets whether all clients are disconnected from this acceptor unbinds the
+     * related local address.  The default value is <tt>true</tt>.
+     */
+    //void setDisconnectClientsOnUnbind( boolean disconnectClientsOnUnbind );
 }

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoConnector.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoConnector.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoConnector.java Wed Nov 30 21:17:41 2005
@@ -1,80 +1,104 @@
-/*
- *   @(#) $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;
-import java.net.SocketAddress;
-
-/**
- * Connects to endpoint, communicates with the server, and fires events to
- * {@link IoHandler}s.
- * <p>
- * Please refer to
- * <a href="../../../../../xref-examples/org/apache/mina/examples/netcat/Main.html">NetCat</a>
- * example. 
- * <p>
- * You should connect to the desired socket address to start communication,
- * and then events for incoming connections will be sent to the specified
- * default {@link IoHandler}.
- * <p>
- * Threads connect to endpoint start automatically when
- * {@link #connect(SocketAddress, IoHandler)} is invoked, and stop when all
- * connection attempts are finished.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public interface IoConnector extends IoSessionManager
-{
-    /**
-     * Connects to the specified <code>address</code>.  If communication starts
-     * successfully, events are fired to the specified
-     * <code>handler</code>.
-     * 
-     * @throws IOException if failed to connect
-     */
-    ConnectFuture connect( SocketAddress address, IoHandler handler )
-            throws IOException;
-
-    /**
-     * Connects to the specified <code>address</code>.  If communication starts
-     * successfully, events are fired to the specified
-     * <code>handler</code>.
-     * 
-     * @param localAddress the local address the channel is bound to
-     * @throws IOException if failed to connect
-     */
-    ConnectFuture connect( SocketAddress address, SocketAddress localAddress,
-                           IoHandler handler ) throws IOException;
-
-    /**
-     * Returns the connect timeout in seconds.
-     */
-    int getConnectTimeout();
-
-    /**
-     * Returns the connect timeout in milliseconds.
-     */
-    long getConnectTimeoutMillis();
-
-    /**
-     * Sets the connect timeout in seconds.
-     */
-    void setConnectTimeout( int connectTimeout );
+/*
+ *   @(#) $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;
+
+/**
+ * Connects to endpoint, communicates with the server, and fires events to
+ * {@link IoHandler}s.
+ * <p>
+ * Please refer to
+ * <a href="../../../../../xref-examples/org/apache/mina/examples/netcat/Main.html">NetCat</a>
+ * example. 
+ * <p>
+ * You should connect to the desired socket address to start communication,
+ * and then events for incoming connections will be sent to the specified
+ * default {@link IoHandler}.
+ * <p>
+ * Threads connect to endpoint start automatically when
+ * {@link #connect(SocketAddress, IoHandler)} is invoked, and stop when all
+ * connection attempts are finished.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public interface IoConnector extends IoSessionManager
+{
+    /**
+     * Connects to the specified <code>address</code>.  If communication starts
+     * successfully, events are fired to the specified
+     * <code>handler</code>.
+     * 
+     * @returns {@link ConnectFuture} that will tell the result of the connection attempt
+     */
+    ConnectFuture connect( SocketAddress address, IoHandler handler );
+    
+    /**
+     * Connects to the specified <code>address</code>.  If communication starts
+     * successfully, events are fired to the specified
+     * <code>handler</code>.
+     * 
+     * @param filterChainBuilder
+     *            an {@link IoFilterChainBuilder} that will modify the
+     *            {@link IoFilterChain} of a newly created {@link IoSession}
+     * @returns {@link ConnectFuture} that will tell the result of the connection attempt
+     */
+    ConnectFuture connect( SocketAddress address, IoHandler handler,
+                           IoFilterChainBuilder filterChainBuilder );
+
+    /**
+     * Connects to the specified <code>address</code>.  If communication starts
+     * successfully, events are fired to the specified
+     * <code>handler</code>.
+     * 
+     * @param localAddress the local address the channel is bound to
+     * @returns {@link ConnectFuture} that will tell the result of the connection attempt
+     */
+    ConnectFuture connect( SocketAddress address, SocketAddress localAddress,
+                           IoHandler handler );
+
+    /**
+     * Connects to the specified <code>address</code>.  If communication starts
+     * successfully, events are fired to the specified
+     * <code>handler</code>.
+     * 
+     * @param filterChainBuilder
+     *            an {@link IoFilterChainBuilder} that will modify the
+     *            {@link IoFilterChain} of a newly created {@link IoSession}
+     * @returns {@link ConnectFuture} that will tell the result of the connection attempt
+     */
+    ConnectFuture connect( SocketAddress address, SocketAddress localAddress,
+                           IoHandler handler, IoFilterChainBuilder filterChainBuilder );
+    
+    /**
+     * Returns the connect timeout in seconds.
+     */
+    int getConnectTimeout();
+
+    /**
+     * Returns the connect timeout in milliseconds.
+     */
+    long getConnectTimeoutMillis();
+
+    /**
+     * Sets the connect timeout in seconds.
+     */
+    void setConnectTimeout( int connectTimeout );
 }

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoFilter.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoFilter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoFilter.java Wed Nov 30 21:17:41 2005
@@ -1,232 +1,303 @@
-/*
- *   @(#) $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;
-
-
-
-/**
- * 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.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- * 
- * @see IoFilterAdapter
- */
-public interface IoFilter
-{
-    /**
-     * Invoked when 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.
-     *
-     * @param parent the parent who called this method
-     * @param nextFilter the {@link NextFilter} for this filter.  You can reuse
-     *                   this object until this filter is removed from the chain.
-     */
-    void init( IoFilterChain parent, NextFilter nextFilter ) throws Exception;
-    
-    /**
-     * Invoked when 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.
-     *
-     * @param parent the parent who called this method
-     * @param nextFilter the {@link NextFilter} for this filter.  You can reuse
-     *                   this object until this filter is removed from the chain.
-     */
-    void destroy( IoFilterChain parent, 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,
-                      Object message ) throws Exception;
-
-    /**
-     * Filters {@link IoSession#close()} method invocation.
-     */
-    void filterClose( NextFilter nextFilter, IoSession session, CloseFuture closeFuture ) throws Exception;
-    
-    /**
-     * Filters {@link IoSession#write(Object)} method invocation.
-     */
-    void filterWrite( NextFilter nextFilter, IoSession session, WriteRequest writeRequest ) 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, Object message );
-
-        /**
-         * 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, CloseFuture closeFuture );
-    }
-    
-    /**
-     * Represents write request fired by {@link IoSession#write(Object)}.
-     */
-    public static class WriteRequest
-    {
-        private static final WriteFuture UNUSED_FUTURE = new WriteFuture();
-        
-        private final Object message;
-        private final WriteFuture future;
-        
-        /**
-         * Creates a new instance without {@link WriteFuture}.  You'll get
-         * an instance of {@link WriteFuture} even if you called this constructor
-         * because {@link #getFuture()} will return a bogus future.
-         */
-        public WriteRequest( Object message )
-        {
-            this( message, null );
-        }
-
-        /**
-         * Creates a new instance with {@link WriteFuture}.
-         */
-        public WriteRequest( Object message, WriteFuture future )
-        {
-            if( message == null )
-            {
-                throw new NullPointerException( "message" );
-            }
-            
-            if( future == null )
-            {
-                future = UNUSED_FUTURE;
-            }
-            
-            this.message = message;
-            this.future = future;
-        }
-
-        /**
-         * Returns {@link WriteFuture} that is associated with this write request.
-         */
-        public WriteFuture getFuture()
-        {
-            return future;
-        }
-
-        /**
-         * Returns a message object to be written.
-         */
-        public Object getMessage()
-        {
-            return message;
-        }
-        
-        public String toString()
-        {
-            return message.toString();
-        }
-    }
-}
+/*
+ *   @(#) $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;
+
+
+
+/**
+ * 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 IoFilterChain} 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.IoFilter.NextFilter)}
+ *       threw an exception.  {@link #destroy()} is also invoked 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 if the removed filter was the last one.</li>
+ * </ol>      
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ * 
+ * @see IoFilterAdapter
+ */
+public interface IoFilter
+{
+    /**
+     * Invoked when this filter is added to a {@link IoFilterChain}
+     * at the first time, so you can initialize shared resources.
+     */
+    void init() throws Exception;
+
+    /**
+     * Invoked when this filter is not used by any {@link IoFilterChain}
+     * anymore, so you can destroy shared resources.
+     */
+    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,
+                      Object message ) throws Exception;
+
+    /**
+     * Filters {@link IoSession#close()} method invocation.
+     */
+    void filterClose( NextFilter nextFilter, IoSession session, CloseFuture closeFuture ) throws Exception;
+    
+    /**
+     * Filters {@link IoSession#write(Object)} method invocation.
+     */
+    void filterWrite( NextFilter nextFilter, IoSession session, WriteRequest writeRequest ) 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, Object message );
+
+        /**
+         * 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, CloseFuture closeFuture );
+    }
+    
+    /**
+     * Represents write request fired by {@link IoSession#write(Object)}.
+     */
+    public static class WriteRequest
+    {
+        private static final WriteFuture UNUSED_FUTURE = new WriteFuture();
+        
+        private final Object message;
+        private final WriteFuture future;
+        
+        /**
+         * Creates a new instance without {@link WriteFuture}.  You'll get
+         * an instance of {@link WriteFuture} even if you called this constructor
+         * because {@link #getFuture()} will return a bogus future.
+         */
+        public WriteRequest( Object message )
+        {
+            this( message, null );
+        }
+
+        /**
+         * Creates a new instance with {@link WriteFuture}.
+         */
+        public WriteRequest( Object message, WriteFuture future )
+        {
+            if( message == null )
+            {
+                throw new NullPointerException( "message" );
+            }
+            
+            if( future == null )
+            {
+                future = UNUSED_FUTURE;
+            }
+            
+            this.message = message;
+            this.future = future;
+        }
+
+        /**
+         * Returns {@link WriteFuture} that is associated with this write request.
+         */
+        public WriteFuture getFuture()
+        {
+            return future;
+        }
+
+        /**
+         * Returns a message object to be written.
+         */
+        public Object getMessage()
+        {
+            return message;
+        }
+        
+        public String toString()
+        {
+            return message.toString();
+        }
+    }
+}

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoFilterAdapter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoFilterAdapter.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoFilterAdapter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoFilterAdapter.java Wed Nov 30 21:17:41 2005
@@ -1,83 +1,99 @@
-/*
- *   @(#) $Id$
- *
- *   Copyright 2004 The Apache Software Foundation
- *
- *   Licensed under the Apache License, Version 2.0 (the "License");
- *   you may not use this file except in compliance with the License.
- *   You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
- *
- */
-package org.apache.mina.common;
-
-/**
- * An 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 Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public class IoFilterAdapter implements IoFilter
-{
-    public void init( IoFilterChain parent, NextFilter nextFilter ) throws Exception
-    {
-    }
-    
-    public void destroy( IoFilterChain parent, 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, Object message ) throws Exception
-    {
-        nextFilter.messageSent( session, message );
-    }
-
-    public void filterWrite( NextFilter nextFilter, IoSession session, WriteRequest writeRequest ) throws Exception
-    {
-        nextFilter.filterWrite( session, writeRequest );
-    }
-
-    public void filterClose( NextFilter nextFilter, IoSession session, CloseFuture closeFuture ) throws Exception
-    {
-        nextFilter.filterClose( session, closeFuture );
-    }
+/*
+ *   @(#) $Id$
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.mina.common;
+
+/**
+ * An 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 Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+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, Object message ) throws Exception
+    {
+        nextFilter.messageSent( session, message );
+    }
+
+    public void filterWrite( NextFilter nextFilter, IoSession session, WriteRequest writeRequest ) throws Exception
+    {
+        nextFilter.filterWrite( session, writeRequest );
+    }
+
+    public void filterClose( NextFilter nextFilter, IoSession session, CloseFuture closeFuture ) throws Exception
+    {
+        nextFilter.filterClose( session, closeFuture );
+    }
 }



Mime
View raw message