diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-20 08:43:26 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-20 08:43:26 +0000 |
commit | 88d958ca1ba30ed421656fa0bcbab220254b7ad6 (patch) | |
tree | 1088bef9aec49a27df05beb8df049a5ca2dd2cf3 /java/sca/modules | |
parent | 634821c2e03c4aad63e7cce2b27715fc892d5762 (diff) |
TUSCANY-2537: Apply patch from Dan Becker for Demonstrate Atom Binding end to end caching (ETag, Last-modified use) in
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@687288 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules')
-rw-r--r-- | java/sca/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/CacheContext.java | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/java/sca/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/CacheContext.java b/java/sca/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/CacheContext.java new file mode 100644 index 0000000000..204cca963c --- /dev/null +++ b/java/sca/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/CacheContext.java @@ -0,0 +1,117 @@ +/*
+ * 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.
+ */
+
+package org.apache.tuscany.sca.binding.atom;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * A class to store cache settings for Atom and HTTP requests and responses.
+ */
+public class CacheContext {
+ private static final SimpleDateFormat RFC822DateFormat = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss Z" ); // RFC 822 date time
+ public String eTag;
+ public String lastModified;
+ public Date lastModifiedDate;
+ public String [] predicates;
+
+ /**
+ * An ETag is a unique ID for an item. It changes when
+ * a field in the item or the update date changes.
+ * See HTTP specification for how ETags work:
+ * http://tools.ietf.org/html/rfc2616
+ * @return the eTag
+ */
+ public String getETag() {
+ return eTag;
+ }
+ /**
+ * @param tag the eTag to set
+ */
+ public void setETag(String tag) {
+ eTag = tag;
+ }
+ /**
+ * The LastModified date is the time the item was last
+ * changed. See HTTP specification for how ETags work:
+ * http://tools.ietf.org/html/rfc2616
+ * @return the lastModified
+ */
+ public String getLastModified() {
+ return lastModified;
+ }
+ /**
+ * The LastModified date is the time the item was last
+ * changed. See HTTP specification for how ETags work:
+ * http://tools.ietf.org/html/rfc2616
+ * @return the lastModified
+ */
+ public Date getLastModifiedAsDate() {
+ return lastModifiedDate;
+ }
+ /**
+ * @param lastModified the lastModified to set
+ */
+ public void setLastModified(String lastModified) throws java.text.ParseException {
+ this.lastModified = lastModified;
+ // Catch date formatting on input to help debugging.
+ lastModifiedDate = RFC822DateFormat.parse( lastModified );
+ }
+
+ /**
+ * Predicates are statements that work in conjunction with
+ * ETags and LastModified dates to determine if a precondition
+ * or postcondition is satisfied.
+ * See HTTP specification for how predicates wrk:
+ * http://tools.ietf.org/html/rfc2616
+ * Example predicats in HTTP include If-Match, If-None-Match,
+ * If-Modified-Since, If-Unmodified-Since, If-Range.
+ * @return the predicates
+ */
+ public String[] getPredicates() {
+ return predicates;
+ }
+ /**
+ * @param predicates the predicates to set
+ */
+ public void setPredicates(String[] predicates) {
+ this.predicates = predicates;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer(", predicates=");
+ if (predicates == null) {
+ sb.append("null");
+ } else if ( predicates.length == 0 ){
+ sb.append("length=0");
+ } else {
+ for (int i = 0; i < predicates.length; i++) {
+ if (i > 0)
+ sb.append(", ");
+ sb.append(predicates[i]);
+ }
+ }
+
+ return "eTag=" + eTag + ", lastModified=" + lastModified
+ + sb.toString();
+ }
+}
|