CachingHttpClient(HttpCache<CacheEntry> cache, int maxObjectSizeBytes) failed to save maxObjectSizeBytes

Make all immutable private fields final

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@939875 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2010-04-30 23:29:15 +00:00
parent 64c00009a4
commit 16a8c31100
1 changed files with 18 additions and 15 deletions

View File

@ -60,6 +60,7 @@ import org.apache.http.protocol.HttpContext;
*/ */
public class CachingHttpClient implements HttpClient { public class CachingHttpClient implements HttpClient {
private static final Log LOG = LogFactory.getLog(CachingHttpClient.class);
private final static int MAX_CACHE_ENTRIES = 1000; private final static int MAX_CACHE_ENTRIES = 1000;
private final static int DEFAULT_MAX_OBJECT_SIZE_BYTES = 8192; private final static int DEFAULT_MAX_OBJECT_SIZE_BYTES = 8192;
@ -67,29 +68,29 @@ public class CachingHttpClient implements HttpClient {
private final static boolean SUPPORTS_RANGE_AND_CONTENT_RANGE_HEADERS = false; private final static boolean SUPPORTS_RANGE_AND_CONTENT_RANGE_HEADERS = false;
private HttpClient backend; private final HttpClient backend;
private ResponseCachingPolicy responseCachingPolicy; private final ResponseCachingPolicy responseCachingPolicy;
private CacheEntryGenerator cacheEntryGenerator; private final CacheEntryGenerator cacheEntryGenerator;
private URIExtractor uriExtractor; private final URIExtractor uriExtractor;
private HttpCache<CacheEntry> responseCache; private final HttpCache<CacheEntry> responseCache;
private CachedHttpResponseGenerator responseGenerator; private final CachedHttpResponseGenerator responseGenerator;
private CacheInvalidator cacheInvalidator; private final CacheInvalidator cacheInvalidator;
private CacheableRequestPolicy cacheableRequestPolicy; private final CacheableRequestPolicy cacheableRequestPolicy;
private CachedResponseSuitabilityChecker suitabilityChecker; private final CachedResponseSuitabilityChecker suitabilityChecker;
private ConditionalRequestBuilder conditionalRequestBuilder; private final ConditionalRequestBuilder conditionalRequestBuilder;
private int maxObjectSizeBytes = DEFAULT_MAX_OBJECT_SIZE_BYTES; private final int maxObjectSizeBytes;
private CacheEntryUpdater cacheEntryUpdater; private final CacheEntryUpdater cacheEntryUpdater;
private volatile long cacheHits; private volatile long cacheHits;
private volatile long cacheMisses; private volatile long cacheMisses;
private volatile long cacheUpdates; private volatile long cacheUpdates;
private ResponseProtocolCompliance responseCompliance; private final ResponseProtocolCompliance responseCompliance;
private RequestProtocolCompliance requestCompliance; private final RequestProtocolCompliance requestCompliance;
private static final Log LOG = LogFactory.getLog(CachingHttpClient.class);
public CachingHttpClient() { public CachingHttpClient() {
this.backend = new DefaultHttpClient(); this.backend = new DefaultHttpClient();
this.maxObjectSizeBytes = DEFAULT_MAX_OBJECT_SIZE_BYTES;
this.responseCachingPolicy = new ResponseCachingPolicy(maxObjectSizeBytes); this.responseCachingPolicy = new ResponseCachingPolicy(maxObjectSizeBytes);
this.cacheEntryGenerator = new CacheEntryGenerator(); this.cacheEntryGenerator = new CacheEntryGenerator();
this.uriExtractor = new URIExtractor(); this.uriExtractor = new URIExtractor();
@ -108,6 +109,7 @@ public class CachingHttpClient implements HttpClient {
this.responseCache = cache; this.responseCache = cache;
this.backend = new DefaultHttpClient(); this.backend = new DefaultHttpClient();
this.maxObjectSizeBytes = maxObjectSizeBytes;
this.responseCachingPolicy = new ResponseCachingPolicy(maxObjectSizeBytes); this.responseCachingPolicy = new ResponseCachingPolicy(maxObjectSizeBytes);
this.cacheEntryGenerator = new CacheEntryGenerator(); this.cacheEntryGenerator = new CacheEntryGenerator();
this.uriExtractor = new URIExtractor(); this.uriExtractor = new URIExtractor();
@ -147,6 +149,7 @@ public class CachingHttpClient implements HttpClient {
ConditionalRequestBuilder conditionalRequestBuilder, CacheEntryUpdater entryUpdater, ConditionalRequestBuilder conditionalRequestBuilder, CacheEntryUpdater entryUpdater,
ResponseProtocolCompliance responseCompliance, ResponseProtocolCompliance responseCompliance,
RequestProtocolCompliance requestCompliance) { RequestProtocolCompliance requestCompliance) {
this.maxObjectSizeBytes = DEFAULT_MAX_OBJECT_SIZE_BYTES;
this.backend = backend; this.backend = backend;
this.responseCachingPolicy = responseCachingPolicy; this.responseCachingPolicy = responseCachingPolicy;
this.cacheEntryGenerator = cacheEntryGenerator; this.cacheEntryGenerator = cacheEntryGenerator;