cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject svn commit: rev 51816 - cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/source/impl
Date Sun, 03 Oct 2004 01:06:07 GMT
Author: pier
Date: Sat Oct  2 18:06:05 2004
New Revision: 51816

Modified:
   cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
Log:
Fixing SitemapSourceValidity to return (always) the same SourceValidity instance to callers,
regardeless of resets.

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
Sat Oct  2 18:06:05 2004
@@ -60,7 +60,7 @@
 implements Source, XMLizable {
 
     /** validities for the internal pipeline */
-    private SourceValidity sourceValidity;
+    private SitemapSourceValidity validity;
 
     /** The system id */
     private final String systemId;
@@ -86,9 +86,6 @@
     /** The redirect <code>Source</code> */
     private Source redirectSource;
 
-    /** Redirect validity */
-    private SourceValidity redirectValidity;
-
     /** The <code>SAXException</code> if unable to get resource */
     private SAXException exception;
 
@@ -208,6 +205,9 @@
             this.environment.getObjectModel().remove(ObjectModelHelper.PARENT_CONTEXT);
         }
 
+        // create a new validity holder
+        this.validity = new SitemapSourceValidity();
+
         // initialize
         this.init();
     }
@@ -300,10 +300,7 @@
      *  <code>null</code> is returned.
      */
     public SourceValidity getValidity() {
-        if (this.redirectSource != null) {
-            return this.redirectValidity;
-        }
-        return this.sourceValidity;
+        return this.validity;
     }
 
     /**
@@ -343,7 +340,7 @@
                                                         this.pipelineProcessor);
                 try {
                     this.processingPipeline.prepareInternal(this.environment);
-                    this.sourceValidity = this.processingPipeline.getValidityForEventPipeline();
+                    this.validity.set(this.processingPipeline.getValidityForEventPipeline());
                     this.mimeType = this.environment.getContentType();
 
                     final String eventPipelineKey = this.processingPipeline.getKeyForEventPipeline();
@@ -371,7 +368,7 @@
                     this.sourceResolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
                 }
                 this.redirectSource = this.sourceResolver.resolveURI(redirectURL);
-                this.redirectValidity = this.redirectSource.getValidity();
+                this.validity.set(this.redirectSource.getValidity());
                 this.mimeType = this.redirectSource.getMimeType();
             }
         } catch (SAXException e) {
@@ -450,8 +447,7 @@
             this.redirectSource = null;
         }
 
-        this.sourceValidity = null;
-        this.redirectValidity = null;
+        this.validity.set(null);
 
         this.environment.reset();
         this.exception = null;
@@ -463,6 +459,7 @@
      * Recyclable
      */
     public void recycle() {
+        this.validity = new SitemapSourceValidity();
         this.reset();
         if (this.sourceResolver != null) {
             this.manager.release(this.sourceResolver);
@@ -497,4 +494,31 @@
         return java.util.Collections.EMPTY_LIST.iterator();
     }
 
+    /**
+     * A simple SourceValidity protecting callers from resets.
+     */
+    public static final class SitemapSourceValidity implements SourceValidity {
+
+        public SourceValidity nested_validity = null;
+
+        private SitemapSourceValidity() {
+            super();
+        }
+
+        private void set(SourceValidity validity) {
+            this.nested_validity = validity;
+        }
+
+        public int isValid() {
+            return(this.nested_validity != null?
+                   this.nested_validity.isValid():
+                   SourceValidity.INVALID);
+        }
+
+        public int isValid(SourceValidity validity) {
+            return(this.nested_validity != null?
+                   this.nested_validity.isValid(validity):
+                   SourceValidity.INVALID);
+        }
+    }
 }

Mime
View raw message