You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ru...@apache.org on 2009/04/03 04:09:49 UTC

svn commit: r761503 - /synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ClientHandler.java

Author: ruwan
Date: Fri Apr  3 02:09:48 2009
New Revision: 761503

URL: http://svn.apache.org/viewvc?rev=761503&view=rev
Log:
documentaiton and code reformatting to increase the readability

Modified:
    synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ClientHandler.java

Modified: synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ClientHandler.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ClientHandler.java?rev=761503&r1=761502&r2=761503&view=diff
==============================================================================
--- synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ClientHandler.java (original)
+++ synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/ClientHandler.java Fri Apr  3 02:09:48 2009
@@ -95,8 +95,10 @@
     /**
      * Create an instance of this client connection handler using the Axis2 configuration
      * context and Http protocol parameters given
+     * 
      * @param cfgCtx the Axis2 configuration context
      * @param params the Http protocol parameters to adhere to
+     * @param metrics statistics collection metrics
      */
     public ClientHandler(final ConfigurationContext cfgCtx, final HttpParams params,
         final MetricsCollector metrics) {
@@ -125,8 +127,10 @@
     /**
      * Submit a new request over an already established connection, which has been
      * 'kept alive'
+     *
      * @param conn the connection to use to send the request, which has been kept open
      * @param axis2Req the new request
+     * @throws ConnectionClosedException if the connection is closed by the other party
      */
     public void submitRequest(final NHttpClientConnection conn, Axis2HttpRequest axis2Req)
         throws ConnectionClosedException {
@@ -135,6 +139,7 @@
 
     /**
      * Invoked when the destination is connected
+     * 
      * @param conn the connection being processed
      * @param attachment the attachment set previously
      */
@@ -155,8 +160,10 @@
 
     /**
      * Process a new connection over an existing TCP connection or new
-     * @param conn
-     * @param axis2Req
+     * 
+     * @param conn HTTP connection to be processed
+     * @param axis2Req axis2 representation of the message in the connection
+     * @throws ConnectionClosedException if the connection is closed 
      */
     private void processConnection(final NHttpClientConnection conn,
         final Axis2HttpRequest axis2Req) throws ConnectionClosedException {
@@ -206,7 +213,8 @@
 
     /**
      * Handle connection close events
-     * @param conn
+     * 
+     * @param conn HTTP connection to be closed
      */
     public void closed(final NHttpClientConnection conn) {
         ConnectionPool.forget(conn);
@@ -234,6 +242,7 @@
     /**
      * Handle connection timeouts by shutting down the connections. These are established
      * that have reached the SO_TIMEOUT of the socket
+     * 
      * @param conn the connection being processed
      */
     public void timeout(final NHttpClientConnection conn) {
@@ -261,6 +270,7 @@
 
     /**
      * Handle Http protocol violations encountered while reading from underlying channels
+     * 
      * @param conn the connection being processed
      * @param e the exception encountered
      */
@@ -273,6 +283,7 @@
 
     /**
      * Handle IO errors while reading or writing to underlying channels
+     * 
      * @param conn the connection being processed
      * @param e the exception encountered
      */
@@ -289,6 +300,7 @@
 
     /**
      * Include remote host and port information to an error message
+     * 
      * @param message the initial message
      * @param conn the connection encountering the error
      * @return the updated error message
@@ -368,9 +380,11 @@
                 public void run() {
                     MessageReceiver mr = mc.getAxisOperation().getMessageReceiver();
                     try {
-                        AxisFault axisFault = (exceptionToRaise != null ?
-                            new AxisFault(errorMessage, exceptionToRaise) :
-                            new AxisFault(errorMessage));
+                        // This AxisFault is created to create the fault message context
+                        // noinspection ThrowableInstanceNeverThrown
+                        AxisFault axisFault = exceptionToRaise != null ?
+                                new AxisFault(errorMessage, exceptionToRaise) :
+                                new AxisFault(errorMessage);
 
                         MessageContext nioFaultMessageContext =
                             MessageContextBuilder.createFaultMessageContext(mc, axisFault);
@@ -414,6 +428,7 @@
 
     /**
      * Process ready input (i.e. response from remote server)
+     * 
      * @param conn connection being processed
      * @param decoder the content decoder in use
      */
@@ -475,6 +490,7 @@
 
     /**
      * Process ready output (i.e. write request to remote server)
+     * 
      * @param conn the connection being processed
      * @param encoder the encoder in use
      */
@@ -509,6 +525,7 @@
 
     /**
      * Process a response received for the request sent out
+     * 
      * @param conn the connection being processed
      */
     public void responseReceived(final NHttpClientConnection conn) {
@@ -673,14 +690,16 @@
 
     /**
      * Perform processing of the received response though Axis2
-     * @param conn
-     * @param context
-     * @param response
+     *
+     * @param conn HTTP connection to be processed
+     * @param context HTTP context associated with the connection
+     * @param response HTTP response associated with the connection
      */
     private void processResponse(final NHttpClientConnection conn, HttpContext context,
         HttpResponse response) {
 
-        ContentInputBuffer inputBuffer = new SharedInputBuffer(cfg.getBufferSize(), conn, allocator);
+        ContentInputBuffer inputBuffer
+                = new SharedInputBuffer(cfg.getBufferSize(), conn, allocator);
         context.setAttribute(RESPONSE_SINK_BUFFER, inputBuffer);
 
         BasicHttpEntity entity = new BasicHttpEntity();
@@ -700,21 +719,9 @@
         workerPool.execute(task);        
     }
 
-    // ----------- utility methods -----------
-
-    private void handleException(String msg, Exception e, NHttpClientConnection conn) {
-        if (msg.toLowerCase().indexOf("reset") != -1) {
-            log.warn(msg);
-        } else {
-            log.error(msg, e);
-        }
-        if (conn != null) {
-            shutdownConnection(conn);
-        }
-    }
-
     /**
      * Shutdown the connection ignoring any IO errors during the process
+     * 
      * @param conn the connection to be shutdown
      */
     private void shutdownConnection(final NHttpClientConnection conn) {
@@ -735,6 +742,7 @@
 
     /**
      * Return the HttpProcessor for requests
+     *
      * @return the HttpProcessor that processes requests
      */
     private HttpProcessor getHttpProcessor() {
@@ -761,6 +769,19 @@
         } catch (InterruptedException ignore) {}
     }
 
+    // ----------- utility methods -----------
+
+    private void handleException(String msg, Exception e, NHttpClientConnection conn) {
+        if (msg.toLowerCase().indexOf("reset") != -1) {
+            log.warn(msg);
+        } else {
+            log.error(msg, e);
+        }
+        if (conn != null) {
+            shutdownConnection(conn);
+        }
+    }
+
     private MessageContext getMessageContext(final NHttpClientConnection conn) {
         HttpContext context = conn.getContext();
         Axis2HttpRequest axis2Req = (Axis2HttpRequest) context.getAttribute(AXIS2_HTTP_REQUEST);