You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2009/01/24 16:02:37 UTC

svn commit: r737373 - in /httpcomponents/httpcore/trunk: module-main/src/main/java/org/apache/http/impl/ module-nio/src/main/java/org/apache/http/impl/nio/

Author: olegk
Date: Sat Jan 24 15:02:37 2009
New Revision: 737373

URL: http://svn.apache.org/viewvc?rev=737373&view=rev
Log:
Javadoc updates

Modified:
    httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultClientIOEventDispatch.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultServerIOEventDispatch.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/SSLClientIOEventDispatch.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/SSLServerIOEventDispatch.java

Modified: httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java?rev=737373&r1=737372&r2=737373&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java (original)
+++ httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java Sat Jan 24 15:02:37 2009
@@ -136,7 +136,7 @@
      * After this method's execution the connection status will be reported
      * as open and the {@link #isOpen()} will return <code>true</code>.
      * <p>
-     * The following HTTP parameters affect configuration this connection:
+     * The following HTTP parameters affect configuration of this connection:
      * <p>
      * The {@link CoreConnectionPNames#SOCKET_BUFFER_SIZE}
      * parameter determines the size of the internal socket buffer. If not 

Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultClientIOEventDispatch.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultClientIOEventDispatch.java?rev=737373&r1=737372&r2=737373&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultClientIOEventDispatch.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultClientIOEventDispatch.java Sat Jan 24 15:02:37 2009
@@ -31,6 +31,7 @@
 
 package org.apache.http.impl.nio;
 
+import org.apache.http.HttpResponse;
 import org.apache.http.HttpResponseFactory;
 import org.apache.http.impl.DefaultHttpResponseFactory;
 import org.apache.http.nio.NHttpClientIOTarget;
@@ -41,6 +42,14 @@
 import org.apache.http.nio.util.HeapByteBufferAllocator;
 import org.apache.http.params.HttpParams;
 
+/**
+ * Default implementation of {@link IOEventDispatch} interface for plain 
+ * (unencrypted) client-side HTTP connections.
+ * 
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ */
 public class DefaultClientIOEventDispatch implements IOEventDispatch {
 
     private static final String NHTTP_CONN = "NHTTP_CONN";
@@ -49,6 +58,13 @@
     protected final NHttpClientHandler handler;
     protected final HttpParams params;
 
+    /**
+     * Creates a new instance of this class to be used for dispatching I/O event 
+     * notifications to the given protocol handler.
+     * 
+     * @param handler the client protocol handler.
+     * @param params HTTP parameters.
+     */
     public DefaultClientIOEventDispatch(
             final NHttpClientHandler handler, 
             final HttpParams params) {
@@ -64,14 +80,43 @@
         this.params = params;
     }
     
+    /**
+     * Creates an instance of {@link HeapByteBufferAllocator} to be used 
+     * by HTTP connections for allocating {@link ByteBuffer} objects.
+     * <p>
+     * This method can be overridden in super class in order to provide 
+     * a different implementation of the {@link ByteBufferAllocator} interface. 
+     * 
+     * @return byte buffer allocator.
+     */
     protected ByteBufferAllocator createByteBufferAllocator() {
         return new HeapByteBufferAllocator(); 
     }
         
+    /**
+     * Creates an instance of {@link DefaultHttpResponseFactory} to be used 
+     * by HTTP connections for creating {@link HttpResponse} objects.
+     * <p>
+     * This method can be overridden in super class in order to provide 
+     * a different implementation of the {@link HttpResponseFactory} interface. 
+     * 
+     * @return HTTP response factory.
+     */
     protected HttpResponseFactory createHttpResponseFactory() {
         return new DefaultHttpResponseFactory();
     }
     
+    /**
+     * Creates an instance of {@link DefaultNHttpClientConnection} based on the
+     * given {@link IOSession}.
+     * <p>
+     * This method can be overridden in super class in order to provide 
+     * a different implementation of the {@link NHttpClientIOTarget} interface. 
+     * 
+     * @param session the underlying I/O session. 
+     * 
+     * @return newly created HTTP connection.
+     */
     protected NHttpClientIOTarget createConnection(final IOSession session) {
         return new DefaultNHttpClientConnection(
                 session, 

Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultServerIOEventDispatch.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultServerIOEventDispatch.java?rev=737373&r1=737372&r2=737373&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultServerIOEventDispatch.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/DefaultServerIOEventDispatch.java Sat Jan 24 15:02:37 2009
@@ -31,6 +31,9 @@
 
 package org.apache.http.impl.nio;
 
+import java.nio.ByteBuffer;
+
+import org.apache.http.HttpRequest;
 import org.apache.http.HttpRequestFactory;
 import org.apache.http.impl.DefaultHttpRequestFactory;
 import org.apache.http.nio.NHttpServerIOTarget;
@@ -41,6 +44,14 @@
 import org.apache.http.nio.util.HeapByteBufferAllocator;
 import org.apache.http.params.HttpParams;
 
+/**
+ * Default implementation of {@link IOEventDispatch} interface for plain 
+ * (unencrypted) server-side HTTP connections.
+ * 
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ */
 public class DefaultServerIOEventDispatch implements IOEventDispatch {
 
     private static final String NHTTP_CONN = "NHTTP_CONN";
@@ -49,7 +60,14 @@
     protected final NHttpServiceHandler handler;
     protected final HttpParams params;
     
-    public DefaultServerIOEventDispatch(
+    /**
+     * Creates a new instance of this class to be used for dispatching I/O event 
+     * notifications to the given protocol handler.
+     * 
+     * @param handler the server protocol handler.
+     * @param params HTTP parameters.
+     */
+     public DefaultServerIOEventDispatch(
             final NHttpServiceHandler handler,
             final HttpParams params) {
         super();
@@ -64,14 +82,43 @@
         this.params = params;
     }
     
+     /**
+      * Creates an instance of {@link HeapByteBufferAllocator} to be used 
+      * by HTTP connections for allocating {@link ByteBuffer} objects.
+      * <p>
+      * This method can be overridden in super class in order to provide 
+      * a different implementation of the {@link ByteBufferAllocator} interface. 
+      * 
+      * @return byte buffer allocator.
+      */
     protected ByteBufferAllocator createByteBufferAllocator() {
         return new HeapByteBufferAllocator(); 
     }
         
+    /**
+     * Creates an instance of {@link DefaultHttpRequestFactory} to be used 
+     * by HTTP connections for creating {@link HttpRequest} objects.
+     * <p>
+     * This method can be overridden in super class in order to provide 
+     * a different implementation of the {@link HttpRequestFactory} interface. 
+     * 
+     * @return HTTP request factory.
+     */
     protected HttpRequestFactory createHttpRequestFactory() {
         return new DefaultHttpRequestFactory(); 
     }
         
+    /**
+     * Creates an instance of {@link DefaultNHttpServerConnection} based on the
+     * given {@link IOSession}.
+     * <p>
+     * This method can be overridden in super class in order to provide 
+     * a different implementation of the {@link NHttpServerIOTarget} interface. 
+     * 
+     * @param session the underlying I/O session. 
+     * 
+     * @return newly created HTTP connection.
+     */
     protected NHttpServerIOTarget createConnection(final IOSession session) {
         return new DefaultNHttpServerConnection(
                 session, 

Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java?rev=737373&r1=737372&r2=737373&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java Sat Jan 24 15:02:37 2009
@@ -66,12 +66,22 @@
 import org.apache.http.nio.reactor.IOSession;
 import org.apache.http.nio.reactor.SessionBufferStatus;
 import org.apache.http.nio.util.ByteBufferAllocator;
+import org.apache.http.params.CoreConnectionPNames;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.SyncBasicHttpContext;
 
+/**
+ * This class serves as a base for all {@link NHttpConnection} implementations
+ * and implements functionality common to both client and server 
+ * HTTP connections.
+ * 
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ */
 public class NHttpConnectionBase 
         implements NHttpConnection, HttpInetConnection, SessionBufferStatus {
 
@@ -97,6 +107,20 @@
 
     protected volatile int status;
     
+    /**
+     * Creates a new instance of this class given the underlying I/O session.
+     * <p>
+     * The following HTTP parameters affect configuration of this connection:
+     * <p>
+     * The {@link CoreConnectionPNames#SOCKET_BUFFER_SIZE}
+     * parameter determines the size of the internal socket buffer. If not 
+     * defined or set to <code>-1</code> the default value will be chosen
+     * automatically.
+     * 
+     * @param session the underlying I/O session.
+     * @param allocator byte buffer allocator.
+     * @param params HTTP parameters.
+     */
     public NHttpConnectionBase(
             final IOSession session,
             final ByteBufferAllocator allocator,
@@ -166,6 +190,15 @@
         this.session.clearEvent(EventMask.WRITE);
     }
 
+    /**
+     * Initializes a specific {@link ContentDecoder} implementation based on the
+     * properties of the given {@link HttpMessage} and generates an instance of
+     * {@link HttpEntity} matching the properties of the content decoder.
+     * 
+     * @param message the HTTP message.
+     * @return HTTP entity.
+     * @throws HttpException in case of an HTTP protocol violation.
+     */
     protected HttpEntity prepareDecoder(final HttpMessage message) throws HttpException {
         BasicHttpEntity entity = new BasicHttpEntity();
         long len = this.incomingContentStrategy.determineLength(message);
@@ -204,6 +237,13 @@
         return entity;
     }
 
+    /**
+     * Initializes a specific {@link ContentEncoder} implementation based on the
+     * properties of the given {@link HttpMessage}.
+     * 
+     * @param message the HTTP message.
+     * @throws HttpException in case of an HTTP protocol violation.
+     */
     protected void prepareEncoder(final HttpMessage message) throws HttpException {
         long len = this.outgoingContentStrategy.determineLength(message);
         if (len == ContentLengthStrategy.CHUNKED) {
@@ -233,7 +273,13 @@
         return this.hasBufferedOutput;
     }
     
-    protected void assertNotClosed() throws IOException {
+    /**
+     * Assets if the connection is still open.
+     * 
+     * @throws ConnectionClosedException in case the connection has already 
+     *   been closed.
+     */
+    protected void assertNotClosed() throws ConnectionClosedException {
         if (this.status != ACTIVE) {
             throw new ConnectionClosedException("Connection is closed");
         }

Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/SSLClientIOEventDispatch.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/SSLClientIOEventDispatch.java?rev=737373&r1=737372&r2=737373&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/SSLClientIOEventDispatch.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/SSLClientIOEventDispatch.java Sat Jan 24 15:02:37 2009
@@ -36,6 +36,7 @@
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLException;
 
+import org.apache.http.HttpResponse;
 import org.apache.http.HttpResponseFactory;
 import org.apache.http.impl.DefaultHttpResponseFactory;
 import org.apache.http.impl.nio.reactor.SSLIOSession;
@@ -49,6 +50,14 @@
 import org.apache.http.nio.util.HeapByteBufferAllocator;
 import org.apache.http.params.HttpParams;
 
+/**
+ * Default implementation of {@link IOEventDispatch} interface for SSL
+ * (encrypted) client-side HTTP connections.
+ * 
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ */
 public class SSLClientIOEventDispatch implements IOEventDispatch {
 
     private static final String NHTTP_CONN = "NHTTP_CONN";
@@ -59,6 +68,17 @@
     protected final SSLIOSessionHandler sslHandler;
     protected final HttpParams params;
     
+    /**
+     * Creates a new instance of this class to be used for dispatching I/O event 
+     * notifications to the given protocol handler using the given 
+     * {@link SSLContext}. This I/O dispatcher will transparently handle SSL 
+     * protocol aspects for HTTP connections.
+     * 
+     * @param handler the client protocol handler.
+     * @param sslcontext the SSL context.
+     * @param sslHandler the SSL handler.
+     * @param params HTTP parameters.
+     */
     public SSLClientIOEventDispatch(
             final NHttpClientHandler handler,
             final SSLContext sslcontext,
@@ -80,6 +100,16 @@
         this.sslHandler = sslHandler;
     }
     
+    /**
+     * Creates a new instance of this class to be used for dispatching I/O event 
+     * notifications to the given protocol handler using the given 
+     * {@link SSLContext}. This I/O dispatcher will transparently handle SSL 
+     * protocol aspects for HTTP connections.
+     * 
+     * @param handler the client protocol handler.
+     * @param sslcontext the SSL context.
+     * @param params HTTP parameters.
+     */
     public SSLClientIOEventDispatch(
             final NHttpClientHandler handler,
             final SSLContext sslcontext,
@@ -87,14 +117,43 @@
         this(handler, sslcontext, null, params);
     }
     
+    /**
+     * Creates an instance of {@link HeapByteBufferAllocator} to be used 
+     * by HTTP connections for allocating {@link ByteBuffer} objects.
+     * <p>
+     * This method can be overridden in super class in order to provide 
+     * a different implementation of the {@link ByteBufferAllocator} interface. 
+     * 
+     * @return byte buffer allocator.
+     */
     protected ByteBufferAllocator createByteBufferAllocator() {
         return new HeapByteBufferAllocator(); 
     }
         
+    /**
+     * Creates an instance of {@link DefaultHttpResponseFactory} to be used 
+     * by HTTP connections for creating {@link HttpResponse} objects.
+     * <p>
+     * This method can be overridden in super class in order to provide 
+     * a different implementation of the {@link HttpResponseFactory} interface. 
+     * 
+     * @return HTTP response factory.
+     */
     protected HttpResponseFactory createHttpResponseFactory() {
         return new DefaultHttpResponseFactory();
     }
     
+    /**
+     * Creates an instance of {@link DefaultNHttpClientConnection} based on the
+     * given SSL {@link IOSession}.
+     * <p>
+     * This method can be overridden in super class in order to provide 
+     * a different implementation of the {@link NHttpClientIOTarget} interface. 
+     * 
+     * @param session the underlying SSL I/O session. 
+     * 
+     * @return newly created HTTP connection.
+     */
     protected NHttpClientIOTarget createConnection(final IOSession session) {
         return new DefaultNHttpClientConnection(
                 session, 
@@ -103,6 +162,18 @@
                 this.params); 
     }
         
+    /**
+     * Creates an instance of {@link SSLIOSession} decorating the given
+     * {@link IOSession}.
+     * <p>
+     * This method can be overridden in super class in order to provide 
+     * a different implementation of SSL I/O session. 
+     * 
+     * @param session the underlying I/O session. 
+     * @param sslcontext the SSL context.
+     * @param sslHandler the SSL handler.
+     * @return newly created SSL I/O session.
+     */
     protected SSLIOSession createSSLIOSession(
             final IOSession session,
             final SSLContext sslcontext,

Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/SSLServerIOEventDispatch.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/SSLServerIOEventDispatch.java?rev=737373&r1=737372&r2=737373&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/SSLServerIOEventDispatch.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/SSLServerIOEventDispatch.java Sat Jan 24 15:02:37 2009
@@ -32,10 +32,12 @@
 package org.apache.http.impl.nio;
 
 import java.io.IOException;
+import java.nio.ByteBuffer;
 
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLException;
 
+import org.apache.http.HttpRequest;
 import org.apache.http.HttpRequestFactory;
 import org.apache.http.impl.DefaultHttpRequestFactory;
 import org.apache.http.impl.nio.reactor.SSLIOSession;
@@ -49,6 +51,14 @@
 import org.apache.http.nio.util.HeapByteBufferAllocator;
 import org.apache.http.params.HttpParams;
 
+/**
+ * Default implementation of {@link IOEventDispatch} interface for SSL
+ * (encrypted) server-side HTTP connections.
+ * 
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ */
 public class SSLServerIOEventDispatch implements IOEventDispatch {
 
     private static final String NHTTP_CONN = "NHTTP_CONN";
@@ -59,6 +69,17 @@
     protected final SSLIOSessionHandler sslHandler;
     protected final HttpParams params;
     
+    /**
+     * Creates a new instance of this class to be used for dispatching I/O event 
+     * notifications to the given protocol handler using the given 
+     * {@link SSLContext}. This I/O dispatcher will transparently handle SSL 
+     * protocol aspects for HTTP connections.
+     * 
+     * @param handler the server protocol handler.
+     * @param sslcontext the SSL context.
+     * @param sslHandler the SSL handler.
+     * @param params HTTP parameters.
+     */
     public SSLServerIOEventDispatch(
             final NHttpServiceHandler handler,
             final SSLContext sslcontext,
@@ -80,6 +101,16 @@
         this.sslHandler = sslHandler;
     }
     
+    /**
+     * Creates a new instance of this class to be used for dispatching I/O event 
+     * notifications to the given protocol handler using the given 
+     * {@link SSLContext}. This I/O dispatcher will transparently handle SSL 
+     * protocol aspects for HTTP connections.
+     * 
+     * @param handler the server protocol handler.
+     * @param sslcontext the SSL context.
+     * @param params HTTP parameters.
+     */
     public SSLServerIOEventDispatch(
             final NHttpServiceHandler handler,
             final SSLContext sslcontext,
@@ -87,14 +118,43 @@
         this(handler, sslcontext, null, params);
     }
     
+    /**
+     * Creates an instance of {@link HeapByteBufferAllocator} to be used 
+     * by HTTP connections for allocating {@link ByteBuffer} objects.
+     * <p>
+     * This method can be overridden in super class in order to provide 
+     * a different implementation of the {@link ByteBufferAllocator} interface. 
+     * 
+     * @return byte buffer allocator.
+     */
     protected ByteBufferAllocator createByteBufferAllocator() {
         return new HeapByteBufferAllocator(); 
     }
         
+    /**
+     * Creates an instance of {@link DefaultHttpRequestFactory} to be used 
+     * by HTTP connections for creating {@link HttpRequest} objects.
+     * <p>
+     * This method can be overridden in super class in order to provide 
+     * a different implementation of the {@link HttpRequestFactory} interface. 
+     * 
+     * @return HTTP request factory.
+     */
     protected HttpRequestFactory createHttpRequestFactory() {
         return new DefaultHttpRequestFactory(); 
     }
         
+    /**
+     * Creates an instance of {@link DefaultNHttpServerConnection} based on the
+     * given {@link IOSession}.
+     * <p>
+     * This method can be overridden in super class in order to provide 
+     * a different implementation of the {@link NHttpServerIOTarget} interface. 
+     * 
+     * @param session the underlying SSL I/O session. 
+     * 
+     * @return newly created HTTP connection.
+     */
     protected NHttpServerIOTarget createConnection(final IOSession session) {
         return new DefaultNHttpServerConnection(
                 session, 
@@ -103,6 +163,18 @@
                 this.params); 
     }
         
+    /**
+     * Creates an instance of {@link SSLIOSession} decorating the given
+     * {@link IOSession}.
+     * <p>
+     * This method can be overridden in super class in order to provide 
+     * a different implementation of SSL I/O session. 
+     * 
+     * @param session the underlying I/O session. 
+     * @param sslcontext the SSL context.
+     * @param sslHandler the SSL handler.
+     * @return newly created SSL I/O session.
+     */
     protected SSLIOSession createSSLIOSession(
             final IOSession session,
             final SSLContext sslcontext,