pier        2004/06/30 14:04:08

  Modified:    src/java/org/apache/cocoon/components/modules/input
                        XMLFileModule.java
  Log:
  Flush caches when reloading an XML file in the XMLFileModule input module.
  This will prevent XPath values resolved with an old version of the file to
  be cached and returned even if the document changes.
  
  Revision  Changes    Path
  1.22      +18 -4     
cocoon-2.1/src/java/org/apache/cocoon/components/modules/input/XMLFileModule.java
  
  Index: XMLFileModule.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/modules/input/XMLFileModule.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- XMLFileModule.java        29 Jun 2004 15:07:14 -0000      1.21
  +++ XMLFileModule.java        30 Jun 2004 21:04:08 -0000      1.22
  @@ -123,6 +123,8 @@
           private SourceValidity validity;
           /** Source content cached as DOM Document */
           private Document document;
  +        /** Remember who created us (and who's caching us) */
  +        private XMLFileModule instance;
   
           /**
            * Creates a new <code>DocumentHelper</code> instance.
  @@ -131,10 +133,11 @@
            * @param cache a <code>boolean</code> value, whether this source 
should be kept in memory.
            * @param src a <code>String</code> value containing the URI
            */
  -        public DocumentHelper(boolean reload, boolean cache, String src) {
  +        public DocumentHelper(boolean reload, boolean cache, String src, 
XMLFileModule instance) {
               this.reloadable = reload;
               this.cacheable = cache;
               this.uri = src;
  +            this.instance = instance;
               // defer loading of the document
           }
   
  @@ -176,6 +179,17 @@
                               }
                               this.validity = newValidity;
                               this.document = SourceUtil.toDOM(src);
  +
  +                            /*
  +                             * Clear the cache, otherwise reloads won't do 
much.
  +                             *
  +                             * FIXME (pf): caches should be held in the 
DocumentHelper
  +                             *             instance itself, clearing global 
cache will
  +                             *             clear everything for each 
configured document.
  +                             *             (this is a quick fix, no time to 
do the whole)
  +                             */
  +                            this.instance.expressionCache.clear();
  +                            this.instance.expressionValuesCache.clear();
                           }
                       }
                   }
  @@ -266,7 +280,7 @@
               // by assigning the source uri to this.src the last one will be 
the default
               // OTOH caching / reload parameters can be specified in one 
central place
               // if multiple file tags are used.
  -            this.documents.put(files[i], new DocumentHelper(reload, cache, 
this.src));
  +            this.documents.put(files[i], new DocumentHelper(reload, cache, 
this.src, this));
           }
   
           // init caches
  @@ -336,7 +350,7 @@
                   }
   
               }
  -            this.documents.put(src, new DocumentHelper(reload, cache, src));
  +            this.documents.put(src, new DocumentHelper(reload, cache, src, 
this));
           }
   
           try {
  
  
  

Reply via email to