You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2012/02/13 20:20:26 UTC
svn commit: r1243662 -
/httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java
Author: olegk
Date: Mon Feb 13 19:20:26 2012
New Revision: 1243662
URL: http://svn.apache.org/viewvc?rev=1243662&view=rev
Log:
Added option to create fluent Executor on top of an arbitrary HttpClient instance
Modified:
httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java
Modified: httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java?rev=1243662&r1=1243661&r2=1243662&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java (original)
+++ httpcomponents/httpclient/trunk/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java Mon Feb 13 19:20:26 2012
@@ -42,6 +42,8 @@ import org.apache.http.client.HttpClient
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLInitializationException;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.client.BasicAuthCache;
import org.apache.http.impl.client.BasicCredentialsProvider;
@@ -56,8 +58,13 @@ public class Executor {
final static DefaultHttpClient CLIENT;
static {
- CONNMGR = new PoolingClientConnectionManager(
- SchemeRegistryFactory.createSystemDefault());
+ SchemeRegistry schemeRegistry;
+ try {
+ schemeRegistry = SchemeRegistryFactory.createSystemDefault();
+ } catch (SSLInitializationException ex) {
+ schemeRegistry = SchemeRegistryFactory.createDefault();
+ }
+ CONNMGR = new PoolingClientConnectionManager(schemeRegistry);
CONNMGR.setDefaultMaxPerRoute(100);
CONNMGR.setMaxTotal(200);
CLIENT = new DefaultHttpClient(CONNMGR);
@@ -67,6 +74,10 @@ public class Executor {
return new Executor(CLIENT);
}
+ public static Executor newInstance(final HttpClient httpclient) {
+ return new Executor(httpclient != null ? httpclient : CLIENT);
+ }
+
private final HttpClient httpclient;
private final BasicHttpContext localContext;
private final AuthCache authCache;