hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1463727 [1/2] - in /httpcomponents/httpasyncclient/trunk/httpasyncclient/src: examples/org/apache/http/examples/nio/client/ main/java/org/apache/http/impl/nio/client/ main/java/org/apache/http/impl/nio/conn/ main/java/org/apache/http/nio/c...
Date Tue, 02 Apr 2013 20:10:04 GMT
Author: olegk
Date: Tue Apr  2 20:10:03 2013
New Revision: 1463727

URL: http://svn.apache.org/r1463727
Log:
Added HttpAsyncClientBuilder / HttpAsyncClients APIs intended to simplify the process of HttpAsyncClient configuration and customization

Added:
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/CloseableHttpAsyncClient.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultRequestExectionHandlerImpl.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClients.java
      - copied, changed from r1463726, httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/scheme/LayeringStrategy.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalClientExec.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalConnManager.java
      - copied, changed from r1463726, httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/scheme/LayeringStrategy.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalHttpAsyncClient.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalIODispatch.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalState.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MainClientExec.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MinimalClientExec.java   (with props)
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SchemeLayeringStrategy.java
      - copied, changed from r1463726, httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/scheme/LayeringStrategy.java
Modified:
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchange.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeFutureCallback.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeStreaming.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/ZeroCopyHttpExchange.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultHttpAsyncClient.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingAsyncRequestExecutor.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/conn/PoolingNHttpClientConnectionManager.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/HttpAsyncClient.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/util/HttpAsyncClientUtils.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/scheme/LayeringStrategy.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/ssl/SSLLayeringStrategy.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/test/java/org/apache/http/impl/nio/conn/TestPoolingHttpClientAsyncConnectionManager.java

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchange.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchange.java?rev=1463727&r1=1463726&r2=1463727&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchange.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchange.java Tue Apr  2 20:10:03 2013
@@ -30,22 +30,22 @@ import java.util.concurrent.Future;
 
 import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.nio.client.DefaultHttpAsyncClient;
-import org.apache.http.nio.client.HttpAsyncClient;
+import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
+import org.apache.http.impl.nio.client.HttpAsyncClients;
 
 public class AsyncClientHttpExchange {
 
-    public static void main(String[] args) throws Exception {
-        HttpAsyncClient httpclient = new DefaultHttpAsyncClient();
+    public static void main(final String[] args) throws Exception {
+        final CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
         httpclient.start();
         try {
-            HttpGet request = new HttpGet("http://www.apache.org/");
-            Future<HttpResponse> future = httpclient.execute(request, null);
-            HttpResponse response = future.get();
+            final HttpGet request = new HttpGet("http://www.apache.org/");
+            final Future<HttpResponse> future = httpclient.execute(request, null);
+            final HttpResponse response = future.get();
             System.out.println("Response: " + response.getStatusLine());
             System.out.println("Shutting down");
         } finally {
-            httpclient.shutdown();
+            httpclient.close();
         }
         System.out.println("Done");
     }

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeFutureCallback.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeFutureCallback.java?rev=1463727&r1=1463726&r2=1463727&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeFutureCallback.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeFutureCallback.java Tue Apr  2 20:10:03 2013
@@ -29,25 +29,25 @@ package org.apache.http.examples.nio.cli
 import java.util.concurrent.CountDownLatch;
 
 import org.apache.http.HttpResponse;
+import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.concurrent.FutureCallback;
-import org.apache.http.impl.nio.client.DefaultHttpAsyncClient;
-import org.apache.http.nio.client.HttpAsyncClient;
-import org.apache.http.params.CoreConnectionPNames;
+import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
+import org.apache.http.impl.nio.client.HttpAsyncClients;
 
 public class AsyncClientHttpExchangeFutureCallback {
 
-    public static void main(String[] args) throws Exception {
-        HttpAsyncClient httpclient = new DefaultHttpAsyncClient();
-        httpclient.getParams()
-            .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 3000)
-            .setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 3000)
-            .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
-            .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true);
+    public static void main(final String[] args) throws Exception {
+        final RequestConfig requestConfig = RequestConfig.custom()
+            .setSocketTimeout(3000)
+            .setConnectTimeout(3000).build();
+        final CloseableHttpAsyncClient httpclient = HttpAsyncClients.custom()
+            .setDefaultRequestConfig(requestConfig)
+            .build();
 
         httpclient.start();
         try {
-            HttpGet[] requests = new HttpGet[] {
+            final HttpGet[] requests = new HttpGet[] {
                     new HttpGet("http://www.apache.org/"),
                     new HttpGet("https://www.verisign.com/"),
                     new HttpGet("http://www.google.com/")
@@ -76,7 +76,7 @@ public class AsyncClientHttpExchangeFutu
             latch.await();
             System.out.println("Shutting down");
         } finally {
-            httpclient.shutdown();
+            httpclient.close();
         }
         System.out.println("Done");
     }

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeStreaming.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeStreaming.java?rev=1463727&r1=1463726&r2=1463727&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeStreaming.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/AsyncClientHttpExchangeStreaming.java Tue Apr  2 20:10:03 2013
@@ -31,23 +31,23 @@ import java.nio.CharBuffer;
 import java.util.concurrent.Future;
 
 import org.apache.http.HttpResponse;
-import org.apache.http.impl.nio.client.DefaultHttpAsyncClient;
+import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
+import org.apache.http.impl.nio.client.HttpAsyncClients;
 import org.apache.http.nio.IOControl;
-import org.apache.http.nio.client.HttpAsyncClient;
 import org.apache.http.nio.client.methods.AsyncCharConsumer;
 import org.apache.http.nio.client.methods.HttpAsyncMethods;
 import org.apache.http.protocol.HttpContext;
 
 public class AsyncClientHttpExchangeStreaming {
 
-    public static void main(String[] args) throws Exception {
-        HttpAsyncClient httpclient = new DefaultHttpAsyncClient();
+    public static void main(final String[] args) throws Exception {
+        final CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
         httpclient.start();
         try {
-            Future<Boolean> future = httpclient.execute(
+            final Future<Boolean> future = httpclient.execute(
                     HttpAsyncMethods.createGet("http://localhost:8080/"),
                     new MyResponseConsumer(), null);
-            Boolean result = future.get();
+            final Boolean result = future.get();
             if (result != null && result.booleanValue()) {
                 System.out.println("Request successfully executed");
             } else {
@@ -55,7 +55,7 @@ public class AsyncClientHttpExchangeStre
             }
             System.out.println("Shutting down");
         } finally {
-            httpclient.shutdown();
+            httpclient.close();
         }
         System.out.println("Done");
     }

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/ZeroCopyHttpExchange.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/ZeroCopyHttpExchange.java?rev=1463727&r1=1463726&r2=1463727&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/ZeroCopyHttpExchange.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/examples/org/apache/http/examples/nio/client/ZeroCopyHttpExchange.java Tue Apr  2 20:10:03 2013
@@ -33,22 +33,22 @@ import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
 import org.apache.http.client.ClientProtocolException;
 import org.apache.http.entity.ContentType;
-import org.apache.http.impl.nio.client.DefaultHttpAsyncClient;
-import org.apache.http.nio.client.HttpAsyncClient;
+import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
+import org.apache.http.impl.nio.client.HttpAsyncClients;
 import org.apache.http.nio.client.methods.ZeroCopyConsumer;
 import org.apache.http.nio.client.methods.ZeroCopyPost;
 
 public class ZeroCopyHttpExchange {
 
-    public static void main(String[] args) throws Exception {
-        HttpAsyncClient httpclient = new DefaultHttpAsyncClient();
+    public static void main(final String[] args) throws Exception {
+        final CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
         httpclient.start();
         try {
-            File upload = new File(args[0]);
-            File download = new File(args[1]);
-            ZeroCopyPost httpost = new ZeroCopyPost("http://localhost:8080/", upload,
+            final File upload = new File(args[0]);
+            final File download = new File(args[1]);
+            final ZeroCopyPost httpost = new ZeroCopyPost("http://localhost:8080/", upload,
                     ContentType.create("text/plain"));
-            ZeroCopyConsumer<File> consumer = new ZeroCopyConsumer<File>(download) {
+            final ZeroCopyConsumer<File> consumer = new ZeroCopyConsumer<File>(download) {
 
                 @Override
                 protected File process(
@@ -62,12 +62,12 @@ public class ZeroCopyHttpExchange {
                 }
 
             };
-            Future<File> future = httpclient.execute(httpost, consumer, null);
-            File result = future.get();
+            final Future<File> future = httpclient.execute(httpost, consumer, null);
+            final File result = future.get();
             System.out.println("Response file length: " + result.length());
             System.out.println("Shutting down");
         } finally {
-            httpclient.shutdown();
+            httpclient.close();
         }
         System.out.println("Done");
     }

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java?rev=1463727&r1=1463726&r2=1463727&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java Tue Apr  2 20:10:03 2013
@@ -98,9 +98,10 @@ import org.apache.http.protocol.HttpCont
 import org.apache.http.protocol.HttpProcessor;
 import org.apache.http.protocol.ImmutableHttpProcessor;
 
+@Deprecated
 public abstract class AbstractHttpAsyncClient implements HttpAsyncClient {
 
-    private final Log log = LogFactory.getLog(getClass());;
+    private final Log log = LogFactory.getLog(getClass());
     private final ClientAsyncConnectionManager connmgr;
     private final Queue<HttpAsyncRequestExecutionHandler<?>> queue;
 

Added: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/CloseableHttpAsyncClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/CloseableHttpAsyncClient.java?rev=1463727&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/CloseableHttpAsyncClient.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/CloseableHttpAsyncClient.java Tue Apr  2 20:10:03 2013
@@ -0,0 +1,111 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.http.impl.nio.client;
+
+import java.io.Closeable;
+import java.net.URI;
+import java.util.concurrent.Future;
+
+import org.apache.http.HttpHost;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.client.utils.URIUtils;
+import org.apache.http.concurrent.BasicFuture;
+import org.apache.http.concurrent.FutureCallback;
+import org.apache.http.nio.client.HttpAsyncClient;
+import org.apache.http.nio.client.methods.HttpAsyncMethods;
+import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
+import org.apache.http.nio.protocol.HttpAsyncResponseConsumer;
+import org.apache.http.protocol.BasicHttpContext;
+import org.apache.http.protocol.HttpContext;
+
+public abstract class CloseableHttpAsyncClient implements HttpAsyncClient, Closeable {
+
+    public abstract void start();
+
+    public <T> Future<T> execute(
+            final HttpAsyncRequestProducer requestProducer,
+            final HttpAsyncResponseConsumer<T> responseConsumer,
+            final FutureCallback<T> callback) {
+        return execute(requestProducer, responseConsumer, new BasicHttpContext(), callback);
+    }
+
+    public Future<HttpResponse> execute(
+            final HttpHost target, final HttpRequest request, final HttpContext context,
+            final FutureCallback<HttpResponse> callback) {
+        return execute(
+                HttpAsyncMethods.create(target, request),
+                HttpAsyncMethods.createConsumer(),
+                context, callback);
+    }
+
+    public Future<HttpResponse> execute(
+            final HttpHost target, final HttpRequest request,
+            final FutureCallback<HttpResponse> callback) {
+        return execute(target, request, new BasicHttpContext(), callback);
+    }
+
+    public Future<HttpResponse> execute(
+            final HttpUriRequest request,
+            final FutureCallback<HttpResponse> callback) {
+        return execute(request, new BasicHttpContext(), callback);
+    }
+
+    public Future<HttpResponse> execute(
+            final HttpUriRequest request,
+            final HttpContext context,
+            final FutureCallback<HttpResponse> callback) {
+        HttpHost target;
+        try {
+            target = determineTarget(request);
+        } catch (final ClientProtocolException ex) {
+            final BasicFuture<HttpResponse> future = new BasicFuture<HttpResponse>(callback);
+            future.failed(ex);
+            return future;
+        }
+        return execute(target, request, context, callback);
+    }
+
+    private HttpHost determineTarget(final HttpUriRequest request) throws ClientProtocolException {
+        // A null target may be acceptable if there is a default target.
+        // Otherwise, the null target is detected in the director.
+        HttpHost target = null;
+
+        final URI requestURI = request.getURI();
+        if (requestURI.isAbsolute()) {
+            target = URIUtils.extractHost(requestURI);
+            if (target == null) {
+                throw new ClientProtocolException(
+                        "URI does not specify a valid host name: " + requestURI);
+            }
+        }
+        return target;
+    }
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/CloseableHttpAsyncClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/CloseableHttpAsyncClient.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/CloseableHttpAsyncClient.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java?rev=1463727&r1=1463726&r2=1463727&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultAsyncRequestDirector.java Tue Apr  2 20:10:03 2013
@@ -58,7 +58,6 @@ import org.apache.http.client.config.Req
 import org.apache.http.client.methods.AbortableHttpRequest;
 import org.apache.http.client.methods.HttpUriRequest;
 import org.apache.http.client.params.ClientPNames;
-import org.apache.http.client.params.HttpClientParamConfig;
 import org.apache.http.client.params.HttpClientParams;
 import org.apache.http.client.protocol.ClientContext;
 import org.apache.http.client.utils.URIUtils;
@@ -94,6 +93,7 @@ import org.apache.http.protocol.Executio
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpProcessor;
 
+@Deprecated
 class DefaultAsyncRequestDirector<T> implements HttpAsyncRequestExecutionHandler<T> {
 
     private static final AtomicLong COUNTER = new AtomicLong(1);
@@ -232,7 +232,7 @@ class DefaultAsyncRequestDirector<T> imp
             wrapper.setParams(this.params);
             final HttpRoute route = determineRoute(target, wrapper, this.localContext);
             this.mainRequest = new RoutedRequest(wrapper, route);
-            RequestConfig config = ParamConfig.getRequestConfig(params);
+            final RequestConfig config = ParamConfig.getRequestConfig(params);
             this.localContext.setAttribute(ClientContext.REQUEST_CONFIG, config);
             this.requestContentProduced = false;
             requestConnection();

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultHttpAsyncClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultHttpAsyncClient.java?rev=1463727&r1=1463726&r2=1463727&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultHttpAsyncClient.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultHttpAsyncClient.java Tue Apr  2 20:10:03 2013
@@ -50,6 +50,7 @@ import org.apache.http.protocol.RequestT
 import org.apache.http.protocol.RequestUserAgent;
 import org.apache.http.util.VersionInfo;
 
+@Deprecated
 public class DefaultHttpAsyncClient extends AbstractHttpAsyncClient {
 
     public DefaultHttpAsyncClient(final ClientAsyncConnectionManager connmgr) {

Added: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultRequestExectionHandlerImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultRequestExectionHandlerImpl.java?rev=1463727&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultRequestExectionHandlerImpl.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultRequestExectionHandlerImpl.java Tue Apr  2 20:10:03 2013
@@ -0,0 +1,430 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.http.impl.nio.client;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.logging.Log;
+import org.apache.http.ConnectionClosedException;
+import org.apache.http.ConnectionReuseStrategy;
+import org.apache.http.HttpException;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.HttpExecutionAware;
+import org.apache.http.client.protocol.HttpClientContext;
+import org.apache.http.concurrent.Cancellable;
+import org.apache.http.concurrent.FutureCallback;
+import org.apache.http.conn.routing.HttpRoute;
+import org.apache.http.conn.routing.RouteTracker;
+import org.apache.http.nio.ContentDecoder;
+import org.apache.http.nio.ContentEncoder;
+import org.apache.http.nio.IOControl;
+import org.apache.http.nio.NHttpClientConnection;
+import org.apache.http.nio.conn.NHttpClientConnectionManager;
+import org.apache.http.nio.protocol.HttpAsyncRequestExecutionHandler;
+import org.apache.http.nio.protocol.HttpAsyncRequestExecutor;
+import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
+import org.apache.http.nio.protocol.HttpAsyncResponseConsumer;
+import org.apache.http.protocol.ExecutionContext;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpProcessor;
+
+class DefaultRequestExectionHandlerImpl<T>
+    implements HttpAsyncRequestExecutionHandler<T>, InternalConnManager, Cancellable {
+
+    private final Log log;
+
+    private final HttpAsyncRequestProducer requestProducer;
+    private final HttpAsyncResponseConsumer<T> responseConsumer;
+    private final HttpClientContext localContext;
+    private final ResultCallback<T> resultCallback;
+    private final NHttpClientConnectionManager connmgr;
+    private final HttpProcessor httppocessor;
+    private final ConnectionReuseStrategy reuseStrategy;
+    private final InternalClientExec exec;
+    private final InternalState state;
+
+    private volatile boolean closed;
+
+    private volatile NHttpClientConnection managedConn;
+
+    public DefaultRequestExectionHandlerImpl(
+            final Log log,
+            final HttpAsyncRequestProducer requestProducer,
+            final HttpAsyncResponseConsumer<T> responseConsumer,
+            final HttpClientContext localContext,
+            final ResultCallback<T> callback,
+            final NHttpClientConnectionManager connmgr,
+            final HttpProcessor httppocessor,
+            final ConnectionReuseStrategy reuseStrategy,
+            final InternalClientExec exec) {
+        super();
+        this.log = log;
+        this.requestProducer = requestProducer;
+        this.responseConsumer = responseConsumer;
+        this.localContext = localContext;
+        this.resultCallback = callback;
+        this.connmgr = connmgr;
+        this.httppocessor = httppocessor;
+        this.reuseStrategy = reuseStrategy;
+        this.exec = exec;
+        this.state = new InternalState(requestProducer, responseConsumer, localContext);
+    }
+
+    public void close() {
+        if (this.closed) {
+            return;
+        }
+        this.closed = true;
+        abortConnection();
+        try {
+            this.requestProducer.close();
+        } catch (final IOException ex) {
+            this.log.debug("I/O error closing request producer", ex);
+        }
+        try {
+            this.responseConsumer.close();
+        } catch (final IOException ex) {
+            this.log.debug("I/O error closing response consumer", ex);
+        }
+    }
+
+    public synchronized void start() throws HttpException, IOException {
+        final HttpHost target = this.requestProducer.getTarget();
+        final HttpRequest original = this.requestProducer.generateRequest();
+
+        if (original instanceof HttpExecutionAware) {
+            ((HttpExecutionAware) original).setCancellable(this);
+        }
+        this.exec.prepare(this.state, target, original);
+        requestConnection();
+    }
+
+    public HttpHost getTarget() {
+        return this.requestProducer.getTarget();
+    }
+
+    public synchronized HttpRequest generateRequest() throws IOException, HttpException {
+        return this.exec.generateRequest(this.state, this);
+    }
+
+    public synchronized void produceContent(
+            final ContentEncoder encoder, final IOControl ioctrl) throws IOException {
+        this.exec.produceContent(this.state, encoder, ioctrl);
+    }
+
+    public void requestCompleted(final HttpContext context) {
+        this.exec.requestCompleted(this.state);
+    }
+
+    public boolean isRepeatable() {
+        return this.requestProducer.isRepeatable();
+    }
+
+    public void resetRequest() throws IOException {
+        this.requestProducer.resetRequest();
+    }
+
+    public synchronized void responseReceived(
+            final HttpResponse response) throws IOException, HttpException {
+        this.exec.responseReceived(this.state, response);
+    }
+
+    public synchronized void consumeContent(
+            final ContentDecoder decoder, final IOControl ioctrl) throws IOException {
+        this.exec.consumeContent(this.state, decoder, ioctrl);
+    }
+
+    public synchronized void responseCompleted(final HttpContext context) {
+        if (this.resultCallback.isDone()) {
+            return;
+        }
+        try {
+            this.exec.responseCompleted(this.state, this);
+        } catch (final HttpException ex) {
+            failed(ex);
+        }
+        if (this.state.getFinalResponse() != null) {
+            releaseConnection();
+            final T result = this.responseConsumer.getResult();
+            final Exception ex = this.responseConsumer.getException();
+            if (ex == null) {
+                this.resultCallback.completed(result, this);
+            } else {
+                this.resultCallback.failed(ex, this);
+            }
+        } else {
+            if (this.managedConn != null) {
+                if (!this.managedConn.isOpen()) {
+                    reopenConnection();
+                } else {
+                    this.managedConn.requestOutput();
+                }
+            } else {
+                requestConnection();
+            }
+        }
+    }
+
+    public synchronized void releaseConnection() {
+        if (this.managedConn != null) {
+            try {
+                if (this.log.isDebugEnabled()) {
+                    this.log.debug("[exchange: " + this.state.getId() + "] releasing connection");
+                }
+                this.managedConn.getContext().removeAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER);
+                if (this.state.isReusable()) {
+                    this.connmgr.releaseConnection(this.managedConn,
+                        this.localContext.getUserToken(),
+                        this.state.getValidDuration(), TimeUnit.MILLISECONDS);
+                    this.managedConn = null;
+                }
+            } finally {
+                abortConnection();
+            }
+        }
+    }
+
+    public synchronized void abortConnection() {
+        if (this.managedConn != null) {
+            try {
+                this.managedConn.shutdown();
+                if (this.log.isDebugEnabled()) {
+                    this.log.debug("[exchange: " + this.state.getId() + "] connection discarded");
+                }
+            } catch (final IOException ex) {
+                if (this.log.isDebugEnabled()) {
+                    this.log.debug(ex.getMessage(), ex);
+                }
+            } finally {
+                this.connmgr.releaseConnection(
+                        this.managedConn, null, 0, TimeUnit.MILLISECONDS);
+            }
+        }
+        this.managedConn = null;
+    }
+
+    public synchronized void failed(final Exception ex) {
+        try {
+            this.requestProducer.failed(ex);
+            this.responseConsumer.failed(ex);
+        } finally {
+            try {
+                this.resultCallback.failed(ex, this);
+            } finally {
+                close();
+            }
+        }
+    }
+
+    public synchronized boolean cancel() {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("[exchange: " + this.state.getId() + "] Cancelled");
+        }
+        try {
+            final boolean cancelled = this.responseConsumer.cancel();
+
+            final T result = this.responseConsumer.getResult();
+            final Exception ex = this.responseConsumer.getException();
+            if (ex != null) {
+                this.resultCallback.failed(ex, this);
+            } else if (result != null) {
+                this.resultCallback.completed(result, this);
+            } else {
+                this.resultCallback.cancelled(this);
+            }
+            return cancelled;
+        } catch (final RuntimeException runex) {
+            this.resultCallback.failed(runex, this);
+            throw runex;
+        } finally {
+            close();
+        }
+    }
+
+    public boolean isDone() {
+        return this.resultCallback.isDone();
+    }
+
+    public T getResult() {
+        return this.responseConsumer.getResult();
+    }
+
+    public Exception getException() {
+        return this.responseConsumer.getException();
+    }
+
+    public HttpContext getContext() {
+        return this.localContext;
+    }
+
+    public HttpProcessor getHttpProcessor() {
+        return this.httppocessor;
+    }
+
+    public ConnectionReuseStrategy getConnectionReuseStrategy() {
+        return this.reuseStrategy;
+    }
+
+    private synchronized void connectionAllocated(final NHttpClientConnection managedConn) {
+        try {
+            if (this.log.isDebugEnabled()) {
+                this.log.debug("[exchange: " + this.state.getId() + "] Connection allocated: " + managedConn);
+            }
+            this.managedConn = managedConn;
+            this.state.setValidDuration(0);
+            this.state.setNonReusable();
+
+            if (this.closed) {
+                releaseConnection();
+                return;
+            }
+
+            this.localContext.setAttribute(ExecutionContext.HTTP_CONNECTION, managedConn);
+            this.state.setRouteEstablished(this.connmgr.isRouteComplete(managedConn));
+            if (!this.state.isRouteEstablished()) {
+                this.state.setRouteTracker(new RouteTracker(this.state.getRoute()));
+            }
+
+            if (!managedConn.isOpen()) {
+                failed(new ConnectionClosedException("Connection closed"));
+            } else {
+                this.managedConn.getContext().setAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER, this);
+                this.managedConn.requestOutput();
+            }
+        } catch (final RuntimeException runex) {
+            failed(runex);
+            throw runex;
+        }
+    }
+
+    private synchronized void connectionReopened(final NHttpClientConnection managedConn) {
+        try {
+            if (this.log.isDebugEnabled()) {
+                this.log.debug("[exchange: " + this.state.getId() + "] Connection re-opened: " + managedConn);
+            }
+            this.managedConn = managedConn;
+            this.state.setValidDuration(0);
+            this.state.setNonReusable();
+            this.state.setRouteEstablished(false);
+            this.state.setRouteTracker(new RouteTracker(this.state.getRoute()));
+
+            this.managedConn.getContext().setAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER, this);
+            this.managedConn.requestOutput();
+        } catch (final RuntimeException runex) {
+            failed(runex);
+            throw runex;
+        }
+    }
+
+    private synchronized void connectionRequestFailed(final Exception ex) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("[exchange: " + this.state.getId() + "] connection request failed");
+        }
+        try {
+            this.resultCallback.failed(ex, this);
+        } finally {
+            close();
+        }
+    }
+
+    private synchronized void connectionRequestCancelled() {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("[exchange: " + this.state.getId() + "] Connection request cancelled");
+        }
+        try {
+            this.resultCallback.cancelled(this);
+        } finally {
+            close();
+        }
+    }
+
+    private void requestConnection() {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("[exchange: " + this.state.getId() + "] Request connection for " +
+                this.state.getRoute());
+        }
+        final HttpRoute route = this.state.getRoute();
+        final Object userToken = this.localContext.getUserToken();
+        final RequestConfig config = this.localContext.getRequestConfig();
+        this.connmgr.requestConnection(
+                route,
+                userToken,
+                config.getConnectionRequestTimeout(), TimeUnit.MILLISECONDS,
+                new FutureCallback<NHttpClientConnection>() {
+
+                    public void completed(final NHttpClientConnection managedConn) {
+                        connectionAllocated(managedConn);
+                    }
+
+                    public void failed(final Exception ex) {
+                        connectionRequestFailed(ex);
+                    }
+
+                    public void cancelled() {
+                        connectionRequestCancelled();
+                    }
+
+                });
+    }
+
+    private void reopenConnection() {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug("[exchange: " + this.state.getId() + "] Re-open connection for " +
+                this.state.getRoute());
+        }
+        final HttpRoute route = this.state.getRoute();
+        final RequestConfig config = this.localContext.getRequestConfig();
+        this.connmgr.connect(
+                this.managedConn,
+                route,
+                config.getConnectTimeout(),
+                new FutureCallback<NHttpClientConnection>() {
+
+                    public void completed(final NHttpClientConnection managedConn) {
+                        connectionReopened(managedConn);
+                    }
+
+                    public void failed(final Exception ex) {
+                        connectionRequestFailed(ex);
+                    }
+
+                    public void cancelled() {
+                        connectionRequestCancelled();
+                    }
+
+                });
+    }
+
+    public NHttpClientConnection getConnection() {
+        return this.managedConn;
+    }
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultRequestExectionHandlerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultRequestExectionHandlerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/DefaultRequestExectionHandlerImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java?rev=1463727&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java Tue Apr  2 20:10:03 2013
@@ -0,0 +1,565 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.impl.nio.client;
+
+import java.net.ProxySelector;
+import java.util.Collection;
+import java.util.LinkedList;
+
+import javax.net.ssl.SSLContext;
+
+import org.apache.http.ConnectionReuseStrategy;
+import org.apache.http.Header;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpRequestInterceptor;
+import org.apache.http.HttpResponseInterceptor;
+import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.auth.AuthSchemeProvider;
+import org.apache.http.client.AuthenticationStrategy;
+import org.apache.http.client.CookieStore;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.RedirectStrategy;
+import org.apache.http.client.UserTokenHandler;
+import org.apache.http.client.config.AuthSchemes;
+import org.apache.http.client.config.CookieSpecs;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.protocol.RequestAddCookies;
+import org.apache.http.client.protocol.RequestAuthCache;
+import org.apache.http.client.protocol.RequestClientConnControl;
+import org.apache.http.client.protocol.RequestDefaultHeaders;
+import org.apache.http.client.protocol.RequestExpectContinue;
+import org.apache.http.client.protocol.ResponseProcessCookies;
+import org.apache.http.config.ConnectionConfig;
+import org.apache.http.config.Lookup;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.config.SocketConfig;
+import org.apache.http.conn.ConnectionKeepAliveStrategy;
+import org.apache.http.conn.SchemePortResolver;
+import org.apache.http.conn.routing.HttpRoutePlanner;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.cookie.CookieSpecProvider;
+import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.impl.NoConnectionReuseStrategy;
+import org.apache.http.impl.auth.BasicSchemeFactory;
+import org.apache.http.impl.auth.DigestSchemeFactory;
+import org.apache.http.impl.auth.KerberosSchemeFactory;
+import org.apache.http.impl.auth.NTLMSchemeFactory;
+import org.apache.http.impl.auth.SPNegoSchemeFactory;
+import org.apache.http.impl.client.BasicCookieStore;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy;
+import org.apache.http.impl.client.DefaultRedirectStrategy;
+import org.apache.http.impl.client.DefaultUserTokenHandler;
+import org.apache.http.impl.client.NoopUserTokenHandler;
+import org.apache.http.impl.client.ProxyAuthenticationStrategy;
+import org.apache.http.impl.client.TargetAuthenticationStrategy;
+import org.apache.http.impl.conn.DefaultProxyRoutePlanner;
+import org.apache.http.impl.conn.DefaultRoutePlanner;
+import org.apache.http.impl.conn.DefaultSchemePortResolver;
+import org.apache.http.impl.conn.SystemDefaultRoutePlanner;
+import org.apache.http.impl.cookie.BestMatchSpecFactory;
+import org.apache.http.impl.cookie.BrowserCompatSpecFactory;
+import org.apache.http.impl.cookie.IgnoreSpecFactory;
+import org.apache.http.impl.cookie.NetscapeDraftSpecFactory;
+import org.apache.http.impl.cookie.RFC2109SpecFactory;
+import org.apache.http.impl.cookie.RFC2965SpecFactory;
+import org.apache.http.impl.execchain.ClientExecChain;
+import org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager;
+import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
+import org.apache.http.impl.nio.reactor.IOReactorConfig;
+import org.apache.http.nio.conn.NHttpClientConnectionManager;
+import org.apache.http.nio.conn.ssl.SSLLayeringStrategy;
+import org.apache.http.nio.conn.ssl.SchemeLayeringStrategy;
+import org.apache.http.nio.reactor.ConnectingIOReactor;
+import org.apache.http.nio.reactor.IOReactorException;
+import org.apache.http.protocol.HttpProcessor;
+import org.apache.http.protocol.HttpProcessorBuilder;
+import org.apache.http.protocol.RequestContent;
+import org.apache.http.protocol.RequestTargetHost;
+import org.apache.http.protocol.RequestUserAgent;
+import org.apache.http.util.VersionInfo;
+
+@NotThreadSafe
+public class HttpAsyncClientBuilder {
+
+    private NHttpClientConnectionManager connManager;
+    private SchemePortResolver schemePortResolver;
+    private SchemeLayeringStrategy sslLayeringStrategy;
+    private SSLContext sslcontext;
+    private ConnectionReuseStrategy reuseStrategy;
+    private ConnectionKeepAliveStrategy keepAliveStrategy;
+    private AuthenticationStrategy targetAuthStrategy;
+    private AuthenticationStrategy proxyAuthStrategy;
+    private UserTokenHandler userTokenHandler;
+    private HttpProcessor httpprocessor;
+
+    private LinkedList<HttpRequestInterceptor> requestFirst;
+    private LinkedList<HttpRequestInterceptor> requestLast;
+    private LinkedList<HttpResponseInterceptor> responseFirst;
+    private LinkedList<HttpResponseInterceptor> responseLast;
+
+    private HttpRoutePlanner routePlanner;
+    private RedirectStrategy redirectStrategy;
+    private Lookup<AuthSchemeProvider> authSchemeRegistry;
+    private Lookup<CookieSpecProvider> cookieSpecRegistry;
+    private CookieStore cookieStore;
+    private CredentialsProvider credentialsProvider;
+    private String userAgent;
+    private HttpHost proxy;
+    private Collection<? extends Header> defaultHeaders;
+    private IOReactorConfig defaultIOReactorConfig;
+    private SocketConfig defaultSocketConfig;
+    private ConnectionConfig defaultConnectionConfig;
+    private RequestConfig defaultRequestConfig;
+
+    private boolean systemProperties;
+    private boolean cookieManagementDisabled;
+    private boolean authCachingDisabled;
+    private boolean connectionStateDisabled;
+
+    private int maxConnTotal = 0;
+    private int maxConnPerRoute = 0;
+
+    public static HttpAsyncClientBuilder create() {
+        return new HttpAsyncClientBuilder();
+    }
+
+    protected HttpAsyncClientBuilder() {
+        super();
+    }
+
+    public final HttpAsyncClientBuilder setConnectionManager(
+            final NHttpClientConnectionManager connManager) {
+        this.connManager = connManager;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setSchemePortResolver(
+            final SchemePortResolver schemePortResolver) {
+        this.schemePortResolver = schemePortResolver;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setMaxConnTotal(final int maxConnTotal) {
+        this.maxConnTotal = maxConnTotal;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setMaxConnPerRoute(final int maxConnPerRoute) {
+        this.maxConnPerRoute = maxConnPerRoute;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setConnectionReuseStrategy(
+            final ConnectionReuseStrategy reuseStrategy) {
+        this.reuseStrategy = reuseStrategy;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setKeepAliveStrategy(
+            final ConnectionKeepAliveStrategy keepAliveStrategy) {
+        this.keepAliveStrategy = keepAliveStrategy;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setUserTokenHandler(final UserTokenHandler userTokenHandler) {
+        this.userTokenHandler = userTokenHandler;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setTargetAuthenticationStrategy(
+            final AuthenticationStrategy targetAuthStrategy) {
+        this.targetAuthStrategy = targetAuthStrategy;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setProxyAuthenticationStrategy(
+            final AuthenticationStrategy proxyAuthStrategy) {
+        this.proxyAuthStrategy = proxyAuthStrategy;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setHttpProcessor(final HttpProcessor httpprocessor) {
+        this.httpprocessor = httpprocessor;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder addInterceptorFirst(final HttpResponseInterceptor itcp) {
+        if (itcp == null) {
+            return this;
+        }
+        if (responseFirst == null) {
+            responseFirst = new LinkedList<HttpResponseInterceptor>();
+        }
+        responseFirst.addFirst(itcp);
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder addInterceptorLast(final HttpResponseInterceptor itcp) {
+        if (itcp == null) {
+            return this;
+        }
+        if (responseLast == null) {
+            responseLast = new LinkedList<HttpResponseInterceptor>();
+        }
+        responseLast.addLast(itcp);
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder addInterceptorFirst(final HttpRequestInterceptor itcp) {
+        if (itcp == null) {
+            return this;
+        }
+        if (requestFirst == null) {
+            requestFirst = new LinkedList<HttpRequestInterceptor>();
+        }
+        requestFirst.addFirst(itcp);
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder addInterceptorLast(final HttpRequestInterceptor itcp) {
+        if (itcp == null) {
+            return this;
+        }
+        if (requestLast == null) {
+            requestLast = new LinkedList<HttpRequestInterceptor>();
+        }
+        requestLast.addLast(itcp);
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setRoutePlanner(final HttpRoutePlanner routePlanner) {
+        this.routePlanner = routePlanner;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setRedirectStrategy(final RedirectStrategy redirectStrategy) {
+        this.redirectStrategy = redirectStrategy;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setDefaultCookieStore(final CookieStore cookieStore) {
+        this.cookieStore = cookieStore;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setDefaultCredentialsProvider(
+            final CredentialsProvider credentialsProvider) {
+        this.credentialsProvider = credentialsProvider;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setDefaultAuthSchemeRegistry(
+            final Lookup<AuthSchemeProvider> authSchemeRegistry) {
+        this.authSchemeRegistry = authSchemeRegistry;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setDefaultCookieSpecRegistry(
+            final Lookup<CookieSpecProvider> cookieSpecRegistry) {
+        this.cookieSpecRegistry = cookieSpecRegistry;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setUserAgent(final String userAgent) {
+        this.userAgent = userAgent;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setProxy(final HttpHost proxy) {
+        this.proxy = proxy;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setSSLLayeringStrategy(
+            final SchemeLayeringStrategy layeringStrategy) {
+        this.sslLayeringStrategy = layeringStrategy;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setSSLContext(final SSLContext sslcontext) {
+        this.sslcontext = sslcontext;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setDefaultHeaders(final Collection<? extends Header> defaultHeaders) {
+        this.defaultHeaders = defaultHeaders;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setDefaultSocketConfig(final SocketConfig config) {
+        this.defaultSocketConfig = config;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setDefaultConnectionConfig(final ConnectionConfig config) {
+        this.defaultConnectionConfig = config;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder setDefaultRequestConfig(final RequestConfig config) {
+        this.defaultRequestConfig = config;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder disableConnectionState() {
+        connectionStateDisabled = true;
+        return this;
+    }
+
+    public final HttpAsyncClientBuilder useSystemProperties() {
+        systemProperties = true;
+        return this;
+    }
+
+    protected ClientExecChain decorateMainExec(final ClientExecChain mainExec) {
+        return mainExec;
+    }
+
+    protected ClientExecChain decorateProtocolExec(final ClientExecChain protocolExec) {
+        return protocolExec;
+    }
+
+    private ConnectingIOReactor createIOReactor(final IOReactorConfig config) {
+        try {
+            return new DefaultConnectingIOReactor(config);
+        } catch (final IOReactorException ex) {
+            throw new IllegalStateException(ex);
+        }
+    }
+
+    public CloseableHttpAsyncClient build() {
+        NHttpClientConnectionManager connManager = this.connManager;
+        if (connManager == null) {
+            SchemeLayeringStrategy sslLayeringStrategy = this.sslLayeringStrategy;
+            if (sslLayeringStrategy == null) {
+                SSLContext sslcontext = this.sslcontext;
+                if (sslcontext == null) {
+                    if (systemProperties) {
+                        sslcontext = SSLSocketFactory.createSystemSSLContext();
+                    } else {
+                        sslcontext = SSLSocketFactory.createDefaultSSLContext();
+                    }
+                }
+                sslLayeringStrategy = new SSLLayeringStrategy(sslcontext);
+            }
+            final ConnectingIOReactor ioreactor = createIOReactor(
+                defaultIOReactorConfig != null ? defaultIOReactorConfig : IOReactorConfig.DEFAULT);
+            final PoolingNHttpClientConnectionManager poolingmgr = new PoolingNHttpClientConnectionManager(
+                    ioreactor,
+                    RegistryBuilder.<SchemeLayeringStrategy>create()
+                        .register("https", sslLayeringStrategy)
+                        .build());
+            if (defaultSocketConfig != null) {
+                poolingmgr.setDefaultSocketConfig(defaultSocketConfig);
+            }
+            if (defaultConnectionConfig != null) {
+                poolingmgr.setDefaultConnectionConfig(defaultConnectionConfig);
+            }
+            if (systemProperties) {
+                String s = System.getProperty("http.keepAlive", "true");
+                if ("true".equalsIgnoreCase(s)) {
+                    s = System.getProperty("http.maxConnections", "5");
+                    final int max = Integer.parseInt(s);
+                    poolingmgr.setDefaultMaxPerRoute(max);
+                    poolingmgr.setMaxTotal(2 * max);
+                }
+            } else {
+                if (maxConnTotal > 0) {
+                    poolingmgr.setMaxTotal(maxConnTotal);
+                }
+                if (maxConnPerRoute > 0) {
+                    poolingmgr.setDefaultMaxPerRoute(maxConnPerRoute);
+                }
+            }
+            connManager = poolingmgr;
+        }
+        ConnectionReuseStrategy reuseStrategy = this.reuseStrategy;
+        if (reuseStrategy == null) {
+            if (systemProperties) {
+                final String s = System.getProperty("http.keepAlive", "true");
+                if ("true".equalsIgnoreCase(s)) {
+                    reuseStrategy = DefaultConnectionReuseStrategy.INSTANCE;
+                } else {
+                    reuseStrategy = NoConnectionReuseStrategy.INSTANCE;
+                }
+            } else {
+                reuseStrategy = DefaultConnectionReuseStrategy.INSTANCE;
+            }
+        }
+        ConnectionKeepAliveStrategy keepAliveStrategy = this.keepAliveStrategy;
+        if (keepAliveStrategy == null) {
+            keepAliveStrategy = DefaultConnectionKeepAliveStrategy.INSTANCE;
+        }
+        AuthenticationStrategy targetAuthStrategy = this.targetAuthStrategy;
+        if (targetAuthStrategy == null) {
+            targetAuthStrategy = TargetAuthenticationStrategy.INSTANCE;
+        }
+        AuthenticationStrategy proxyAuthStrategy = this.proxyAuthStrategy;
+        if (proxyAuthStrategy == null) {
+            proxyAuthStrategy = ProxyAuthenticationStrategy.INSTANCE;
+        }
+        UserTokenHandler userTokenHandler = this.userTokenHandler;
+        if (userTokenHandler == null) {
+            if (!connectionStateDisabled) {
+                userTokenHandler = DefaultUserTokenHandler.INSTANCE;
+            } else {
+                userTokenHandler = NoopUserTokenHandler.INSTANCE;
+            }
+        }
+        SchemePortResolver schemePortResolver = this.schemePortResolver;
+        if (schemePortResolver == null) {
+            schemePortResolver = DefaultSchemePortResolver.INSTANCE;
+        }
+
+        HttpProcessor httpprocessor = this.httpprocessor;
+        if (httpprocessor == null) {
+
+            String userAgent = this.userAgent;
+            if (userAgent == null) {
+                if (systemProperties) {
+                    userAgent = System.getProperty("http.agent");
+                } else {
+                    final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.nio.client",
+                            HttpAsyncClientBuilder.class.getClassLoader());
+                    final String release = vi != null ? vi.getRelease() : VersionInfo.UNAVAILABLE;
+                    userAgent = "Apache-HttpAsyncClient/" + release + " (java 1.5)";
+                }
+            }
+
+            final HttpProcessorBuilder b = HttpProcessorBuilder.create();
+            if (requestFirst != null) {
+                for (final HttpRequestInterceptor i: requestFirst) {
+                    b.addFirst(i);
+                }
+            }
+            if (responseFirst != null) {
+                for (final HttpResponseInterceptor i: responseFirst) {
+                    b.addFirst(i);
+                }
+            }
+            b.addAll(
+                    new RequestDefaultHeaders(defaultHeaders),
+                    new RequestContent(),
+                    new RequestTargetHost(),
+                    new RequestClientConnControl(),
+                    new RequestUserAgent(userAgent),
+                    new RequestExpectContinue());
+            if (!cookieManagementDisabled) {
+                b.add(new RequestAddCookies());
+            }
+            if (!authCachingDisabled) {
+                b.add(new RequestAuthCache());
+            }
+            if (!cookieManagementDisabled) {
+                b.add(new ResponseProcessCookies());
+            }
+            if (requestLast != null) {
+                for (final HttpRequestInterceptor i: requestLast) {
+                    b.addLast(i);
+                }
+            }
+            if (responseLast != null) {
+                for (final HttpResponseInterceptor i: responseLast) {
+                    b.addLast(i);
+                }
+            }
+            httpprocessor = b.build();
+        }
+        // Add redirect executor, if not disabled
+        HttpRoutePlanner routePlanner = this.routePlanner;
+        if (routePlanner == null) {
+            if (proxy != null) {
+                routePlanner = new DefaultProxyRoutePlanner(proxy, schemePortResolver);
+            } else if (systemProperties) {
+                routePlanner = new SystemDefaultRoutePlanner(
+                        schemePortResolver, ProxySelector.getDefault());
+            } else {
+                routePlanner = new DefaultRoutePlanner(schemePortResolver);
+            }
+        }
+        Lookup<AuthSchemeProvider> authSchemeRegistry = this.authSchemeRegistry;
+        if (authSchemeRegistry == null) {
+            authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create()
+                .register(AuthSchemes.BASIC, new BasicSchemeFactory())
+                .register(AuthSchemes.DIGEST, new DigestSchemeFactory())
+                .register(AuthSchemes.NTLM, new NTLMSchemeFactory())
+                .register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory())
+                .register(AuthSchemes.KERBEROS, new KerberosSchemeFactory())
+                .build();
+        }
+        Lookup<CookieSpecProvider> cookieSpecRegistry = this.cookieSpecRegistry;
+        if (cookieSpecRegistry == null) {
+            cookieSpecRegistry = RegistryBuilder.<CookieSpecProvider>create()
+                .register(CookieSpecs.BEST_MATCH, new BestMatchSpecFactory())
+                .register(CookieSpecs.BROWSER_COMPATIBILITY, new BrowserCompatSpecFactory())
+                .register(CookieSpecs.NETSCAPE, new NetscapeDraftSpecFactory())
+                .register(CookieSpecs.RFC_2109, new RFC2109SpecFactory())
+                .register(CookieSpecs.RFC_2965, new RFC2965SpecFactory())
+                .register(CookieSpecs.IGNORE_COOKIES, new IgnoreSpecFactory())
+                .build();
+        }
+
+        CookieStore defaultCookieStore = this.cookieStore;
+        if (defaultCookieStore == null) {
+            defaultCookieStore = new BasicCookieStore();
+        }
+
+        CredentialsProvider defaultCredentialsProvider = this.credentialsProvider;
+        if (defaultCredentialsProvider == null) {
+            defaultCredentialsProvider = new BasicCredentialsProvider();
+        }
+
+        RedirectStrategy redirectStrategy = this.redirectStrategy;
+        if (redirectStrategy == null) {
+            redirectStrategy = DefaultRedirectStrategy.INSTANCE;
+        }
+
+        final MainClientExec exec = new MainClientExec(
+            connManager,
+            routePlanner,
+            reuseStrategy,
+            keepAliveStrategy,
+            redirectStrategy,
+            targetAuthStrategy,
+            proxyAuthStrategy,
+            userTokenHandler);
+
+        return new InternalHttpAsyncClient(
+            connManager,
+            httpprocessor,
+            reuseStrategy,
+            exec,
+            cookieSpecRegistry,
+            authSchemeRegistry,
+            defaultCookieStore,
+            defaultCredentialsProvider,
+            defaultRequestConfig != null ? defaultRequestConfig : RequestConfig.DEFAULT);
+    }
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClients.java (from r1463726, httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/scheme/LayeringStrategy.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClients.java?p2=httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClients.java&p1=httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/scheme/LayeringStrategy.java&r1=1463726&r2=1463727&rev=1463727&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/scheme/LayeringStrategy.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClients.java Tue Apr  2 20:10:03 2013
@@ -24,15 +24,28 @@
  * <http://www.apache.org/>.
  *
  */
-package org.apache.http.nio.conn.scheme;
 
-import org.apache.http.nio.reactor.IOSession;
+package org.apache.http.impl.nio.client;
 
-public interface LayeringStrategy {
+import org.apache.http.annotation.Immutable;
 
-    @Deprecated
-    boolean isSecure();
+@Immutable
+public class HttpAsyncClients {
 
-    IOSession layer(IOSession iosession);
+    private HttpAsyncClients() {
+        super();
+    }
+
+    public static HttpAsyncClientBuilder custom() {
+        return HttpAsyncClientBuilder.create();
+    }
+
+    public static CloseableHttpAsyncClient createDefault() {
+        return HttpAsyncClientBuilder.create().build();
+    }
+
+    public static CloseableHttpAsyncClient createSystem() {
+        return HttpAsyncClientBuilder.create().useSystemProperties().build();
+    }
 
 }

Added: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalClientExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalClientExec.java?rev=1463727&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalClientExec.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalClientExec.java Tue Apr  2 20:10:03 2013
@@ -0,0 +1,71 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.http.impl.nio.client;
+
+import java.io.IOException;
+
+import org.apache.http.HttpException;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.nio.ContentDecoder;
+import org.apache.http.nio.ContentEncoder;
+import org.apache.http.nio.IOControl;
+
+interface InternalClientExec {
+
+    void prepare(
+            InternalState state,
+            HttpHost target,
+            HttpRequest original) throws IOException, HttpException;
+
+    HttpRequest generateRequest(
+            InternalState state,
+            InternalConnManager connManager) throws IOException, HttpException;
+
+    void produceContent(
+            InternalState state,
+            ContentEncoder encoder,
+            IOControl ioctrl) throws IOException;
+
+    void requestCompleted(
+            InternalState state);
+
+    void responseReceived(
+            InternalState state,
+            HttpResponse response) throws IOException, HttpException;
+
+    void consumeContent(
+            InternalState state,
+            ContentDecoder decoder,
+            IOControl ioctrl) throws IOException;
+
+    void responseCompleted(
+            InternalState state,
+            InternalConnManager connManager) throws HttpException;
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalClientExec.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalClientExec.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalClientExec.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalConnManager.java (from r1463726, httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/scheme/LayeringStrategy.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalConnManager.java?p2=httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalConnManager.java&p1=httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/scheme/LayeringStrategy.java&r1=1463726&r2=1463727&rev=1463727&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/conn/scheme/LayeringStrategy.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalConnManager.java Tue Apr  2 20:10:03 2013
@@ -24,15 +24,16 @@
  * <http://www.apache.org/>.
  *
  */
-package org.apache.http.nio.conn.scheme;
+package org.apache.http.impl.nio.client;
 
-import org.apache.http.nio.reactor.IOSession;
+import org.apache.http.nio.NHttpClientConnection;
 
-public interface LayeringStrategy {
+interface InternalConnManager {
 
-    @Deprecated
-    boolean isSecure();
+    void releaseConnection();
 
-    IOSession layer(IOSession iosession);
+    void abortConnection();
+
+    NHttpClientConnection getConnection();
 
 }

Added: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalHttpAsyncClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalHttpAsyncClient.java?rev=1463727&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalHttpAsyncClient.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalHttpAsyncClient.java Tue Apr  2 20:10:03 2013
@@ -0,0 +1,226 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.http.impl.nio.client;
+
+import java.io.IOException;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.Future;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.ConnectionReuseStrategy;
+import org.apache.http.auth.AuthSchemeProvider;
+import org.apache.http.auth.AuthState;
+import org.apache.http.client.CookieStore;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.protocol.ClientContext;
+import org.apache.http.client.protocol.HttpClientContext;
+import org.apache.http.concurrent.BasicFuture;
+import org.apache.http.concurrent.FutureCallback;
+import org.apache.http.config.Lookup;
+import org.apache.http.cookie.CookieSpecProvider;
+import org.apache.http.nio.conn.ClientAsyncConnectionManager;
+import org.apache.http.nio.conn.NHttpClientConnectionManager;
+import org.apache.http.nio.protocol.HttpAsyncRequestExecutionHandler;
+import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
+import org.apache.http.nio.protocol.HttpAsyncResponseConsumer;
+import org.apache.http.nio.reactor.IOEventDispatch;
+import org.apache.http.nio.reactor.IOReactorStatus;
+import org.apache.http.params.HttpParams;
+import org.apache.http.protocol.BasicHttpContext;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpProcessor;
+
+@SuppressWarnings("deprecation")
+class InternalHttpAsyncClient extends CloseableHttpAsyncClient {
+
+    private final Log log = LogFactory.getLog(getClass());
+
+    private final NHttpClientConnectionManager connmgr;
+    private final HttpProcessor httpProcessor;
+    private final ConnectionReuseStrategy reuseStrategy;
+    private final InternalClientExec exec;
+    private final Lookup<CookieSpecProvider> cookieSpecRegistry;
+    private final Lookup<AuthSchemeProvider> authSchemeRegistry;
+    private final CookieStore cookieStore;
+    private final CredentialsProvider credentialsProvider;
+    private final RequestConfig defaultConfig;
+    private final Queue<HttpAsyncRequestExecutionHandler<?>> queue;
+    private final Thread reactorThread;
+
+    private volatile IOReactorStatus status;
+
+    public InternalHttpAsyncClient(
+            final NHttpClientConnectionManager connmgr,
+            final HttpProcessor httpProcessor,
+            final ConnectionReuseStrategy reuseStrategy,
+            final InternalClientExec exec,
+            final Lookup<CookieSpecProvider> cookieSpecRegistry,
+            final Lookup<AuthSchemeProvider> authSchemeRegistry,
+            final CookieStore cookieStore,
+            final CredentialsProvider credentialsProvider,
+            final RequestConfig defaultConfig) {
+        super();
+        this.connmgr = connmgr;
+        this.httpProcessor = httpProcessor;
+        this.reuseStrategy = reuseStrategy;
+        this.exec = exec;
+        this.cookieSpecRegistry = cookieSpecRegistry;
+        this.authSchemeRegistry = authSchemeRegistry;
+        this.cookieStore = cookieStore;
+        this.credentialsProvider = credentialsProvider;
+        this.defaultConfig = defaultConfig;
+        this.queue = new ConcurrentLinkedQueue<HttpAsyncRequestExecutionHandler<?>>();
+        this.reactorThread = new Thread() {
+
+            @Override
+            public void run() {
+                doExecute();
+            }
+
+        };
+        this.status = IOReactorStatus.INACTIVE;
+    }
+
+    private void doExecute() {
+        try {
+            final IOEventDispatch ioEventDispatch = new InternalIODispatch();
+            this.connmgr.execute(ioEventDispatch);
+        } catch (final Exception ex) {
+            this.log.error("I/O reactor terminated abnormally", ex);
+        } finally {
+            this.status = IOReactorStatus.SHUT_DOWN;
+            while (!this.queue.isEmpty()) {
+                final HttpAsyncRequestExecutionHandler<?> exchangeHandler = this.queue.remove();
+                exchangeHandler.cancel();
+            }
+        }
+    }
+
+    public IOReactorStatus getStatus() {
+        return this.status;
+    }
+
+    public void start() {
+        this.status = IOReactorStatus.ACTIVE;
+        this.reactorThread.start();
+    }
+
+    public void shutdown() {
+        if (this.status.compareTo(IOReactorStatus.ACTIVE) > 0) {
+            return;
+        }
+        this.status = IOReactorStatus.SHUTDOWN_REQUEST;
+        try {
+            this.connmgr.shutdown();
+        } catch (final IOException ex) {
+            this.log.error("I/O error shutting down connection manager", ex);
+        }
+        if (this.reactorThread != null) {
+            try {
+                this.reactorThread.join();
+            } catch (final InterruptedException ex) {
+                Thread.currentThread().interrupt();
+            }
+        }
+    }
+
+    public void close() {
+        shutdown();
+    }
+
+    private void setupContext(final HttpClientContext context) {
+        if (context.getAttribute(ClientContext.TARGET_AUTH_STATE) == null) {
+            context.setAttribute(ClientContext.TARGET_AUTH_STATE, new AuthState());
+        }
+        if (context.getAttribute(ClientContext.PROXY_AUTH_STATE) == null) {
+            context.setAttribute(ClientContext.PROXY_AUTH_STATE, new AuthState());
+        }
+        if (context.getAttribute(ClientContext.AUTHSCHEME_REGISTRY) == null) {
+            context.setAttribute(ClientContext.AUTHSCHEME_REGISTRY, this.authSchemeRegistry);
+        }
+        if (context.getAttribute(ClientContext.COOKIESPEC_REGISTRY) == null) {
+            context.setAttribute(ClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
+        }
+        if (context.getAttribute(ClientContext.COOKIE_STORE) == null) {
+            context.setAttribute(ClientContext.COOKIE_STORE, this.cookieStore);
+        }
+        if (context.getAttribute(ClientContext.CREDS_PROVIDER) == null) {
+            context.setAttribute(ClientContext.CREDS_PROVIDER, this.credentialsProvider);
+        }
+        if (context.getAttribute(ClientContext.REQUEST_CONFIG) == null) {
+            context.setAttribute(ClientContext.REQUEST_CONFIG, this.defaultConfig);
+        }
+    }
+
+    public <T> Future<T> execute(
+            final HttpAsyncRequestProducer requestProducer,
+            final HttpAsyncResponseConsumer<T> responseConsumer,
+            final HttpContext context,
+            final FutureCallback<T> callback) {
+        if (this.status != IOReactorStatus.ACTIVE) {
+            throw new IllegalStateException("Request cannot be executed; " +
+                    "I/O reactor status: " + this.status);
+        }
+        final BasicFuture<T> future = new BasicFuture<T>(callback);
+        final ResultCallback<T> resultCallback = new DefaultResultCallback<T>(future, this.queue);
+        final HttpClientContext localcontext = HttpClientContext.adapt(
+            context != null ? context : new BasicHttpContext());
+        setupContext(localcontext);
+
+        final DefaultRequestExectionHandlerImpl<T> handler = new DefaultRequestExectionHandlerImpl<T>(
+            this.log,
+            requestProducer,
+            responseConsumer,
+            localcontext,
+            resultCallback,
+            this.connmgr,
+            this.httpProcessor,
+            this.reuseStrategy,
+            this.exec);
+        this.queue.add(handler);
+        try {
+            handler.start();
+        } catch (final Exception ex) {
+            handler.failed(ex);
+        }
+        return future;
+    }
+
+    @Deprecated
+    public ClientAsyncConnectionManager getConnectionManager() {
+        return null;
+    }
+
+    @Deprecated
+    public HttpParams getParams() {
+        return null;
+    }
+
+}

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalHttpAsyncClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalHttpAsyncClient.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalHttpAsyncClient.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalIODispatch.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalIODispatch.java?rev=1463727&view=auto
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalIODispatch.java (added)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalIODispatch.java Tue Apr  2 20:10:03 2013
@@ -0,0 +1,90 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.impl.nio.client;
+
+import java.io.IOException;
+
+import org.apache.http.impl.nio.DefaultNHttpClientConnection;
+import org.apache.http.impl.nio.reactor.AbstractIODispatch;
+import org.apache.http.nio.NHttpClientEventHandler;
+import org.apache.http.nio.reactor.IOSession;
+
+class InternalIODispatch extends AbstractIODispatch<DefaultNHttpClientConnection> {
+
+    private final NHttpClientEventHandler handler;
+
+    public InternalIODispatch() {
+        super();
+        this.handler = new LoggingAsyncRequestExecutor();
+    }
+
+    @Override
+    protected DefaultNHttpClientConnection createConnection(final IOSession session) {
+        throw new IllegalStateException("Connection must be created by connection manager");
+    }
+
+    @Override
+    protected void onConnected(final DefaultNHttpClientConnection conn) {
+        final Object attachment = conn.getContext().getAttribute(IOSession.ATTACHMENT_KEY);
+        try {
+            this.handler.connected(conn, attachment);
+        } catch (final Exception ex) {
+            this.handler.exception(conn, ex);
+        }
+    }
+
+    @Override
+    protected void onClosed(final DefaultNHttpClientConnection conn) {
+        this.handler.closed(conn);
+    }
+
+    @Override
+    protected void onException(final DefaultNHttpClientConnection conn, final IOException ex) {
+        this.handler.exception(conn, ex);
+    }
+
+    @Override
+    protected void onInputReady(final DefaultNHttpClientConnection conn) {
+        conn.consumeInput(this.handler);
+    }
+
+    @Override
+    protected void onOutputReady(final DefaultNHttpClientConnection conn) {
+        conn.produceOutput(this.handler);
+    }
+
+    @Override
+    protected void onTimeout(final DefaultNHttpClientConnection conn) {
+        try {
+            this.handler.timeout(conn);
+        } catch (final Exception ex) {
+            this.handler.exception(conn, ex);
+        }
+    }
+
+}



Mime
View raw message