cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r936242 - /cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/jaxb/JAXBGenerator.java
Date Wed, 21 Apr 2010 10:07:08 GMT
Author: simonetripodi
Date: Wed Apr 21 10:07:08 2010
New Revision: 936242

URL: http://svn.apache.org/viewvc?rev=936242&view=rev
Log:
added constructCacheKey() method implementation

Modified:
    cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/jaxb/JAXBGenerator.java

Modified: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/jaxb/JAXBGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/jaxb/JAXBGenerator.java?rev=936242&r1=936241&r2=936242&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/jaxb/JAXBGenerator.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/jaxb/JAXBGenerator.java
Wed Apr 21 10:07:08 2010
@@ -23,6 +23,7 @@ import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 
 import org.apache.cocoon.pipeline.ProcessingException;
+import org.apache.cocoon.pipeline.caching.AbstractCacheKey;
 import org.apache.cocoon.pipeline.caching.CacheKey;
 import org.apache.cocoon.pipeline.component.CachingPipelineComponent;
 import org.apache.cocoon.pipeline.util.StringRepresentation;
@@ -42,10 +43,6 @@ public final class JAXBGenerator extends
         this.toBeMarshalled = toBeMarshalled;
     }
 
-    public CacheKey constructCacheKey() {
-        return null;
-    }
-
     public void execute() {
         try {
             JAXBContext jaxbContext = JAXBContext.newInstance(this.toBeMarshalled.getClass());
@@ -62,4 +59,56 @@ public final class JAXBGenerator extends
     public String toString() {
         return StringRepresentation.buildString(this, "toBeMarshalled=" + this.toBeMarshalled);
     }
+
+    public CacheKey constructCacheKey() {
+        return new ObjectCacheKey(this.toBeMarshalled);
+    }
+
+    private final class ObjectCacheKey extends AbstractCacheKey {
+
+        private static final long serialVersionUID = 1L;
+
+        private final Object obj;
+
+        public ObjectCacheKey(Object obj) {
+            this.obj = obj;
+        }
+
+        public Object getObj() {
+            return this.obj;
+        }
+
+        @Override
+        public boolean equals(Object other) {
+            if (!(other instanceof ObjectCacheKey)) {
+                return false;
+            }
+
+            ObjectCacheKey otherCacheKey = (ObjectCacheKey) other;
+            return this.obj.equals(otherCacheKey.getObj());
+        }
+
+        @Override
+        public int hashCode() {
+            return this.obj.hashCode();
+        }
+
+        /**
+         * {@inheritDoc}
+         *
+         * @see org.apache.cocoon.pipeline.caching.CacheKey#isValid(org.apache.cocoon.pipeline.caching.CacheKey)
+         */
+        public long getLastModified() {
+            return -1;
+        }
+
+        /**
+         * {@inheritDoc}
+         *
+         * @see org.apache.cocoon.pipeline.caching.CacheKey#isValid(org.apache.cocoon.pipeline.caching.CacheKey)
+         */
+        public boolean isValid(CacheKey other) {
+            return this.equals(other);
+        }
+    }
 }



Mime
View raw message