diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClient.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClient.java
index f2bdc05aa..a1b18de20 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClient.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClient.java
@@ -118,7 +118,7 @@ import org.apache.http.util.VersionInfo;
*
* @since 4.1
*
- * @deprecated (4.3)
+ * @deprecated (4.3) use {@link CachingHttpClientBuilder} or {@link CachingHttpClients}.
*/
@Deprecated
@ThreadSafe // So long as the responseCache implementation is threadsafe
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClientBuilder.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClientBuilder.java
new file mode 100644
index 000000000..40971253b
--- /dev/null
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClientBuilder.java
@@ -0,0 +1,97 @@
+/*
+ * ====================================================================
+ * 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
+ * .
+ *
+ */
+package org.apache.http.impl.client.cache;
+
+import java.io.File;
+
+import org.apache.http.client.cache.HttpCacheStorage;
+import org.apache.http.client.cache.ResourceFactory;
+import org.apache.http.impl.client.builder.HttpClientBuilder;
+import org.apache.http.impl.client.execchain.ClientExecChain;
+
+/**
+ * @since (4.3)
+ */
+public class CachingHttpClientBuilder extends HttpClientBuilder {
+
+ private ResourceFactory resourceFactory;
+ private HttpCacheStorage storage;
+ private File cacheDir;
+ private CacheConfig cacheConfig;
+
+ public static CachingHttpClientBuilder create() {
+ return new CachingHttpClientBuilder();
+ }
+
+ protected CachingHttpClientBuilder() {
+ super();
+ }
+
+ public final CachingHttpClientBuilder setResourceFactory(
+ final ResourceFactory resourceFactory) {
+ this.resourceFactory = resourceFactory;
+ return this;
+ }
+
+ public final CachingHttpClientBuilder setHttpCacheStorage(
+ final HttpCacheStorage storage) {
+ this.storage = storage;
+ return this;
+ }
+
+ public final CachingHttpClientBuilder setCacheDir(
+ final File cacheDir) {
+ this.cacheDir = cacheDir;
+ return this;
+ }
+
+ public final CachingHttpClientBuilder setCacheConfig(
+ final CacheConfig cacheConfig) {
+ this.cacheConfig = cacheConfig;
+ return this;
+ }
+
+ @Override
+ protected ClientExecChain decorateMainExec(final ClientExecChain mainExec) {
+ CacheConfig config = this.cacheConfig != null ? this.cacheConfig : CacheConfig.DEFAULT;
+ ResourceFactory resourceFactory = this.resourceFactory;
+ if (resourceFactory == null) {
+ if (this.cacheDir == null) {
+ resourceFactory = new HeapResourceFactory();
+ } else {
+ resourceFactory = new FileResourceFactory(cacheDir);
+ }
+ }
+ HttpCacheStorage storage = this.storage;
+ if (storage == null) {
+ storage = new BasicHttpCacheStorage(cacheConfig);
+ }
+ return new CachingExec(mainExec,
+ new BasicHttpCache(resourceFactory, storage, config), config);
+ }
+
+}
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClients.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClients.java
new file mode 100644
index 000000000..55ed1ab00
--- /dev/null
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClients.java
@@ -0,0 +1,57 @@
+/*
+ * ====================================================================
+ * 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
+ * .
+ *
+ */
+
+package org.apache.http.impl.client.cache;
+
+import java.io.File;
+
+import org.apache.http.annotation.Immutable;
+import org.apache.http.impl.client.CloseableHttpClient;
+
+/**
+ * @since 4.3
+ */
+@Immutable
+public class CachingHttpClients {
+
+ private CachingHttpClients() {
+ super();
+ }
+
+ public static CachingHttpClientBuilder custom() {
+ return CachingHttpClientBuilder.create();
+ }
+
+ public static CloseableHttpClient createMemoryBound() {
+ return CachingHttpClientBuilder.create().build();
+ }
+
+ public static CloseableHttpClient createFileBound(final File cacheDir) {
+ return CachingHttpClientBuilder.create().setCacheDir(cacheDir).build();
+ }
+
+}
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
index 5a5d28042..a3cd0bdaf 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
@@ -32,7 +32,6 @@ import java.util.Arrays;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
-import javax.crypto.Mac;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.util.EncodingUtils;
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/HttpClients.java b/httpclient/src/main/java/org/apache/http/impl/client/HttpClients.java
index 02deec886..afc2d5ac2 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/HttpClients.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/HttpClients.java
@@ -48,4 +48,8 @@ public class HttpClients {
return HttpClientBuilder.create().build();
}
+ public static CloseableHttpClient createSystem() {
+ return HttpClientBuilder.create().useSystemProperties().build();
+ }
+
}
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/builder/HttpClientBuilder.java b/httpclient/src/main/java/org/apache/http/impl/client/builder/HttpClientBuilder.java
index c611ee762..89e511a9f 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/builder/HttpClientBuilder.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/builder/HttpClientBuilder.java
@@ -191,7 +191,7 @@ public class HttpClientBuilder {
return new HttpClientBuilder();
}
- HttpClientBuilder() {
+ protected HttpClientBuilder() {
super();
}