geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r599081 - /geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/AsyncHttpClient.java
Date Wed, 28 Nov 2007 18:13:18 GMT
Author: jgenender
Date: Wed Nov 28 10:13:17 2007
New Revision: 599081

URL: http://svn.apache.org/viewvc?rev=599081&view=rev
Log:
Clean code

Modified:
    geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/AsyncHttpClient.java

Modified: geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/AsyncHttpClient.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/AsyncHttpClient.java?rev=599081&r1=599080&r2=599081&view=diff
==============================================================================
--- geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/AsyncHttpClient.java (original)
+++ geronimo/sandbox/AsyncHttpClient/src/main/java/org/apache/ahc/AsyncHttpClient.java Wed
Nov 28 10:13:17 2007
@@ -41,28 +41,44 @@
  */
 public class AsyncHttpClient {
 
-    /** The Constant DEFAULT_CONNECTION_TIMEOUT. */
+    /**
+     * The Constant DEFAULT_CONNECTION_TIMEOUT.
+     */
     public static final int DEFAULT_CONNECTION_TIMEOUT = 30000;
-    
-    /** The Constant DEFAULT_SSL_PROTOCOL. */
+
+    /**
+     * The Constant DEFAULT_SSL_PROTOCOL.
+     */
     public static final String DEFAULT_SSL_PROTOCOL = "TLS";
 
-    /** The ssl protocol. */
+    /**
+     * The ssl protocol.
+     */
     private String sslProtocol = DEFAULT_SSL_PROTOCOL;
 
-    /** The connection timeout. */
+    /**
+     * The connection timeout.
+     */
     private int connectionTimeout = DEFAULT_CONNECTION_TIMEOUT;
-    
-    /** The connector. */
+
+    /**
+     * The connector.
+     */
     private SocketConnector connector;
-    
-    /** The thread pool. */
+
+    /**
+     * The thread pool.
+     */
     private final ExecutorService threadPool;
-    
-    /** The HttpIoHandler handler. */
+
+    /**
+     * The HttpIoHandler handler.
+     */
     private HttpIoHandler handler = new HttpIoHandler();
-    
-    /** The ssl filter. */
+
+    /**
+     * The ssl filter.
+     */
     private SSLFilter sslFilter;
 
     /**
@@ -76,7 +92,7 @@
     /**
      * Instantiates a new AsyncHttpClient.  This will take a thread pool (ExecutorService)
to use
      * for processing connections.
-     * 
+     *
      * @param executor the executor
      */
     public AsyncHttpClient(ExecutorService executor) {
@@ -86,7 +102,7 @@
     /**
      * Instantiates a new AsyncHttpClient.  Uses a single thread model by default and allows
you to specify
      * a connection timeout.
-     * 
+     *
      * @param connectionTimeout the connection timeout in milliseconds.
      */
     public AsyncHttpClient(int connectionTimeout) {
@@ -95,9 +111,9 @@
 
     /**
      * Instantiates a new AsyncHttpClient.  Allows you to specify a connection timeout and
an ExecutorService.
-     * 
+     *
      * @param connectionTimeout the connection timeout in milliseconds.
-     * @param executor the ExceutorService to use to process connections.
+     * @param executor          the ExceutorService to use to process connections.
      */
     public AsyncHttpClient(int connectionTimeout, ExecutorService executor) {
         this.connectionTimeout = connectionTimeout;
@@ -118,7 +134,7 @@
 
     /**
      * Sends a request.
-     * 
+     *
      * @param message the <code>HttpRequestMessage</code> to send to the remote
server.
      * @see HttpRequestMessage
      */
@@ -134,7 +150,7 @@
 
     /**
      * Gets the connection timeout.
-     * 
+     *
      * @return the connection timeout in milliseconds
      */
     public int getConnectionTimeout() {
@@ -143,7 +159,7 @@
 
     /**
      * Sets the connection timeout.
-     * 
+     *
      * @param connectionTimeout the new connection timeout in milliseconds
      */
     public void setConnectionTimeout(int connectionTimeout) {
@@ -153,7 +169,7 @@
     }
 
     private void applyConnectionTimeout() {
-        connector.getDefaultConfig().setConnectTimeout(connectionTimeout/1000);
+        connector.getDefaultConfig().setConnectTimeout(connectionTimeout / 1000);
     }
 
     /**
@@ -167,7 +183,7 @@
             threadPool.shutdownNow();
         }
 
-        if (connector != null){
+        if (connector != null) {
             connector.setWorkerTimeout(0);
         }
     }
@@ -180,16 +196,20 @@
      */
     class FutureListener implements IoFutureListener {
 
-        /** The request. */
+        /**
+         * The request.
+         */
         HttpRequestMessage request;
-        
-        /** The client. */
+
+        /**
+         * The client.
+         */
         AsyncHttpClient client;
 
         /**
          * Instantiates a new future listener for a connection.
-         * 
-         * @param client the <code>AsyncHttpClient</code> client object
+         *
+         * @param client  the <code>AsyncHttpClient</code> client object
          * @param request the <code>HttpRequestMessage</code> request that is
to be sent.
          */
         public FutureListener(AsyncHttpClient client, HttpRequestMessage request) {
@@ -200,7 +220,7 @@
         /**
          * Event notification that the conection has completed, either by a successful connection
or
          * by an error.
-         * 
+         *
          * @param future the {@link org.apache.mina.common.IoFuture} representing the <code>ConnectFuture</code>.
          * @see org.apache.mina.common.IoFutureListener#operationComplete(org.apache.mina.common.IoFuture)
          */
@@ -227,20 +247,19 @@
                     sess.getFilterChain().addLast("SSL", sslFilter);
                 }
 
-                sess.getFilterChain()
-                        .addLast("protocolFilter", new ProtocolCodecFilter(
-                                new HttpProtocolCodecFactory()));
+                sess.getFilterChain().addLast("protocolFilter", new ProtocolCodecFilter(
+                        new HttpProtocolCodecFactory()));
 
                 sess.setAttribute(HttpIoHandler.CURRENT_REQUEST, request);
-                
+
                 sess.setAttachment(client);
 
                 sess.write(request);
             } else {
-                try{
+                try {
                     IoSession sess = future.getSession();
                     request.getCallback().onException(new AsyncHttpClientException("Connection
failed."));
-                } catch (RuntimeIOException e){
+                } catch (RuntimeIOException e) {
                     //Set the callback exception
                     request.getCallback().onException(e);
                 }
@@ -249,9 +268,8 @@
 
         /**
          * Creates the client ssl context.
-         * 
+         *
          * @return the SSL context
-         * 
          * @throws GeneralSecurityException the general security exception
          */
         private SSLContext createClientSSLContext() throws GeneralSecurityException {



Mime
View raw message