[java-opensaml COMMIT] in /trunk/opensaml-util/src: main/java/org/opensaml/util/net/CachingHttpResourceDecorator.java...
noreply at shibboleth.net
noreply at shibboleth.net
Mon Sep 26 18:21:25 BST 2011
Author: lajoie
Date: Mon Sep 26 18:21:25 2011
New Revision: 2912
URL: http://svn.shibboleth.net/view/java-opensaml?rev=2912&view=rev
Log:
Rework resource caching mechanics into a decorator pattern. Still have impl work to do but just getting the basics out there so Ian can look at it.
Added:
trunk/opensaml-util/src/main/java/org/opensaml/util/net/CachingHttpResourceDecorator.java (with props)
trunk/opensaml-util/src/main/java/org/opensaml/util/resource/CachingResourceDecorator.java (with props)
trunk/opensaml-util/src/main/java/org/opensaml/util/resource/InMemoryResourceCache.java (with props)
trunk/opensaml-util/src/main/java/org/opensaml/util/resource/ResourceCache.java (with props)
Removed:
trunk/opensaml-util/src/main/java/org/opensaml/util/resource/FilebackedRemoteResource.java
Modified:
trunk/opensaml-util/src/main/java/org/opensaml/util/net/HttpResource.java
trunk/opensaml-util/src/main/java/org/opensaml/util/resource/CachingResource.java
trunk/opensaml-util/src/test/java/org/opensaml/util/net/HttpResourceTest.java
Modified: trunk/opensaml-util/src/main/java/org/opensaml/util/net/HttpResource.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-util/src/main/java/org/opensaml/util/net/HttpResource.java?rev=2912&r1=2911&r2=2912&view=diff
==============================================================================
--- trunk/opensaml-util/src/main/java/org/opensaml/util/net/HttpResource.java (original)
+++ trunk/opensaml-util/src/main/java/org/opensaml/util/net/HttpResource.java Mon Sep 26 18:21:25 2011
@@ -17,21 +17,16 @@
package org.opensaml.util.net;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.GregorianCalendar;
-import java.util.Properties;
import net.jcip.annotations.NotThreadSafe;
+import net.jcip.annotations.ThreadSafe;
import org.apache.http.Header;
+import org.apache.http.HttpEntity;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
@@ -41,28 +36,21 @@
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.cookie.DateParseException;
import org.apache.http.impl.cookie.DateUtils;
-import org.apache.http.util.EntityUtils;
import org.opensaml.util.Assert;
-import org.opensaml.util.CloseableSupport;
-import org.opensaml.util.Pair;
import org.opensaml.util.StringSupport;
-import org.opensaml.util.resource.CachingResource;
-import org.opensaml.util.resource.FilebackedRemoteResource;
+import org.opensaml.util.constraint.documented.NotEmpty;
+import org.opensaml.util.constraint.documented.NotNull;
+import org.opensaml.util.constraint.documented.Null;
+import org.opensaml.util.resource.Resource;
import org.opensaml.util.resource.ResourceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//TODO authentication
-//TODO deal with case where cache file(s) are removed unexpectedly
-
-/**
- * A resource that fetches data from a remote source via HTTP. A backup/cache of the data is maintained in a local file.
- * The backup file is used if a conditional get, based on the ETag and last modified time, indicates that the data has
- * not been modified or if there is a problem fetching the data from the remote source (e.g. if the remote server is
- * down).
- */
+
+/** A resource that fetches data from a remote source via HTTP. */
@NotThreadSafe
-public class HttpResource implements CachingResource, FilebackedRemoteResource {
+public class HttpResource implements Resource {
/** Property name under which the ETag data is stored. */
public static final String ETAG_PROP = "etag";
@@ -79,58 +67,57 @@
/** URL of remote resource. */
private final String resourceUrl;
- /** Backup and local cache of metadata. */
- private final File backupFile;
-
- /** File used to store ETag and Last-Modified properties associated with backup file. */
- private final File propFile;
-
- /**
- * Whether the data (ETag and/or Last-Modified) information will be saved in addition to the backup file and then
- * used to bootstrap this resource next time.
- */
- private final boolean savingConditionalGetData;
-
- /** Instant, in milliseconds since the epoch, when the backup file was created. */
- private long backupFileCreationInstant;
-
- /** ETag associated with cached metadata. */
- private String cachedResourceETag;
-
- /** Last modified time associated with cached metadata. */
- private String cachedResourceLastModified;
-
- /**
- * Constructor. Initializes {@link #saveConditionalGetData} to true.
- *
+ /** Strategy used to customize an {@link HttpGet} before using it. */
+ private HttpGetCustomizationStrategy httpGetCustomizationStrategy;
+
+ /** Strategy used to customize an {@link HttpResponse} before get its content. */
[... 697 lines stripped ...]
More information about the commits
mailing list