cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: rev 51871 - cocoon/trunk/src/java/org/apache/cocoon/components/source/impl
Date Mon, 04 Oct 2004 07:45:45 GMT
Author: cziegeler
Date: Mon Oct  4 00:45:44 2004
New Revision: 51871

Modified:
   cocoon/trunk/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
Log:
Sync updates to sitemap source

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java	(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java	Mon
Oct  4 00:45:44 2004
@@ -58,7 +58,7 @@
 implements Source, XMLizable {
 
     /** validities for the internal pipeline */
-    private SourceValidity sourceValidity;
+    private SitemapSourceValidity validity;
 
     /** The system id */
     private final String systemId;
@@ -81,9 +81,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;
 
@@ -142,6 +139,9 @@
 
         this.systemId = info.systemId;
 
+        // create a new validity holder
+        this.validity = new SitemapSourceValidity();
+
         // initialize
         this.init();
     }
@@ -235,10 +235,7 @@
      *  <code>null</code> is returned.
      */
     public SourceValidity getValidity() {
-        if (this.redirectSource != null) {
-            return this.redirectValidity;
-        }
-        return this.sourceValidity;
+        return this.validity;
     }
 
     /**
@@ -278,7 +275,7 @@
                                                  this.environment);
                 try {
                     this.pipelineDescription.processingPipeline.prepareInternal(this.environment);
-                    this.sourceValidity = this.pipelineDescription.processingPipeline.getValidityForEventPipeline();
+                    this.validity.set(this.pipelineDescription.processingPipeline.getValidityForEventPipeline());
                     final String eventPipelineKey = this.pipelineDescription.processingPipeline.getKeyForEventPipeline();
                     this.mimeType = this.environment.getContentType();
 
@@ -306,7 +303,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) {
@@ -384,8 +381,8 @@
             this.sourceResolver.release(this.redirectSource);
             this.redirectSource = null;
         }
-        this.sourceValidity = null;
-        this.redirectValidity = null;
+
+        this.validity.set(null);
 
         this.environment.reset();
         this.exception = null;
@@ -396,6 +393,7 @@
      * Recyclable
      */
     public void recycle() {
+        this.validity = new SitemapSourceValidity();
         this.reset();
         if ( this.sourceResolver != null ) {
             this.manager.release( this.sourceResolver );
@@ -430,4 +428,31 @@
         return java.util.Collections.EMPTY_LIST.iterator();
     }
 
+    /**
+     * A simple SourceValidity protecting callers from resets.
+     */
+    private static final class SitemapSourceValidity implements SourceValidity {
+
+        private 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