velocity-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime/resource ResourceManager.java
Date Mon, 12 Mar 2001 04:38:39 GMT
geirm       01/03/11 20:38:38

  Modified:    src/java/org/apache/velocity/runtime/resource
                        ResourceManager.java
  Log:
  Added Paulo Gaspar's fix to handle the possiblity that a resource
  gets changed between the time that it is read, and it's timestamp
  is saved for future comparisons.
  
  Seems straightforward - it just moves the grabbing of the timestamp
  backwards in time before the resource is loaded, therefore guaranteeing
  that the resource bits are at worst newer than the timestamp says (in
  which case it will be reloaded at next use...)
  
  Revision  Changes    Path
  1.15      +19 -5     jakarta-velocity/src/java/org/apache/velocity/runtime/resource/ResourceManager.java
  
  Index: ResourceManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/ResourceManager.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ResourceManager.java	2001/03/05 11:46:48	1.14
  +++ ResourceManager.java	2001/03/12 04:38:36	1.15
  @@ -3,7 +3,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -75,7 +75,8 @@
    * Runtime.
    *
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
  - * @version $Id: ResourceManager.java,v 1.14 2001/03/05 11:46:48 jvanzyl Exp $
  + * @author <a href="mailto:paulo.gaspar@krankikom.de">Paulo Gaspar</a>
  + * @version $Id: ResourceManager.java,v 1.15 2001/03/12 04:38:36 geirm Exp $
    */
   public class ResourceManager
   {
  @@ -260,6 +261,12 @@
                       try
                       {
                           /*
  +                         *  read how old the resource is _before_
  +                         *  processing (=>reading) it
  +                         */
  +                        long howOldItWas = resourceLoader.getLastModified( resource );
  +
  +                        /*
                            *  read in the fresh stream and parse
                            */
   
  @@ -270,8 +277,7 @@
                            *  the modification check counters
                            */
                           
  -                        resource.setLastModified( 
  -                            resourceLoader.getLastModified( resource ));              

  +                        resource.setLastModified( howOldItWas );
                       }
                       catch( ResourceNotFoundException rnfe )
                       {
  @@ -314,6 +320,7 @@
                   
                   //! Bug this is being run more then once!
                   
  +                long howOldItWas = 0;  // Initialize to avoid warnings
                   for (int i = 0; i < resourceLoaders.size(); i++)
                   {
                       resourceLoader = (ResourceLoader) resourceLoaders.get(i);
  @@ -322,6 +329,13 @@
                       Runtime.info("Attempting to find " + resourceName + 
                           " with " + resourceLoader.getClassName());
                       
  +                    /*
  +                     *  read how old the resource is _before_
  +                     *  processing (=>reading) it
  +                     */
  +
  +                    howOldItWas = resourceLoader.getLastModified( resource );
  +
                       if (resource.process())
                           break;
                   }
  @@ -332,7 +346,7 @@
                   if (resource.getData() == null)
                       throw new ResourceNotFoundException("Can't find " + resourceName +
"!");
                   
  -                resource.setLastModified(resourceLoader.getLastModified(resource));
  +                resource.setLastModified( howOldItWas );
                   
                   resource.setModificationCheckInterval(
                       resourceLoader.getModificationCheckInterval());
  
  
  

Mime
View raw message