cziegeler    2003/08/11 05:48:56

  Modified:    src/java/org/apache/cocoon/generation
                        JXTemplateGenerator.java
  Log:
  Use SourceValidity instead of last modified
  
  Revision  Changes    Path
  1.6       +33 -10    
cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java
  
  Index: JXTemplateGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JXTemplateGenerator.java  8 Aug 2003 18:49:06 -0000       1.5
  +++ JXTemplateGenerator.java  11 Aug 2003 12:48:56 -0000      1.6
  @@ -88,6 +88,7 @@
   import org.apache.commons.jxpath.*;
   import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.SourceException;
  +import org.apache.excalibur.source.SourceValidity;
   import org.mozilla.javascript.*;
   import org.w3c.dom.Node;
   import org.w3c.dom.NodeList;
  @@ -1125,7 +1126,7 @@
           StartDocument(Locator location) {
               super(location);
           }
  -        long compileTime;
  +        SourceValidity compileTime;
           EndDocument endDocument; // null if document fragment
       }
   
  @@ -2569,13 +2570,18 @@
               } catch (SourceException se) {
                   throw SourceUtil.handle("Error during resolving of '" + src 
+ "'.", se);
               }
  -            long lastMod = inputSource.getLastModified();
               String uri = inputSource.getURI();
               synchronized (cache) {
                   StartDocument startEvent = (StartDocument)cache.get(uri);
  -                if (startEvent != null &&
  -                    lastMod > startEvent.compileTime) {
  -                    cache.remove(uri);
  +                if (startEvent != null) {
  +                    int valid = startEvent.compileTime.isValid();
  +                    if ( valid == SourceValidity.UNKNOWN ) {
  +                        SourceValidity validity = inputSource.getValidity();
  +                        valid = startEvent.compileTime.isValid(validity);
  +                    }
  +                    if ( valid != SourceValidity.VALID) {
  +                        cache.remove(uri);
  +                    }
                   }
               }
           }
  @@ -2686,11 +2692,11 @@
               startEvent = (StartDocument)cache.get(inputSource.getURI());
           }
           if (startEvent == null) {
  -            long compileTime = inputSource.getLastModified();
  +            SourceValidity validity = inputSource.getValidity();
               Parser parser = new Parser();
               SourceUtil.parse(this.manager, this.inputSource, parser);
               startEvent = parser.getStartEvent();
  -            startEvent.compileTime = compileTime;
  +            startEvent.compileTime = validity;
               synchronized (cache) {
                   cache.put(inputSource.getURI(), startEvent);
               }
  @@ -3522,12 +3528,26 @@
                                                   ev.location,
                                                   exc);
                   }
  -                long lastMod = input.getLastModified();
  +                SourceValidity validity = null;
                   StartDocument doc;
                   synchronized (cache) {
                       doc = (StartDocument)cache.get(input.getURI());
                       if (doc != null) {
  -                        if (doc.compileTime < lastMod) {
  +                        boolean recompile = false;
  +                        if ( doc.compileTime == null) {
  +                            recompile = true;
  +                        } else {
  +                            int valid = doc.compileTime.isValid();
  +                            if ( valid == SourceValidity.UNKNOWN ) {
  +                                validity = input.getValidity();
  +                                valid = doc.compileTime.isValid(validity);
  +                                
  +                            }
  +                            if ( valid != SourceValidity.VALID ) {
  +                                recompile = true;
  +                            }
  +                        }
  +                        if ( recompile ) {
                               doc = null; // recompile
                           }
                       }
  @@ -3537,7 +3557,10 @@
                           Parser parser = new Parser();
                           SourceUtil.parse(this.manager, input, parser);
                           doc = parser.getStartEvent();
  -                        doc.compileTime = lastMod;
  +                        if ( validity == null ) {
  +                            validity = input.getValidity();
  +                        }
  +                        doc.compileTime = validity;
                       } catch (Exception exc) {
                           throw new SAXParseException(exc.getMessage(),
                                                       ev.location,
  
  
  

Reply via email to