costin      00/12/13 10:48:47

  Modified:    src/share/org/apache/tomcat/util/depend DependManager.java
                        Dependency.java
  Log:
  Few small enhancements to the depend manager  - some dependencies are
  "local" ( the case of a jsp file ), and don't triger the expiration of
  the full collection.
  
  Revision  Changes    Path
  1.4       +9 -7      
jakarta-tomcat/src/share/org/apache/tomcat/util/depend/DependManager.java
  
  Index: DependManager.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/depend/DependManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DependManager.java        2000/12/02 08:26:58     1.3
  +++ DependManager.java        2000/12/13 18:48:43     1.4
  @@ -141,15 +141,17 @@
                //exact science ( and no dep can be removed)
                for( int i=0; i<depsCount; i++ ) {
                    Dependency d=deps[i];
  -                 long lm=d.getLastModified();
  -                 File f=d.getOrigin();
  -                 if( lm < f.lastModified() ) {
  +                 if( d.checkExpiry() ) {
                        // something got modified
  -                     //                      if( debug>0 )
                        if( debug > 0)
  -                         log("Found expired4 file " + f.getName());
  -                     expired=true;
  -                     // at least one file is expired
  +                         log("Found expired file " +
  +                             d.getOrigin().getName());
  +
  +                     if( ! d.isLocal() ) {
  +                         // if d is local, it'll just be marked as expired,
  +                         // the DependManager will not.
  +                         expired=true;
  +                     }
                    }
                }
                checkTime += lastCheck-startCheck;
  
  
  
  1.2       +78 -34    
jakarta-tomcat/src/share/org/apache/tomcat/util/depend/Dependency.java
  
  Index: Dependency.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/depend/Dependency.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Dependency.java   2000/08/14 18:40:35     1.1
  +++ Dependency.java   2000/12/13 18:48:43     1.2
  @@ -63,56 +63,100 @@
   import java.util.zip.*;
   import java.security.*;
   
  -/**
  +/** Represents a dependency between a real file and a server object.
  + *  The servler object has a timestamp, and it is compared with the
  + *  file lastModified time to detect changes.
  + * 
  + *  The DependManager will do the checkings ( with the minimal possible
  + *  overhead ). 
    */
  -public class Dependency {
  -
  -
  +public final class Dependency {
  +    
  +    private File origin;
  +    private long lastModified;
  +    private Object target;
  +    private boolean localDep=false;
  +    private boolean expired=false;
  +    
       public Dependency() {
       }
   
  -    long lastModified;
  -    
       /**
  -     * Get the value of lastModified.
  -     * @return Value of lastModified.
  +     * The time when the server-side object has been loaded/modified.
  +     * 
  +     * @param v  modification time 
        */
  -    public long getLastModified() {return lastModified;}
  -    
  +    public void setLastModified(long  v) {
  +     this.lastModified = v;
  +    }
  +
  +    public long getLastModified() {
  +     return lastModified;
  +    }
  +
       /**
  -     * Set the value of lastModified.
  -     * @param v  Value to assign to lastModified.
  +     * If set, the dependency will be "local", i.e. will be marked as
  +     * expired but the DependManager will not triger an expire at a higher
  +     * level ( example: if a JSP changes, no need to reload the context )
        */
  -    public void setLastModified(long  v) {this.lastModified = v;}
  +    public void setLocal(boolean b) {
  +     localDep=b;
  +    }
   
  -    
  -    File origin;
  +    public boolean isLocal() {
  +     return localDep;
  +    }
  +
  +    /** Mark this dependency as expired.
  +     */
  +    public void setExpired( boolean b ) {
  +     expired=b;
  +    }
  +
  +    public boolean isExpired() {
  +     return expired;
  +    }
       
       /**
  -       * Get the value of origin.
  -       * @return Value of origin.
  -       */
  -    public File getOrigin() {return origin;}
  +     * The file on which the server-side object depends or has been
  +     * loaded from.
  +     * 
  +     * @param v  Value to assign to origin.
  +     */
  +    public void setOrigin(File  v) {
  +     this.origin = v;
  +    }
       
  -    /**
  -       * Set the value of origin.
  -       * @param v  Value to assign to origin.
  -       */
  -    public void setOrigin(File  v) {this.origin = v;}
  +    public File getOrigin() {
  +     return origin;
  +    }
       
  -    Object target;
       
       /**
  -       * Get the value of target.
  -       * @return Value of target.
  -       */
  -    public Object getTarget() {return target;}
  +     * Server-side object that is checked for dependency on the file.
  +     *
  +     * @param v  Value to assign to target.
  +     */
  +    public void setTarget(Object  v) {
  +     this.target = v;
  +    }
       
  -    /**
  -       * Set the value of target.
  -       * @param v  Value to assign to target.
  -       */
  -    public void setTarget(Object  v) {this.target = v;}
  +    public Object getTarget() {
  +     return target;
  +    }
       
   
  +    // -------------------- methods --------------------
  +
  +    /** Check if the origin changed since target's was lastModified.
  +     *  This will be called periodically by DependManager or can
  +     *  be called to force a check for this particular dependency.
  +     */
  +    public boolean checkExpiry() {
  +     if( lastModified < origin.lastModified() ) {
  +         expired=true;
  +         return true;
  +     }
  +     return false;
  +    }
   }
  
  
  

Reply via email to