directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r123396 - in incubator/directory/network/trunk/mina/src: examples/org/apache/mina/examples/reverser java/org/apache/mina/common java/org/apache/mina/io java/org/apache/mina/io/datagram java/org/apache/mina/io/filter java/org/apache/mina/io/socket java/org/apache/mina/protocol java/org/apache/mina/protocol/filter java/org/apache/mina/util
Date Mon, 27 Dec 2004 07:29:50 GMT
Author: trustin
Date: Sun Dec 26 23:29:48 2004
New Revision: 123396

URL: http://svn.apache.org/viewcvs?view=rev&rev=123396
Log:
Added some JavaDocs. :)
Modified:
   incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/reverser/TextLineDecoder.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/ByteBuffer.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/IdleStatus.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/SessionConfig.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Acceptor.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/ExceptionMonitor.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandler.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerAdapter.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerFilter.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerFilterAdapter.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoSession.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/WriteTimeoutException.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramConnector.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramProcessor.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramSession.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramSessionConfig.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/BlacklistFilter.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketAcceptor.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketConnector.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketIoProcessor.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketSession.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketSessionConfig.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/IoAdapter.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolCodecFactory.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolDecoder.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolDecoderOutput.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolEncoder.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolProvider.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/filter/ProtocolThreadPoolFilter.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/BasicSessionConfig.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/DefaultExceptionMonitor.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/IoHandlerFilterManager.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Queue.java
   incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Stack.java

Modified: incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/reverser/TextLineDecoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/reverser/TextLineDecoder.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/reverser/TextLineDecoder.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/reverser/TextLineDecoder.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/reverser/TextLineDecoder.java	(original)
+++ incubator/directory/network/trunk/mina/src/examples/org/apache/mina/examples/reverser/TextLineDecoder.java	Sun Dec 26 23:29:48 2004
@@ -35,7 +35,8 @@
 
     private StringBuffer decodeBuf = new StringBuffer();
 
-    public void decode( ProtocolSession session, ByteBuffer in, ProtocolDecoderOutput out )
+    public void decode( ProtocolSession session, ByteBuffer in,
+                       ProtocolDecoderOutput out )
             throws ProtocolViolationException
     {
         do
@@ -48,7 +49,7 @@
             case '\n':
                 String result = decodeBuf.toString();
                 decodeBuf.delete( 0, decodeBuf.length() );
-                out.write(result);
+                out.write( result );
                 break;
             default:
                 decodeBuf.append( ( char ) b );

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/ByteBuffer.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/ByteBuffer.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/ByteBuffer.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/ByteBuffer.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/ByteBuffer.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/ByteBuffer.java	Sun Dec 26 23:29:48 2004
@@ -14,396 +14,481 @@
 import org.apache.mina.util.Stack;
 
 /**
- * A byte buffer used by MINA applications.
+ * A pooled direct byte buffer used by MINA applications.
  * <p>
- * This is a replacement for {@link java.nio.ByteBuffer}. Please see
- * {@link java.nio.ByteBuffer} documentation for usage.
+ * This is a replacement for {@link java.nio.ByteBuffer}. Please refer to
+ * {@link java.nio.ByteBuffer} and {@link java.nio.Buffer} documentation for
+ * usage.  MINA does not use NIO {@link java.nio.ByteBuffer} directly for two
+ * reasons:
+ * <ul>
+ *   <li>It doesn't provide useful getters and putters such as
+ *       <code>fill</code>, <code>get/putString</code>, and
+ *       <code>get/putAsciiInt()</code> enough.</li>
+ *   <li>It is hard to distinguish if the buffer is created from MINA buffer
+ *       pool or not.  MINA have to return used buffers back to pool.</li>
+ * </ul>
+ * <p>
+ * You can get (or allocate) a new buffer from buffer pool:
+ * <pre>
+ * ByteBuffer buf = ByteBuffer.allocate(1024);
+ * </pre>
+ * <p>
+ * <b>Please note that you never need to release the allocated buffer because
+ * MINA will release it automatically.</b>  But, if you didn't pass it to MINA,
+ * you will have to release it manually:
+ * <pre>
+ * ByteBuffer.release(buf);
+ * </pre>
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$,
  */
-public final class ByteBuffer {
-	
-	public static final int MAXIMUM_CAPACITY = 8192;
-	
-    private static final int[] bufferStackSizes = new int[] {
-    		16,
-			32,
-			64,
-			128,
-			256,
-			512,
-			1024,
-			2048,
-			3072,
-			4096,
-			6144,
-			8192,
-    };
-    
-    private static final Stack[] bufferStacks = new Stack[] {
-    		new Stack(),
-    		new Stack(),
-    		new Stack(),
-    		new Stack(),
-    		new Stack(),
-    		new Stack(),
-    		new Stack(),
-    		new Stack(),
-    		new Stack(),
-    		new Stack(),
-    		new Stack(),
-    		new Stack(),
-    };
-    
-    public static ByteBuffer allocate(int size)
-    {
-    	int idx = getBufferStackIndex(size);
-    	Stack stack = bufferStacks[idx];
-    	
-    	ByteBuffer buf;
-		synchronized (stack)
-		{
-			buf = (ByteBuffer) stack.pop();
-    		if (buf == null)
-    		{
-    			buf = new ByteBuffer(java.nio.ByteBuffer.allocateDirect( bufferStackSizes[ idx ] ));
-    		}
-		}
-		
-		buf.clear();
-		return buf;
-    }
+public final class ByteBuffer
+{
+    /**
+     * The maximum capacity of allocatable buffer (8192).
+     */
+    public static final int MAXIMUM_CAPACITY = 8192;
+
+    private static final int[] bufferStackSizes = new int[] { 16, 32, 64, 128,
+                                                             256, 512, 1024,
+                                                             2048, 3072, 4096,
+                                                             6144, 8192, };
+
+    private static final Stack[] bufferStacks = new Stack[] { new Stack(),
+                                                             new Stack(),
+                                                             new Stack(),
+                                                             new Stack(),
+                                                             new Stack(),
+                                                             new Stack(),
+                                                             new Stack(),
+                                                             new Stack(),
+                                                             new Stack(),
+                                                             new Stack(),
+                                                             new Stack(),
+                                                             new Stack(), };
+
+    /**
+     * Returns the buffer which is capable of the specified size.
+     */
+    public static ByteBuffer allocate( int size )
+    {
+        int idx = getBufferStackIndex( size );
+        Stack stack = bufferStacks[ idx ];
 
+        ByteBuffer buf;
+        synchronized( stack )
+        {
+            buf = ( ByteBuffer ) stack.pop();
+            if( buf == null )
+            {
+                buf = new ByteBuffer( java.nio.ByteBuffer
+                        .allocateDirect( bufferStackSizes[ idx ] ) );
+            }
+        }
+
+        buf.clear();
+        return buf;
+    }
+
+    /**
+     * Returns the specified buffer to buffer pool.
+     */
     public static void release( ByteBuffer buf )
     {
-    	Stack stack = bufferStacks[ getBufferStackIndex( buf.capacity() ) ];
-    	synchronized (stack)
-		{
-    		stack.push( buf );
-		}
-    }
-    
-    private static int getBufferStackIndex(int size) {
-    	if (size <= 16)
-    		return 0;
-    	if (size <= 32)
-    		return 1;
-    	if (size <= 64)
-    		return 2;
-    	if (size <= 128)
-    		return 3;
-    	if (size <= 256)
-    		return 4;
-    	if (size <= 512)
-    		return 5;
-    	if (size <= 1024)
-    		return 6;
-    	if (size <= 2048)
-    		return 7;
-    	if (size <= 3072)
-    		return 8;
-    	if (size <= 4096)
-    		return 9;
-    	if (size <= 6144)
-    		return 10;
-    	if (size <= 8192)
-    		return 11;
-    	
-    	throw new IllegalArgumentException("Buffer size cannot exceed 8192: " + size);
+        Stack stack = bufferStacks[ getBufferStackIndex( buf.capacity() ) ];
+        synchronized( stack )
+        {
+            stack.push( buf );
+        }
+    }
+
+    private static int getBufferStackIndex( int size )
+    {
+        if( size <= 16 )
+            return 0;
+        if( size <= 32 )
+            return 1;
+        if( size <= 64 )
+            return 2;
+        if( size <= 128 )
+            return 3;
+        if( size <= 256 )
+            return 4;
+        if( size <= 512 )
+            return 5;
+        if( size <= 1024 )
+            return 6;
+        if( size <= 2048 )
+            return 7;
+        if( size <= 3072 )
+            return 8;
+        if( size <= 4096 )
+            return 9;
+        if( size <= 6144 )
+            return 10;
+        if( size <= 8192 )
+            return 11;
+
+        throw new IllegalArgumentException( "Buffer size cannot exceed 8192: "
+                                            + size );
     }
 
     private final java.nio.ByteBuffer buf;
 
-	private ByteBuffer(java.nio.ByteBuffer buf) {
-		this.buf = buf;
-	}
-	
-	/**
-	 * Returns the underlying NIO buffer instance.
-	 */
-	public java.nio.ByteBuffer buf() {
-		return buf;
-	}
+    private ByteBuffer( java.nio.ByteBuffer buf )
+    {
+        this.buf = buf;
+    }
+
+    /**
+     * Returns the underlying NIO buffer instance.
+     */
+    public java.nio.ByteBuffer buf()
+    {
+        return buf;
+    }
 
-	public int capacity() {
-		return buf.capacity();
-	}
+    public int capacity()
+    {
+        return buf.capacity();
+    }
 
-	public int position() {
-		return buf.position();
-	}
+    public int position()
+    {
+        return buf.position();
+    }
 
-	public ByteBuffer position(int newPosition) {
-		buf.position(newPosition);
-		return this;
-	}
+    public ByteBuffer position( int newPosition )
+    {
+        buf.position( newPosition );
+        return this;
+    }
 
-	public int limit() {
-		return buf.limit();
-	}
+    public int limit()
+    {
+        return buf.limit();
+    }
 
-	public ByteBuffer limit(int newLimit) {
-		buf.limit(newLimit);
-		return this;
-	}
+    public ByteBuffer limit( int newLimit )
+    {
+        buf.limit( newLimit );
+        return this;
+    }
 
-	public ByteBuffer mark() {
-		buf.mark();
-		return this;
-	}
+    public ByteBuffer mark()
+    {
+        buf.mark();
+        return this;
+    }
 
-	public ByteBuffer reset() {
-		buf.reset();
-		return this;
-	}
+    public ByteBuffer reset()
+    {
+        buf.reset();
+        return this;
+    }
 
-	public ByteBuffer clear() {
-		buf.clear();
-		return this;
-	}
+    public ByteBuffer clear()
+    {
+        buf.clear();
+        return this;
+    }
 
-	public ByteBuffer flip() {
-		buf.flip();
-		return this;
-	}
+    public ByteBuffer flip()
+    {
+        buf.flip();
+        return this;
+    }
 
-	public ByteBuffer rewind() {
-		buf.rewind();
-		return this;
-	}
+    public ByteBuffer rewind()
+    {
+        buf.rewind();
+        return this;
+    }
 
-	public int remaining() {
-		return buf.remaining();
-	}
+    public int remaining()
+    {
+        return buf.remaining();
+    }
 
-	public boolean hasRemaining() {
-		return buf.hasRemaining();
-	}
+    public boolean hasRemaining()
+    {
+        return buf.hasRemaining();
+    }
 
-    public java.nio.ByteBuffer slice() {
-    	return buf.slice();
+    public java.nio.ByteBuffer slice()
+    {
+        return buf.slice();
     }
 
-    public java.nio.ByteBuffer duplicate() {
-    	return buf.duplicate();
+    public java.nio.ByteBuffer duplicate()
+    {
+        return buf.duplicate();
     }
 
-    public java.nio.ByteBuffer asReadOnlyBuffer() {
-    	return buf.asReadOnlyBuffer();
+    public java.nio.ByteBuffer asReadOnlyBuffer()
+    {
+        return buf.asReadOnlyBuffer();
     }
 
-    public byte get() {
-    	return buf.get();
+    public byte get()
+    {
+        return buf.get();
     }
 
-    public ByteBuffer put(byte b) {
-    	buf.put(b);
-    	return this;
+    public ByteBuffer put( byte b )
+    {
+        buf.put( b );
+        return this;
     }
 
-    public byte get(int index) {
-    	return buf.get(index);
+    public byte get( int index )
+    {
+        return buf.get( index );
     }
 
-    public ByteBuffer put(int index, byte b) {
-    	buf.put(index, b);
-    	return this;
+    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, int offset, int length )
+    {
+        buf.get( dst, offset, length );
+        return this;
     }
 
-    public ByteBuffer get(byte[] dst) {
-    	buf.get(dst);
-    	return this;
+    public ByteBuffer get( byte[] dst )
+    {
+        buf.get( dst );
+        return this;
     }
 
-    public ByteBuffer put(java.nio.ByteBuffer src) {
-    	buf.put(src);
-    	return this;
+    public ByteBuffer put( java.nio.ByteBuffer src )
+    {
+        buf.put( src );
+        return this;
     }
-    
-    public ByteBuffer put(ByteBuffer src) {
-    	buf.put(src.buf());
-    	return this;
+
+    public ByteBuffer put( ByteBuffer src )
+    {
+        buf.put( src.buf() );
+        return this;
     }
 
-    public ByteBuffer put(byte[] src, int offset, int length) {
-    	buf.put(src, offset, length);
-    	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 put( byte[] src )
+    {
+        buf.put( src );
+        return this;
     }
 
-    public ByteBuffer compact() {
-    	buf.compact();
-    	return this;
+    public ByteBuffer compact()
+    {
+        buf.compact();
+        return this;
     }
 
-    public String toString() {
-    	return buf.toString();
+    public String toString()
+    {
+        return buf.toString();
     }
 
-    public int hashCode() {
-    	return buf.hashCode();
+    public int hashCode()
+    {
+        return buf.hashCode();
     }
 
-    public boolean equals(Object ob) {
-		if (!(ob instanceof ByteBuffer))
-		    return false;
+    public boolean equals( Object ob )
+    {
+        if( ! ( ob instanceof ByteBuffer ) )
+            return false;
 
-		ByteBuffer that = (ByteBuffer)ob;
-		return this.buf.equals(that.buf);
+        ByteBuffer that = ( ByteBuffer ) ob;
+        return this.buf.equals( that.buf );
     }
 
-    public int compareTo(ByteBuffer that) {
-    	return this.buf.compareTo(that.buf);
+    public int compareTo( ByteBuffer that )
+    {
+        return this.buf.compareTo( that.buf );
     }
 
-    public ByteOrder order() {
-    	return buf.order();
+    public ByteOrder order()
+    {
+        return buf.order();
     }
 
-    public ByteBuffer order(ByteOrder bo) {
-    	buf.order(bo);
-    	return this;
+    public ByteBuffer order( ByteOrder bo )
+    {
+        buf.order( bo );
+        return this;
     }
 
-    public char getChar() {
-    	return buf.getChar();
+    public char getChar()
+    {
+        return buf.getChar();
     }
 
-    public ByteBuffer putChar(char value) {
-    	buf.putChar(value);
-    	return this;
+    public ByteBuffer putChar( char value )
+    {
+        buf.putChar( value );
+        return this;
     }
 
-    public char getChar(int index) {
-    	return buf.getChar(index);
+    public char getChar( int index )
+    {
+        return buf.getChar( index );
     }
 
-    public ByteBuffer putChar(int index, char value) {
-    	buf.putChar(index, value);
-    	return this;
+    public ByteBuffer putChar( int index, char value )
+    {
+        buf.putChar( index, value );
+        return this;
     }
 
-    public CharBuffer asCharBuffer() {
-    	return buf.asCharBuffer();
+    public CharBuffer asCharBuffer()
+    {
+        return buf.asCharBuffer();
     }
 
-    public short getShort() {
-    	return buf.getShort();
+    public short getShort()
+    {
+        return buf.getShort();
     }
 
-    public ByteBuffer putShort(short value) {
-    	buf.putShort(value);
-    	return this;
+    public ByteBuffer putShort( short value )
+    {
+        buf.putShort( value );
+        return this;
     }
 
-    public short getShort(int index) {
-    	return buf.getShort(index);
+    public short getShort( int index )
+    {
+        return buf.getShort( index );
     }
 
-    public ByteBuffer putShort(int index, short value) {
-    	buf.putShort(index, value);
-    	return this;
+    public ByteBuffer putShort( int index, short value )
+    {
+        buf.putShort( index, value );
+        return this;
     }
 
-    public ShortBuffer asShortBuffer() {
-    	return buf.asShortBuffer();
+    public ShortBuffer asShortBuffer()
+    {
+        return buf.asShortBuffer();
     }
 
-    public int getInt() {
-    	return buf.getInt();
+    public int getInt()
+    {
+        return buf.getInt();
     }
 
-    public ByteBuffer putInt(int value) {
-    	buf.putInt(value);
-    	return this;
+    public ByteBuffer putInt( int value )
+    {
+        buf.putInt( value );
+        return this;
     }
 
-    public int getInt(int index) {
-    	return buf.getInt(index);
+    public int getInt( int index )
+    {
+        return buf.getInt( index );
     }
 
-    public ByteBuffer putInt(int index, int value) {
-    	buf.putInt(index, value);
-    	return this;
+    public ByteBuffer putInt( int index, int value )
+    {
+        buf.putInt( index, value );
+        return this;
     }
 
-    public IntBuffer asIntBuffer() {
-    	return buf.asIntBuffer();
+    public IntBuffer asIntBuffer()
+    {
+        return buf.asIntBuffer();
     }
 
-    public long getLong() {
-    	return buf.getLong();
+    public long getLong()
+    {
+        return buf.getLong();
     }
 
-    public ByteBuffer putLong(long value) {
-    	buf.putLong(value);
-    	return this;
+    public ByteBuffer putLong( long value )
+    {
+        buf.putLong( value );
+        return this;
     }
 
-    public long getLong(int index) {
-    	return buf.getLong(index);
+    public long getLong( int index )
+    {
+        return buf.getLong( index );
     }
 
-    public ByteBuffer putLong(int index, long value) {
-    	buf.putLong(index, value);
-    	return this;
+    public ByteBuffer putLong( int index, long value )
+    {
+        buf.putLong( index, value );
+        return this;
     }
 
-    public LongBuffer asLongBuffer() {
-    	return buf.asLongBuffer();
+    public LongBuffer asLongBuffer()
+    {
+        return buf.asLongBuffer();
     }
 
-    public float getFloat() {
-    	return buf.getFloat();
+    public float getFloat()
+    {
+        return buf.getFloat();
     }
 
-    public ByteBuffer putFloat(float value) {
-    	buf.putFloat(value);
-    	return this;
+    public ByteBuffer putFloat( float value )
+    {
+        buf.putFloat( value );
+        return this;
     }
 
-    public float getFloat(int index) {
-    	return buf.getFloat(index);
+    public float getFloat( int index )
+    {
+        return buf.getFloat( index );
     }
 
-    public ByteBuffer putFloat(int index, float value) {
-    	buf.putFloat(index, value);
-    	return this;
+    public ByteBuffer putFloat( int index, float value )
+    {
+        buf.putFloat( index, value );
+        return this;
     }
 
-    public FloatBuffer asFloatBuffer() {
-    	return buf.asFloatBuffer();
+    public FloatBuffer asFloatBuffer()
+    {
+        return buf.asFloatBuffer();
     }
 
-    public double getDouble() {
-    	return buf.getDouble();
+    public double getDouble()
+    {
+        return buf.getDouble();
     }
 
-    public ByteBuffer putDouble(double value) {
-    	buf.putDouble(value);
-    	return this;
+    public ByteBuffer putDouble( double value )
+    {
+        buf.putDouble( value );
+        return this;
     }
 
-    public double getDouble(int index) {
-    	return buf.getDouble(index);
+    public double getDouble( int index )
+    {
+        return buf.getDouble( index );
     }
 
-    public ByteBuffer putDouble(int index, double value) {
-    	buf.putDouble(index, value);
-    	return this;
+    public ByteBuffer putDouble( int index, double value )
+    {
+        buf.putDouble( index, value );
+        return this;
     }
 
-    public DoubleBuffer asDoubleBuffer() {
-    	return buf.asDoubleBuffer();
+    public DoubleBuffer asDoubleBuffer()
+    {
+        return buf.asDoubleBuffer();
     }
 }

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/IdleStatus.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/IdleStatus.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/IdleStatus.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/IdleStatus.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/IdleStatus.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/IdleStatus.java	Sun Dec 26 23:29:48 2004
@@ -18,18 +18,40 @@
  */
 package org.apache.mina.common;
 
+import org.apache.mina.io.IoSession;
+import org.apache.mina.protocol.ProtocolSession;
+
 /**
- * TODO Insert type comment.
+ * Represents the type of idleness of {@link IoSession} or
+ * {@link ProtocolSession}.  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 all or
+ * partly using {@link SessionConfig#setIdleTime(IdleStatus,int)}.
  * 
  * @author Trustin Lee (trustin@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;

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/SessionConfig.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/SessionConfig.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/SessionConfig.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/SessionConfig.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/SessionConfig.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/common/SessionConfig.java	Sun Dec 26 23:29:48 2004
@@ -18,23 +18,56 @@
  */
 package org.apache.mina.common;
 
+import org.apache.mina.io.WriteTimeoutException;
+import org.apache.mina.io.datagram.DatagramSessionConfig;
+import org.apache.mina.io.socket.SocketSessionConfig;
+
 /**
- * TODO Insert type comment.
+ * Provides general or transport-specific configuration.
+ * <p>
+ * <ul>
+ *   <li><code>idleTime</code> (secs) - <code>sessionIdle</code> event is
+ *       enabled if this value is greater than 0.
+ *   <li><code>writeTimeout</code> (secs) - {@link WriteTimeoutException} is
+ *       thrown when the write buffer of session is full for the specified
+ *       time.</li>
+ * </ul>
+ * <p>
+ * Please refer to {@link SocketSessionConfig} and {@link DatagramSessionConfig}
+ * for transport-specific configurations.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
  */
 public interface SessionConfig
 {
+    /**
+     * Returns idle time for the specified type of idleness in seconds.
+     */
     int getIdleTime( IdleStatus status );
 
+    /**
+     * Returnd 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 );
 }

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Acceptor.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Acceptor.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Acceptor.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Acceptor.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Acceptor.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Acceptor.java	Sun Dec 26 23:29:48 2004
@@ -21,24 +21,65 @@
 import java.io.IOException;
 import java.net.SocketAddress;
 
+import org.apache.mina.util.DefaultExceptionMonitor;
+
 /**
- * TODO Insert type comment.
+ * Accepts incoming connection, communicates with clients, and fires events to
+ * {@link IoHandler}s.
+ * <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 accepts incoming connections start automatically when
+ * {@link #bind(SocketAddress, IoHandler)} is invoked, and stop when all
+ * addresses are unbound.
+ * <p>
+ * {@link IoHandlerFilter}s can be added and removed at any time to filter
+ * events just like Servlet filters and they are effective immediately.
+ * <p>
+ * You can monitor any uncaught exceptions by setting {@link ExceptionMonitor}
+ * by calling {@link #setExceptionMonitor(ExceptionMonitor)}.  The default
+ * monitor is {@link DefaultExceptionMonitor}.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
  */
 public interface Acceptor
 {
+    /**
+     * Binds to the specified <code>address</code> and handles incoming
+     * connections with the specified <code>defaultHandler</code>.
+     * 
+     * @throws IOException if failed to bind
+     */
     void bind( SocketAddress address, IoHandler defaultHandler )
             throws IOException;
 
+    /**
+     * Unbinds from the specified <code>address</code>.
+     */
     void unbind( SocketAddress address );
 
+    /**
+     * Adds the specified filter with the specified priority.  Greater priority
+     * value, higher priority, and thus evaluated more earlier.
+     */
     void addFilter( int priority, IoHandlerFilter filter );
 
+    /**
+     * Removes the specified filter from the filter list.
+     */
     void removeFilter( IoHandlerFilter filter );
 
+    /**
+     * 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.
+     */
     void setExceptionMonitor( ExceptionMonitor monitor );
 }

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/Connector.java	Sun Dec 26 23:29:48 2004
@@ -21,25 +21,71 @@
 import java.io.IOException;
 import java.net.SocketAddress;
 
+import org.apache.mina.util.DefaultExceptionMonitor;
+
 /**
- * TODO Insert type comment.
+ * Connects to endpoint, communicates with the server, and fires events to
+ * {@link IoHandler}s.
+ * <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 connects to endpoint start automatically when
+ * {@link #connect(SocketAddress, IoHandler)} is invoked, and stop when all
+ * connection attempts are finished.
+ * <p>
+ * {@link IoHandlerFilter}s can be added and removed at any time to filter
+ * events just like Servlet filters and they are effective immediately.
+ * <p>
+ * You can monitor any uncaught exceptions by setting {@link ExceptionMonitor}
+ * by calling {@link #setExceptionMonitor(ExceptionMonitor)}.  The default
+ * monitor is {@link DefaultExceptionMonitor}.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
  */
 public interface Connector
 {
+    /**
+     * Connects to the specified <code>address</code>.  If communication starts
+     * successfully, use the specified <code>defaultHandler</code>.  This method
+     * blocks.
+     * 
+     * @throws IOException if failed to connect
+     */
     IoSession connect( SocketAddress address, IoHandler defaultHandler )
             throws IOException;
 
+    /**
+     * Connects to the specified <code>address</code> with timeout.  If
+     * communication starts successfully, use the specified
+     * <code>defaultHandler</code>.  This method blocks.
+     * 
+     * @throws IOException if failed to connect
+     */
     IoSession connect( SocketAddress address, int timeout,
                       IoHandler defaultHandler ) throws IOException;
 
+    /**
+     * Adds the specified filter with the specified priority.  Greater priority
+     * value, higher priority, and thus evaluated more earlier.
+     */
     void addFilter( int priority, IoHandlerFilter filter );
 
+    /**
+     * Removes the specified filter from the filter list.
+     */
     void removeFilter( IoHandlerFilter filter );
 
+    /**
+     * 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.
+     */
     void setExceptionMonitor( ExceptionMonitor monitor );
 }

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/ExceptionMonitor.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/ExceptionMonitor.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/ExceptionMonitor.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/ExceptionMonitor.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/ExceptionMonitor.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/ExceptionMonitor.java	Sun Dec 26 23:29:48 2004
@@ -19,12 +19,16 @@
 package org.apache.mina.io;
 
 /**
- * TODO Document me.
+ * Monitors uncaught exceptions.  {@link #exceptionCaught(Object, Throwable)} is
+ * invoked when there are any uncaught exceptions.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
  */
 public interface ExceptionMonitor
 {
+    /**
+     * Invoked when there are any uncaught exceptions.
+     */
     void exceptionCaught( Object source, Throwable cause );
 }

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandler.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandler.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandler.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandler.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandler.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandler.java	Sun Dec 26 23:29:48 2004
@@ -18,26 +18,59 @@
  */
 package org.apache.mina.io;
 
+import java.io.IOException;
+
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IdleStatus;
 
 /**
- * TODO Insert type comment.
+ * Handles all I/O events fired by {@link Acceptor} and {@link Connector}.
+ * There are 6 event handler methods, and they are all invoked by MINA
+ * automatically.  Most users of MINA I/O package will be OK with this single
+ * interface to implement their protocols.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
  */
 public interface IoHandler
 {
+    /**
+     * Invoked when the connection is opened.  This method is not invoked if the
+     * transport type is UDP.
+     */
     void sessionOpened( IoSession session );
 
+    /**
+     * Invoked when the connection is closed.  This method is not invoked if the
+     * transport type is UDP.
+     */
     void sessionClosed( IoSession session );
 
+    /**
+     * 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 );
 
+    /**
+     * 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 );
 
+    /**
+     * Invoked when data is read from the connection.  You can access
+     * <code>buf</code> to get read data.  <code>buf</code> returns to
+     * the internal buffer pool of MINA after this method is invoked, so
+     * please don't try to reuse it.
+     */
     void dataRead( IoSession session, ByteBuffer buf );
 
+    /**
+     * Invoked when MINA wrote {@link IoSession#write(ByteBuffer, Object)}
+     * request successfully.  <code>marker</code> is what you specified at the
+     * point of invocation of {@link IoSession#write(ByteBuffer, Object)}.
+     */
     void dataWritten( IoSession session, Object marker );
 }

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerAdapter.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerAdapter.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerAdapter.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerAdapter.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerAdapter.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerAdapter.java	Sun Dec 26 23:29:48 2004
@@ -20,9 +20,13 @@
 
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IdleStatus;
+import org.apache.mina.examples.netcat.NetCatProtocolHandler;
 
 /**
- * TODO Document me.
+ * 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.  Please refer to {@link NetCatProtocolHandler} for
+ * example. 
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerFilter.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerFilter.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerFilter.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerFilter.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerFilter.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerFilter.java	Sun Dec 26 23:29:48 2004
@@ -20,26 +20,46 @@
 
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IdleStatus;
+import org.apache.mina.io.filter.BlacklistFilter;
 
 /**
- * TODO Insert type comment.
+ * A filter which intercepts {@link IoHandler} events like Servlet filters.
+ * Please refer to {@link BlacklistFilter} for example.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
  */
 public interface IoHandlerFilter
 {
+    /**
+     * Filters {@link IoHandler#sessionOpened(IoSession)} event.
+     */
     void sessionOpened( IoHandler nextHandler, IoSession session );
 
+    /**
+     * Filters {@link IoHandler#sessionClosed(IoSession)} event.
+     */
     void sessionClosed( IoHandler nextHandler, IoSession session );
 
+    /**
+     * Filters {@link IoHandler#sessionIdle(IoSession, IdleStatus)} event.
+     */
     void sessionIdle( IoHandler nextHandler, IoSession session,
                      IdleStatus status );
 
+    /**
+     * Filters {@link IoHandler#exceptionCaught(IoSession, Throwable)} event.
+     */
     void exceptionCaught( IoHandler nextHandler, IoSession session,
                          Throwable cause );
 
+    /**
+     * Filters {@link IoHandler#dataRead(IoSession, ByteBuffer)} event.
+     */
     void dataRead( IoHandler nextHandler, IoSession session, ByteBuffer buf );
 
+    /**
+     * Filters {@link IoHandler#dataWritten(IoSession, Object)} event.
+     */
     void dataWritten( IoHandler nextHandler, IoSession session, Object marker );
 }

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerFilterAdapter.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerFilterAdapter.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerFilterAdapter.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerFilterAdapter.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerFilterAdapter.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoHandlerFilterAdapter.java	Sun Dec 26 23:29:48 2004
@@ -20,9 +20,13 @@
 
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IdleStatus;
+import org.apache.mina.io.filter.BlacklistFilter;
 
 /**
- * TODO Document me.
+ * An abstract adapter class for {@link IoHandlerFilter}.  You can extend this
+ * class and selectively override required event filter methods only.  All
+ * methods forwards events to the next filter by default.  Please refer to
+ * {@link BlacklistFilter} for example.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoSession.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoSession.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoSession.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoSession.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoSession.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/IoSession.java	Sun Dec 26 23:29:48 2004
@@ -25,42 +25,102 @@
 import org.apache.mina.common.SessionConfig;
 
 /**
- * TODO Insert type comment.
- * 
+ * A handle which represents connection between two endpoints regardless of 
+ * transport types (UDP/IP and TCP/IP).
+ * <p>
+ * Session provides an attachment per session ({@link #getAttachment()} and
+ * {@link #setAttachment(Object)}).  Attachment is an application-specific data
+ * which is associated with a session.  It is often an object that represents
+ * the state of a higher-level protocol.
+ *   
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
  */
 public interface IoSession
 {
+    /**
+     * Returns the event handler for this session.
+     */
     IoHandler getHandler();
 
+    /**
+     * Closes this session immediately.
+     */
     void close();
 
+    /**
+     * Writes the content of the specified <code>buf</code>.
+     * This operation is asynchronous, and you'll get notified by
+     * {@link IoHandler#dataWritten(IoSession, Object)} event.
+     * The specified <code>marker</code> will be passes as a parameter.
+     */
     void write( ByteBuffer buf, Object marker );
 
+    /**
+     * Returns an attachment of this session.
+     */
     Object getAttachment();
 
+    /**
+     * Sets an attachment of this session.
+     */
     void setAttachment( Object attachment );
-    
+
+    /**
+     * Returns <code>true</code> if this session is stateless.  This method
+     * returns the transport type is UDP/IP currently.
+     */
     boolean isStateless();
 
+    /**
+     * Returns <code>true</code> if this session is connected.
+     */
     boolean isConnected();
 
+    /**
+     * Returns the configuration of this session.
+     */
     SessionConfig getConfig();
 
+    /**
+     * 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 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 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 );
 }

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/WriteTimeoutException.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/WriteTimeoutException.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/WriteTimeoutException.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/WriteTimeoutException.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/WriteTimeoutException.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/WriteTimeoutException.java	Sun Dec 26 23:29:48 2004
@@ -20,20 +20,30 @@
 
 import java.io.IOException;
 
+import org.apache.mina.common.SessionConfig;
+
 /**
- * TODO Document me.
+ * An {@link IOException} which is thrown when write buffer is not flushed for
+ * {@link SessionConfig#getWriteTimeout()} seconds.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$, 
  */
-public class WriteTimeoutException extends IOException {
-
-	public WriteTimeoutException() {
-		super();
-	}
-
-	public WriteTimeoutException(String s) {
-		super(s);
-	}
+public class WriteTimeoutException extends IOException
+{
+    /**
+     * Creates a new exception.
+     */
+    public WriteTimeoutException()
+    {
+        super();
+    }
 
-}
+    /**
+     * Creates a new exception.
+     */
+    public WriteTimeoutException( String s )
+    {
+        super( s );
+    }
+}
\ No newline at end of file

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java	Sun Dec 26 23:29:48 2004
@@ -40,7 +40,7 @@
 import org.apache.mina.util.Queue;
 
 /**
- * TODO Insert type comment.
+ * {@link Acceptor} for datagram transport (UDP/IP).
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
@@ -144,7 +144,7 @@
         scheduleFlush( session );
         selector.wakeup();
     }
-    
+
     public void closeSession( DatagramSession session )
     {
     }
@@ -227,7 +227,7 @@
                                                            ch,
                                                            ( IoHandler ) key
                                                                    .attachment() );
-            session.setSelectionKey(key);
+            session.setSelectionKey( key );
 
             if( key.isReadable() )
             {
@@ -253,9 +253,9 @@
             {
                 readBuf.flip();
                 session.setRemoteAddress( remoteAddress );
-                
-                ByteBuffer newBuf = ByteBuffer.allocate(readBuf.limit());
-                newBuf.put(readBuf);
+
+                ByteBuffer newBuf = ByteBuffer.allocate( readBuf.limit() );
+                newBuf.put( readBuf );
                 newBuf.flip();
 
                 filterManager.fireDataRead( session, newBuf );
@@ -266,9 +266,9 @@
             filterManager.fireExceptionCaught( session, e );
         }
         finally
-		{
-            ByteBuffer.release(readBuf);
-		}
+        {
+            ByteBuffer.release( readBuf );
+        }
     }
 
     private void flushSessions()
@@ -327,7 +327,7 @@
                     writeBufferQueue.pop();
                     writeMarkerQueue.pop();
                 }
-                
+
                 ByteBuffer.release( buf );
                 session.getFilterManager().fireDataWritten( session, marker );
                 continue;

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramConnector.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramConnector.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramConnector.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramConnector.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramConnector.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramConnector.java	Sun Dec 26 23:29:48 2004
@@ -39,7 +39,7 @@
 import org.apache.mina.util.Queue;
 
 /**
- * TODO Insert type comment.
+ * {@link Connector} for datagram transport (UDP/IP).
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
@@ -245,8 +245,8 @@
             if( readBytes > 0 )
             {
                 readBuf.flip();
-                ByteBuffer newBuf = ByteBuffer.allocate(readBuf.limit());
-                newBuf.put(readBuf);
+                ByteBuffer newBuf = ByteBuffer.allocate( readBuf.limit() );
+                newBuf.put( readBuf );
                 newBuf.flip();
 
                 filterManager.fireDataRead( session, newBuf );
@@ -257,9 +257,9 @@
             filterManager.fireExceptionCaught( session, e );
         }
         finally
-		{
-        	ByteBuffer.release( readBuf );
-		}
+        {
+            ByteBuffer.release( readBuf );
+        }
     }
 
     private void flushSessions()

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramProcessor.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramProcessor.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramProcessor.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramProcessor.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramProcessor.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramProcessor.java	Sun Dec 26 23:29:48 2004
@@ -19,14 +19,21 @@
 package org.apache.mina.io.datagram;
 
 /**
- * TODO Document me.
+ * A base interface for {@link DatagramAcceptor and DatagramConnector}.
+ * Session interacts with this interface instead of those two concrete classes.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
  */
-public interface DatagramProcessor
+interface DatagramProcessor
 {
+    /**
+     * This method is invoked by MINA internally, so please don't call this.
+     */
     void flushSession( DatagramSession session );
-    
+
+    /**
+     * This method is invoked by MINA internally, so please don't call this.
+     */
     void closeSession( DatagramSession session );
 }

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramSession.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramSession.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramSession.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramSession.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramSession.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramSession.java	Sun Dec 26 23:29:48 2004
@@ -151,10 +151,10 @@
 
         parent.flushSession( this );
     }
-    
+
     public boolean isStateless()
     {
-    	return true;
+        return true;
     }
 
     public boolean isConnected()

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramSessionConfig.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramSessionConfig.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramSessionConfig.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramSessionConfig.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramSessionConfig.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/datagram/DatagramSessionConfig.java	Sun Dec 26 23:29:48 2004
@@ -21,10 +21,11 @@
 import java.net.SocketException;
 import java.nio.channels.DatagramChannel;
 
+import org.apache.mina.common.SessionConfig;
 import org.apache.mina.util.BasicSessionConfig;
 
 /**
- * TODO Document me.
+ * A {@link SessionConfig} for datagram transport (UDP/IP).
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$,

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/BlacklistFilter.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/BlacklistFilter.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/BlacklistFilter.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/BlacklistFilter.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/BlacklistFilter.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/BlacklistFilter.java	Sun Dec 26 23:29:48 2004
@@ -26,11 +26,13 @@
 
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.io.IoHandler;
+import org.apache.mina.io.IoHandlerFilter;
 import org.apache.mina.io.IoHandlerFilterAdapter;
 import org.apache.mina.io.IoSession;
 
 /**
- * TODO Document me.
+ * A {@link IoHandlerFilter} which blocks connections from blacklisted remote
+ * address.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
@@ -39,34 +41,45 @@
 {
     private final Set blacklist = new HashSet();
 
-    public void block( InetAddress address )
+    /**
+     * Blocks the specified endpoint.
+     */
+    public synchronized void block( InetAddress address )
     {
         blacklist.add( address );
     }
 
-    public void unblock( InetAddress address )
+    /**
+     * Unblocks the specified endpoint.
+     */
+    public synchronized void unblock( InetAddress address )
     {
         blacklist.remove( address );
     }
 
+    /**
+     * Forwards event if and if only the remote address of session is not
+     * blacklisted.
+     */
     public void dataRead( IoHandler nextHandler, IoSession session,
                          ByteBuffer buf )
     {
-        if( isBlocked( session ) )
-        {
-            // just ignore all
-        }
-        else
+        if( !isBlocked( session ) )
         {
-            // or forward
+            // forward if not blocked
             super.dataRead( nextHandler, session, buf );
         }
     }
 
+    /**
+     * Close connection immediately if the remote address of session is
+     * blacklisted.
+     */
     public void sessionOpened( IoHandler nextHandler, IoSession session )
     {
         if( isBlocked( session ) )
         {
+            // Close immediately if blocked
             session.close();
         }
         else

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/filter/IoThreadPoolFilter.java	Sun Dec 26 23:29:48 2004
@@ -34,17 +34,24 @@
 import org.apache.mina.util.Stack;
 
 /**
- * TODO Document me.
- * 
- * A Leader/Followers thread pool.
+ * A Thread-pooling filter.  This filter forwards {@link IoHandler} events 
+ * to its thread pool.  This is an implementation of
+ * <a href="http://deuce.doc.wustl.edu/doc/pspdfs/lf.pdf">Leader/Followers
+ * thread pool</a> by Douglas C. Schmidt et al.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
  */
 public class IoThreadPoolFilter implements IoHandlerFilter
 {
+    /**
+     * Default maximum size of thread pool (2G).
+     */
     public static final int DEFAULT_MAXIMUM_POOL_SIZE = Integer.MAX_VALUE;
 
+    /**
+     * Default keep-alive time of thread pool (1 min).
+     */
     public static final int DEFAULT_KEEP_ALIVE_TIME = 60 * 1000;
 
     private static volatile int threadId = 0;
@@ -71,25 +78,42 @@
 
     private final Object poolSizeLock = new Object();
 
+    /**
+     * Creates a new instanceof this filter with default thread pool settings.
+     * You'll have to invoke {@link #start()} method to start threads actually.
+     */
     public IoThreadPoolFilter()
     {
     }
 
+    /**
+     * Returns the number of threads in the thread pool.
+     */
     public synchronized int getPoolSize()
     {
         return poolSize;
     }
 
+    /**
+     * Returns the maximum size of the thread pool.
+     */
     public int getMaximumPoolSize()
     {
         return maximumPoolSize;
     }
 
+    /**
+     * Returns the keep-alive time until the thread suicides after it became
+     * idle (milliseconds unit).
+     */
     public int getKeepAliveTime()
     {
         return keepAliveTime;
     }
 
+    /**
+     * Sets the maximum size of the thread pool.
+     */
     public void setMaximumPoolSize( int maximumPoolSize )
     {
         if( maximumPoolSize <= 0 )
@@ -97,11 +121,18 @@
         this.maximumPoolSize = maximumPoolSize;
     }
 
+    /**
+     * Sets the keep-alive time until the thread suicides after it became idle
+     * (milliseconds unit).
+     */
     public void setKeepAliveTime( int keepAliveTime )
     {
         this.keepAliveTime = keepAliveTime;
     }
 
+    /**
+     * Starts thread pool threads and starts forwarding events to them.
+     */
     public synchronized void start()
     {
         if( started )
@@ -116,6 +147,9 @@
         started = true;
     }
 
+    /**
+     * Stops all thread pool threads.
+     */
     public synchronized void stop()
     {
         if( !started )
@@ -387,7 +421,7 @@
         {
             if( type == EventType.READ )
             {
-                nextHandler.dataRead( session, (ByteBuffer) data );
+                nextHandler.dataRead( session, ( ByteBuffer ) data );
             }
             else if( type == EventType.WRITTEN )
             {

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketAcceptor.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketAcceptor.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketAcceptor.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketAcceptor.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketAcceptor.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketAcceptor.java	Sun Dec 26 23:29:48 2004
@@ -39,7 +39,7 @@
 import org.apache.mina.util.Queue;
 
 /**
- * TODO Insert type comment.
+ * {@link Acceptor} for socket transport (TCP/IP).
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
@@ -80,6 +80,13 @@
         this.bind( address, 50, defaultHandler );
     }
 
+    /**
+     * Binds to the specified <code>address</code> and handles incoming
+     * connections with the specified <code>defaultHandler</code>.
+     *
+     * @param backlog the listen backlog length 
+     * @throws IOException if failed to bind
+     */
     public void bind( SocketAddress address, int backlog,
                      IoHandler defaultHandler ) throws IOException
     {

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketConnector.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketConnector.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketConnector.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketConnector.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketConnector.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketConnector.java	Sun Dec 26 23:29:48 2004
@@ -37,7 +37,7 @@
 import org.apache.mina.util.IoHandlerFilterManager;
 
 /**
- * TODO Insert type comment.
+ * {@link Connector} for socket transport (TCP/IP).
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketIoProcessor.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketIoProcessor.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketIoProcessor.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketIoProcessor.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketIoProcessor.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketIoProcessor.java	Sun Dec 26 23:29:48 2004
@@ -254,9 +254,9 @@
             {
                 if( readBytes > 0 )
                 {
-                	ByteBuffer newBuf = ByteBuffer.allocate( readBytes );
-                	newBuf.put(buf);
-                	newBuf.flip();
+                    ByteBuffer newBuf = ByteBuffer.allocate( readBytes );
+                    newBuf.put( buf );
+                    newBuf.flip();
                     session.getFilterManager().fireDataRead( session, newBuf );
                 }
             }
@@ -326,7 +326,7 @@
                             IdleStatus.WRITER_IDLE, session.getLastWriteTime() );
 
         notifyWriteTimeoutSession( session, currentTime, config
-        		.getWriteTimeoutInMillis(), session.getLastWriteTime());
+                .getWriteTimeoutInMillis(), session.getLastWriteTime() );
     }
 
     private void notifyIdleSession0( SocketSession session, long currentTime,
@@ -337,18 +337,22 @@
             && ( currentTime - lastIoTime ) >= idleTime )
         {
             session.setIdle( status );
-           	session.getFilterManager().fireSessionIdle( session, status );
+            session.getFilterManager().fireSessionIdle( session, status );
         }
     }
-    
-    private void notifyWriteTimeoutSession( SocketSession session, long currentTime, long writeTimeout, long lastIoTime )
+
+    private void notifyWriteTimeoutSession( SocketSession session,
+                                           long currentTime,
+                                           long writeTimeout, long lastIoTime )
     {
-        if ( writeTimeout > 0 && ( currentTime - lastIoTime ) >= writeTimeout &&
-             (session.getSelectionKey().interestOps() & SelectionKey.OP_WRITE) != 0)
-       	{
-       		session.getFilterManager().fireExceptionCaught( session,
-       				                                        new WriteTimeoutException());
-       	}
+        if( writeTimeout > 0
+            && ( currentTime - lastIoTime ) >= writeTimeout
+            && ( session.getSelectionKey().interestOps() & SelectionKey.OP_WRITE ) != 0 )
+        {
+            session
+                    .getFilterManager()
+                    .fireExceptionCaught( session, new WriteTimeoutException() );
+        }
     }
 
     private void flushSessions()

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketSession.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketSession.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketSession.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketSession.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketSession.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketSession.java	Sun Dec 26 23:29:48 2004
@@ -83,7 +83,8 @@
         this.filterManager = filterManager;
         this.ch = ch;
         this.config = new SocketSessionConfig( ch );
-        this.readBuf = ByteBuffer.allocate( ByteBuffer.MAXIMUM_CAPACITY ).limit( 0 );
+        this.readBuf = ByteBuffer.allocate( ByteBuffer.MAXIMUM_CAPACITY )
+                .limit( 0 );
         this.writeBufferQueue = new Queue();
         this.writeMarkerQueue = new Queue();
         this.handler = defaultHandler;
@@ -161,10 +162,10 @@
 
         SocketIoProcessor.getInstance().flushSession( this );
     }
-    
+
     public boolean isStateless()
     {
-    	return false;
+        return false;
     }
 
     public boolean isConnected()

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketSessionConfig.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketSessionConfig.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketSessionConfig.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketSessionConfig.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketSessionConfig.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/io/socket/SocketSessionConfig.java	Sun Dec 26 23:29:48 2004
@@ -21,10 +21,11 @@
 import java.net.SocketException;
 import java.nio.channels.SocketChannel;
 
+import org.apache.mina.common.SessionConfig;
 import org.apache.mina.util.BasicSessionConfig;
 
 /**
- * TODO Document me.
+ * A {@link SessionConfig} for socket transport (TCP/IP).
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$,
@@ -97,24 +98,24 @@
     {
         ch.socket().setTrafficClass( tc );
     }
-    
+
     public int getSendBufferSize() throws SocketException
     {
-    	return ch.socket().getSendBufferSize();
+        return ch.socket().getSendBufferSize();
     }
-    
+
     public void setSendBufferSize( int size ) throws SocketException
     {
-    	ch.socket().setSendBufferSize( size );
+        ch.socket().setSendBufferSize( size );
     }
-	
+
     public int getReceiveBufferSize() throws SocketException
     {
-    	return ch.socket().getReceiveBufferSize();
+        return ch.socket().getReceiveBufferSize();
     }
-    
+
     public void setReceiveBufferSize( int size ) throws SocketException
     {
-    	ch.socket().setReceiveBufferSize( size );
+        ch.socket().setReceiveBufferSize( size );
     }
 }

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/IoAdapter.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/IoAdapter.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/IoAdapter.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/IoAdapter.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/IoAdapter.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/IoAdapter.java	Sun Dec 26 23:29:48 2004
@@ -23,37 +23,68 @@
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.common.SessionConfig;
+import org.apache.mina.io.Acceptor;
+import org.apache.mina.io.Connector;
 import org.apache.mina.io.IoHandler;
+import org.apache.mina.io.IoHandlerFilter;
 import org.apache.mina.io.IoSession;
 import org.apache.mina.util.ProtocolHandlerFilterManager;
 import org.apache.mina.util.Queue;
 
 /**
- * TODO Document me.
+ * Adapts the specified {@link ProtocolProvider} to {@link IoHandler}.  This is
+ * a bridge between I/O layer and Protocol layer.  Protocol layer itself cannot
+ * do any real I/O, but it translates I/O events to more higher level ones
+ * and vice versa.  So you need to convert your {@link ProtocolProvider} into
+ * {@link IoHandler} using this class to do I/O:
+ * <pre>
+ * IoAdapter adapter = new IoAdapter();
+ * adapter.addFilter(...); // add your favorite ProtocolHandlerFilter
+ * IoHandler handler = adapter.adapt(new MyProtocolHandler()); // adapt
+ * 
+ * acceptor.bind(new InetSocketAddress(...), handler);
+ * </pre>
+ * <p>
+ * {@link IoAdapter} supports protocol-level filters like {@link Acceptor}s and
+ * {@link Connector}s.  It is the same with {@link IoHandlerFilter} and Servlet
+ * filters and effective immediately.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
  */
 public class IoAdapter
 {
-	public static final Class IO_HANDLER_TYPE = SessionHandlerAdapter.class;
-	
+    public static final Class IO_HANDLER_TYPE = SessionHandlerAdapter.class;
+
     private final ProtocolHandlerFilterManager filterManager = new ProtocolHandlerFilterManager();
 
     public IoAdapter()
     {
     }
 
+    /**
+     * Adds the specified filter with the specified priority.  Greater priority
+     * value, higher priority, and thus evaluated more earlier.
+     */
     public void addFilter( int priority, ProtocolHandlerFilter filter )
     {
         filterManager.addFilter( priority, filter );
     }
 
+    /**
+     * Removes the specified filter from the filter list.
+     */
     public void removeFilter( ProtocolHandlerFilter filter )
     {
         filterManager.removeFilter( filter );
     }
 
+    /**
+     * Converts the specified <code>protocolProvider</code> to {@link IoAdapter}
+     * to use for actual I/O.
+     * 
+     * @return a new I/O handler for the specified <code>protocolProvider</code>
+     */
     public IoHandler adapt( ProtocolProvider protocolProvider )
     {
         return new SessionHandlerAdapter( protocolProvider );
@@ -135,13 +166,15 @@
                 filterManager.fireExceptionCaught( psession, t );
             }
             finally
-			{
-               	ByteBuffer.release( in );
-			}
+            {
+                ByteBuffer.release( in );
+            }
         }
 
         public void dataWritten( IoSession session, Object marker )
         {
+            if( marker == null )
+                return;
             filterManager.fireMessageSent( ( ProtocolSession ) session
                     .getAttachment(), marker );
         }
@@ -167,8 +200,17 @@
                         if( message == null )
                             break;
 
-                        psession.encOut.setMessage( message );
+                        Queue queue = psession.encOut.queue;
                         encoder.encode( psession, message, psession.encOut );
+                        for( ;; )
+                        {
+                            ByteBuffer buf = ( ByteBuffer ) queue.pop();
+                            if( buf == null )
+                                break;
+                            // use marker only if it is the last ByteBuffer
+                            Object marker = queue.isEmpty() ? message : null;
+                            session.write( buf, marker );
+                        }
                     }
                 }
             }
@@ -218,7 +260,7 @@
         {
             this.session = session;
             this.adapter = adapter;
-            this.encOut = new ProtocolEncoderOutputImpl( session );
+            this.encOut = new ProtocolEncoderOutputImpl();
             this.decOut = new ProtocolDecoderOutputImpl();
         }
 
@@ -262,10 +304,10 @@
             adapter.write( session );
             return true;
         }
-        
+
         public boolean isStateless()
         {
-        	return session.isStateless();
+            return session.isStateless();
         }
 
         public boolean isConnected()
@@ -313,23 +355,15 @@
                                                   ProtocolEncoderOutput
     {
 
-        private final IoSession session;
-
-        private Object message;
-
-        private ProtocolEncoderOutputImpl( IoSession session )
-        {
-            this.session = session;
-        }
+        private final Queue queue = new Queue();
 
-        public void setMessage( Object message )
+        private ProtocolEncoderOutputImpl()
         {
-            this.message = message;
         }
 
         public void write( ByteBuffer buf )
         {
-            session.write( buf, message );
+            queue.push( buf );
         }
     }
 

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolCodecFactory.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolCodecFactory.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolCodecFactory.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolCodecFactory.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolCodecFactory.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolCodecFactory.java	Sun Dec 26 23:29:48 2004
@@ -19,14 +19,23 @@
 package org.apache.mina.protocol;
 
 /**
- * TODO Document me.
+ * provides {@link ProtocolEncoder} and {@link ProtocolDecoder} which translates
+ * binary or protocol specific data into message object and vice versa.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
  */
 public interface ProtocolCodecFactory
 {
+    /**
+     * Creates a new instance of {@link ProtocolEncoder} which encodes message
+     * objects into binary or protocol-specific data.
+     */
     ProtocolEncoder newEncoder();
 
+    /**
+     * Creates a new instance of {@link ProtocolDecoder} which decodes binary or
+     * protocol-specific data into message objects.
+     */
     ProtocolDecoder newDecoder();
 }

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolDecoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolDecoder.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolDecoder.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolDecoder.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolDecoder.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolDecoder.java	Sun Dec 26 23:29:48 2004
@@ -21,13 +21,25 @@
 import org.apache.mina.common.ByteBuffer;
 
 /**
- * TODO Insert type comment.
+ * Decodes binary or protocol-specific data into higher-level message objects.
+ * MINA invokes {@link #decode(ProtocolSession, ByteBuffer, ProtocolDecoderOutput)}
+ * method with read data, and then the decoder implementation puts decoded
+ * messages into {@link ProtocolDecoderOutput}.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
  */
 public interface ProtocolDecoder
 {
+    /**
+     * Decodes binary or protocol-specific into higher-level message objects.
+     * MINA invokes {@link #decode(ProtocolSession, ByteBuffer, ProtocolDecoderOutput)}
+     * method with read data, and then the decoder implementation puts decoded
+     * messages into {@link ProtocolDecoderOutput}.
+     * 
+     * @throws ProtocolViolationException if the read data violated protocol
+     *                                    specification 
+     */
     void decode( ProtocolSession session, ByteBuffer in,
                 ProtocolDecoderOutput out ) throws ProtocolViolationException;
 }

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolDecoderOutput.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolDecoderOutput.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolDecoderOutput.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolDecoderOutput.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolDecoderOutput.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolDecoderOutput.java	Sun Dec 26 23:29:48 2004
@@ -26,5 +26,5 @@
  */
 public interface ProtocolDecoderOutput
 {
-    void write(Object message);
-}
+    void write( Object message );
+}
\ No newline at end of file

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolEncoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolEncoder.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolEncoder.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolEncoder.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolEncoder.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolEncoder.java	Sun Dec 26 23:29:48 2004
@@ -18,14 +18,31 @@
  */
 package org.apache.mina.protocol;
 
+import org.apache.mina.common.ByteBuffer;
+
 /**
- * TODO Insert type comment.
+ * Encodes higher-level message objects into binary or protocol-specific data.
+ * MINA invokes {@link #encode(ProtocolSession, Object, ProtocolEncoderOutput)}
+ * method with message which is popped from the session write queue, and then
+ * the encoder implementation puts encoded {@link ByteBuffer}s into
+ * {@link ProtocolEncoderOutput}.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
  */
 public interface ProtocolEncoder
 {
+
+    /**
+     * Encodes higher-level message objects into binary or protocol-specific data.
+     * MINA invokes {@link #encode(ProtocolSession, Object, ProtocolEncoderOutput)}
+     * method with message which is popped from the session write queue, and then
+     * the encoder implementation puts encoded {@link ByteBuffer}s into
+     * {@link ProtocolEncoderOutput}.
+     * 
+     * @throws ProtocolViolationException if the message violated protocol
+     *                                    specification
+     */
     void encode( ProtocolSession session, Object message,
                 ProtocolEncoderOutput out ) throws ProtocolViolationException;
 }

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolProvider.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolProvider.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolProvider.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolProvider.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolProvider.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/ProtocolProvider.java	Sun Dec 26 23:29:48 2004
@@ -18,8 +18,21 @@
  */
 package org.apache.mina.protocol;
 
+import org.apache.mina.io.IoHandler;
+
 /**
- * TODO Document me.
+ * Provides a required information to implement high-level protocols.
+ * It consists of:
+ * <ul>
+ *   <li>{@link ProtocolCodecFactory} - provides {@link ProtocolEncoder} and
+ *       {@link ProtocolDecoder} which translates binary or protocol specific
+ *       data into message object and vice versa.</li>
+ *   <li>{@link ProtocolHandler} - handles high-leve protocol events.</li>
+ * </ul>
+ * <p>
+ * If once you implement {@link ProtocolProvider} for your protocol, you can
+ * adapt it into {@link IoHandler} using {@link IoAdapter} to work with I/O
+ * layer which does actual I/O operations.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/filter/ProtocolThreadPoolFilter.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/filter/ProtocolThreadPoolFilter.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/filter/ProtocolThreadPoolFilter.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/filter/ProtocolThreadPoolFilter.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/filter/ProtocolThreadPoolFilter.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/filter/ProtocolThreadPoolFilter.java	Sun Dec 26 23:29:48 2004
@@ -33,9 +33,13 @@
 import org.apache.mina.util.Stack;
 
 /**
- * TODO Document me.
+ * A Thread-pooling filter.  This filter forwards {@link ProtocolHandler} events
+ * to its thread pool.  This is an implementation of
+ * <a href="http://deuce.doc.wustl.edu/doc/pspdfs/lf.pdf">Leader/Followers
+ * thread pool</a> by Douglas C. Schmidt et al.
  * 
- * A Leader/Followers thread pool.
+ * @author Trustin Lee (trustin@apache.org)
+ * @version $Rev$, $Date$
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/BasicSessionConfig.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/BasicSessionConfig.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/BasicSessionConfig.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/BasicSessionConfig.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/BasicSessionConfig.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/BasicSessionConfig.java	Sun Dec 26 23:29:48 2004
@@ -34,7 +34,7 @@
     private int idleTimeForWrite;
 
     private int idleTimeForBoth;
-    
+
     private int writeTimeout;
 
     protected BasicSessionConfig()
@@ -76,22 +76,22 @@
             throw new IllegalArgumentException( "Unknown idle status: "
                                                 + status );
     }
-    
+
     public int getWriteTimeout()
     {
-    	return writeTimeout;
+        return writeTimeout;
     }
-    
+
     public long getWriteTimeoutInMillis()
     {
-    	return writeTimeout * 1000L;
+        return writeTimeout * 1000L;
     }
-    
+
     public void setWriteTimeout( int writeTimeout )
     {
         if( writeTimeout < 0 )
             throw new IllegalArgumentException( "Illegal write timeout: "
                                                 + writeTimeout );
-    	this.writeTimeout = writeTimeout;
+        this.writeTimeout = writeTimeout;
     }
 }

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/DefaultExceptionMonitor.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/DefaultExceptionMonitor.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/DefaultExceptionMonitor.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/DefaultExceptionMonitor.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/DefaultExceptionMonitor.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/DefaultExceptionMonitor.java	Sun Dec 26 23:29:48 2004
@@ -25,7 +25,10 @@
 import org.apache.mina.io.ExceptionMonitor;
 
 /**
- * TODO Document me.
+ * A default {@link ExceptionMonitor}.  It logs uncaught exceptions using
+ * <a href="http://jakarta.apache.org/commons/logging/">Apache Jakarta Commons
+ * Logging</a> if available.  If not available, it prints it out to
+ * {@link System#err}.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/IoHandlerFilterManager.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/IoHandlerFilterManager.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/IoHandlerFilterManager.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/IoHandlerFilterManager.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/IoHandlerFilterManager.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/IoHandlerFilterManager.java	Sun Dec 26 23:29:48 2004
@@ -61,10 +61,12 @@
         public void dataRead( IoHandler nextHandler, IoSession session,
                              ByteBuffer buf )
         {
-        	IoHandler handler = session.getHandler();
+            IoHandler handler = session.getHandler();
             handler.dataRead( session, buf );
-            if (!IoAdapter.IO_HANDLER_TYPE.isAssignableFrom( handler.getClass() )) {
-            	ByteBuffer.release( buf );
+            if( !IoAdapter.IO_HANDLER_TYPE.isAssignableFrom( handler
+                    .getClass() ) )
+            {
+                ByteBuffer.release( buf );
             }
         }
 

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Queue.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Queue.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Queue.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Queue.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Queue.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Queue.java	Sun Dec 26 23:29:48 2004
@@ -31,9 +31,9 @@
  */
 public class Queue implements Serializable
 {
-	private static final int DEFAULT_CAPACITY = 4;
-	
-	private static final int DEFAULT_MASK = DEFAULT_CAPACITY - 1;
+    private static final int DEFAULT_CAPACITY = 4;
+
+    private static final int DEFAULT_MASK = DEFAULT_CAPACITY - 1;
 
     private Object[] items;
 

Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Stack.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Stack.java?view=diff&rev=123396&p1=incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Stack.java&r1=123395&p2=incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Stack.java&r2=123396
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Stack.java	(original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/util/Stack.java	Sun Dec 26 23:29:48 2004
@@ -31,7 +31,7 @@
  */
 public class Stack implements Serializable
 {
-	private static final int DEFAULT_CAPACITY = 4;
+    private static final int DEFAULT_CAPACITY = 4;
 
     private Object[] items;
 

Mime
View raw message