From d60c36c40c51d736fc8c8f177f6361601aa99875 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Date: Tue, 14 Dec 2010 21:18:06 +0000 Subject: [PATCH] Renamed URIExtractor to CacheKeyGenerator, which is more descriptive of what we actually use it for. git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1049278 13f79535-47bb-0310-9956-ffa450edef68 --- .../http/impl/client/cache/BasicHttpCache.java | 4 ++-- .../impl/client/cache/CacheInvalidator.java | 6 +++--- ...RIExtractor.java => CacheKeyGenerator.java} | 2 +- .../impl/client/cache/TestBasicHttpCache.java | 8 ++++---- .../client/cache/TestCacheInvalidator.java | 4 ++-- ...tractor.java => TestCacheKeyGenerator.java} | 18 +++++++++--------- 6 files changed, 21 insertions(+), 21 deletions(-) rename httpclient-cache/src/main/java/org/apache/http/impl/client/cache/{URIExtractor.java => CacheKeyGenerator.java} (99%) rename httpclient-cache/src/test/java/org/apache/http/impl/client/cache/{TestURIExtractor.java => TestCacheKeyGenerator.java} (97%) diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCache.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCache.java index 9f48eb570..a94fa782d 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCache.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCache.java @@ -50,7 +50,7 @@ import org.apache.http.message.BasicHttpResponse; class BasicHttpCache implements HttpCache { - private final URIExtractor uriExtractor; + private final CacheKeyGenerator uriExtractor; private final ResourceFactory resourceFactory; private final int maxObjectSizeBytes; private final CacheEntryUpdater cacheEntryUpdater; @@ -62,7 +62,7 @@ class BasicHttpCache implements HttpCache { public BasicHttpCache(ResourceFactory resourceFactory, HttpCacheStorage storage, CacheConfig config) { this.resourceFactory = resourceFactory; - this.uriExtractor = new URIExtractor(); + this.uriExtractor = new CacheKeyGenerator(); this.cacheEntryUpdater = new CacheEntryUpdater(resourceFactory); this.maxObjectSizeBytes = config.getMaxObjectSizeBytes(); this.responseGenerator = new CachedHttpResponseGenerator(); diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheInvalidator.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheInvalidator.java index 86cd5b7c9..4309e7f89 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheInvalidator.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheInvalidator.java @@ -50,19 +50,19 @@ import org.apache.http.client.cache.HttpCacheStorage; class CacheInvalidator { private final HttpCacheStorage storage; - private final URIExtractor uriExtractor; + private final CacheKeyGenerator uriExtractor; private final Log log = LogFactory.getLog(getClass()); /** * Create a new {@link CacheInvalidator} for a given {@link HttpCache} and - * {@link URIExtractor}. + * {@link CacheKeyGenerator}. * * @param uriExtractor Provides identifiers for the keys to store cache entries * @param storage the cache to store items away in */ public CacheInvalidator( - final URIExtractor uriExtractor, + final CacheKeyGenerator uriExtractor, final HttpCacheStorage storage) { this.uriExtractor = uriExtractor; this.storage = storage; diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/URIExtractor.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheKeyGenerator.java similarity index 99% rename from httpclient-cache/src/main/java/org/apache/http/impl/client/cache/URIExtractor.java rename to httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheKeyGenerator.java index 229ae7806..a6c92658e 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/URIExtractor.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheKeyGenerator.java @@ -50,7 +50,7 @@ import org.apache.http.protocol.HTTP; * @since 4.1 */ @Immutable -class URIExtractor { +class CacheKeyGenerator { /** * For a given {@link HttpHost} and {@link HttpRequest} get a URI from the diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java index 0cc826e1f..846907bce 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java @@ -70,7 +70,7 @@ public class TestBasicHttpCache { public void testCanFlushCacheEntriesAtUri() throws Exception { HttpHost host = new HttpHost("foo.example.com"); HttpRequest req = new HttpDelete("/bar"); - final String key = (new URIExtractor()).getURI(host, req); + final String key = (new CacheKeyGenerator()).getURI(host, req); HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(); backing.map.put(key, entry); @@ -217,7 +217,7 @@ public class TestBasicHttpCache { assertFalse(entry.hasVariants()); HttpHost host = new HttpHost("foo.example.com"); HttpRequest req = new HttpGet("http://foo.example.com/bar"); - String key = (new URIExtractor()).getURI(host, req); + String key = (new CacheKeyGenerator()).getURI(host, req); impl.storeInCache(host, req, entry); assertSame(entry, backing.map.get(key)); @@ -263,7 +263,7 @@ public class TestBasicHttpCache { HttpResponse result = impl.cacheAndReturnResponse(host, request, originResponse, requestSent, responseReceived); assertEquals(1, backing.map.size()); - assertTrue(backing.map.containsKey((new URIExtractor()).getURI(host, request))); + assertTrue(backing.map.containsKey((new CacheKeyGenerator()).getURI(host, request))); assertTrue(HttpTestUtils.semanticallyTransparent(originResponse, result)); } @@ -282,7 +282,7 @@ public class TestBasicHttpCache { HttpHost host = new HttpHost("foo.example.com"); HttpRequest request = new HttpGet("http://foo.example.com/bar"); - String key = (new URIExtractor()).getURI(host, request); + String key = (new CacheKeyGenerator()).getURI(host, request); backing.map.put(key,entry); diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheInvalidator.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheInvalidator.java index 57ba76a48..e9157fc68 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheInvalidator.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheInvalidator.java @@ -48,14 +48,14 @@ public class TestCacheInvalidator { private CacheInvalidator impl; private HttpCacheStorage mockStorage; private HttpHost host; - private URIExtractor extractor; + private CacheKeyGenerator extractor; private HttpCacheEntry mockEntry; @Before public void setUp() { host = new HttpHost("foo.example.com"); mockStorage = EasyMock.createMock(HttpCacheStorage.class); - extractor = new URIExtractor(); + extractor = new CacheKeyGenerator(); mockEntry = EasyMock.createMock(HttpCacheEntry.class); impl = new CacheInvalidator(extractor, mockStorage); diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestURIExtractor.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheKeyGenerator.java similarity index 97% rename from httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestURIExtractor.java rename to httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheKeyGenerator.java index 0b603b5e0..6c5436e2d 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestURIExtractor.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheKeyGenerator.java @@ -39,13 +39,13 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -public class TestURIExtractor { +public class TestCacheKeyGenerator { private static final BasicHttpRequest REQUEST_FULL_EPISODES = new BasicHttpRequest("GET", "/full_episodes"); private static final BasicHttpRequest REQUEST_ROOT = new BasicHttpRequest("GET", "/"); - URIExtractor extractor; + CacheKeyGenerator extractor; private HttpHost host; private HttpCacheEntry mockEntry; private HttpRequest mockRequest; @@ -55,7 +55,7 @@ public class TestURIExtractor { host = new HttpHost("foo.example.com"); mockEntry = EasyMock.createMock(HttpCacheEntry.class); mockRequest = EasyMock.createMock(HttpRequest.class); - extractor = new URIExtractor(); + extractor = new CacheKeyGenerator(); } private void replayMocks() { @@ -124,7 +124,7 @@ public class TestURIExtractor { public void testGetVariantURIWithNoVaryHeaderReturnsNormalURI() { final String theURI = "theURI"; org.easymock.EasyMock.expect(mockEntry.hasVariants()).andReturn(false); - extractor = new URIExtractor() { + extractor = new CacheKeyGenerator() { @Override public String getURI(HttpHost h, HttpRequest req) { Assert.assertSame(host, h); @@ -145,7 +145,7 @@ public class TestURIExtractor { Header[] varyHeaders = { new BasicHeader("Vary", "Accept-Encoding") }; Header[] encHeaders = { new BasicHeader("Accept-Encoding", "gzip") }; - extractor = new URIExtractor() { + extractor = new CacheKeyGenerator() { @Override public String getURI(HttpHost h, HttpRequest req) { Assert.assertSame(host, h); @@ -170,7 +170,7 @@ public class TestURIExtractor { final String theURI = "theURI"; Header[] noHeaders = new Header[0]; Header[] varyHeaders = { new BasicHeader("Vary", "Accept-Encoding") }; - extractor = new URIExtractor() { + extractor = new CacheKeyGenerator() { @Override public String getURI(HttpHost h, HttpRequest req) { Assert.assertSame(host, h); @@ -196,7 +196,7 @@ public class TestURIExtractor { Header[] varyHeaders = { new BasicHeader("Vary", "User-Agent, Accept-Encoding") }; Header[] encHeaders = { new BasicHeader("Accept-Encoding", "gzip") }; Header[] uaHeaders = { new BasicHeader("User-Agent", "browser") }; - extractor = new URIExtractor() { + extractor = new CacheKeyGenerator() { @Override public String getURI(HttpHost h, HttpRequest req) { Assert.assertSame(host, h); @@ -224,7 +224,7 @@ public class TestURIExtractor { new BasicHeader("Vary", "Accept-Encoding") }; Header[] encHeaders = { new BasicHeader("Accept-Encoding", "gzip") }; Header[] uaHeaders = { new BasicHeader("User-Agent", "browser") }; - extractor = new URIExtractor() { + extractor = new CacheKeyGenerator() { @Override public String getURI(HttpHost h, HttpRequest req) { Assert.assertSame(host, h); @@ -251,7 +251,7 @@ public class TestURIExtractor { Header[] encHeaders = { new BasicHeader("Accept-Encoding", "gzip"), new BasicHeader("Accept-Encoding", "deflate") }; Header[] uaHeaders = { new BasicHeader("User-Agent", "browser") }; - extractor = new URIExtractor() { + extractor = new CacheKeyGenerator() { @Override public String getURI(HttpHost h, HttpRequest req) { Assert.assertSame(host, h);