You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@locus.apache.org on 2000/03/27 19:11:24 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/jasper/runtime JspLoader.java

mandar      00/03/27 09:11:24

  Modified:    src/share/org/apache/jasper/compiler Tag: latest_TOMCAT_30
                        Compiler.java JspCompiler.java
               src/share/org/apache/jasper/runtime Tag: latest_TOMCAT_30
                        JspLoader.java
  Log:
  performance fixes to the patch.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.3.2.5   +4 -4      jakarta-tomcat/src/share/org/apache/jasper/compiler/Compiler.java
  
  Index: Compiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/Compiler.java,v
  retrieving revision 1.3.2.4
  retrieving revision 1.3.2.5
  diff -u -r1.3.2.4 -r1.3.2.5
  --- Compiler.java	2000/02/14 00:10:52	1.3.2.4
  +++ Compiler.java	2000/03/27 17:11:22	1.3.2.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/Compiler.java,v 1.3.2.4 2000/02/14 00:10:52 mandar Exp $
  - * $Revision: 1.3.2.4 $
  - * $Date: 2000/02/14 00:10:52 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/Compiler.java,v 1.3.2.5 2000/03/27 17:11:22 mandar Exp $
  + * $Revision: 1.3.2.5 $
  + * $Date: 2000/03/27 17:11:22 $
    *
    * ====================================================================
    * 
  @@ -276,7 +276,7 @@
        * subclasses of Compiler. This is used by the compile method
        * to do all the compilation. 
        */
  -    protected abstract boolean isOutDated();
  +    public abstract boolean isOutDated();
       
       /**
        * Set java compiler info
  
  
  
  1.3.2.2   +47 -18    jakarta-tomcat/src/share/org/apache/jasper/compiler/JspCompiler.java
  
  Index: JspCompiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspCompiler.java,v
  retrieving revision 1.3.2.1
  retrieving revision 1.3.2.2
  diff -u -r1.3.2.1 -r1.3.2.2
  --- JspCompiler.java	2000/02/04 01:37:14	1.3.2.1
  +++ JspCompiler.java	2000/03/27 17:11:22	1.3.2.2
  @@ -90,8 +90,8 @@
           setMangler(this);
           computePackageName();
           computeClassFileName();
  -        computeClassFileData();
  -        computeJavaFileName();
  +        //computeClassFileData();
  +        //computeJavaFileName();
       }
   
       public final String getPackageName() {
  @@ -99,10 +99,14 @@
       }
       
       public final String getClassName() {
  +	if (className == null)
  +	    computeClassFileData();
           return className;
       }
   
       public final String getJavaFileName() {
  +	if (javaFileName == null)
  +	    computeJavaFileName();
           return javaFileName;
       }
       
  @@ -117,8 +121,27 @@
        *
        * Can (meant to) be overridden by subclasses of JspCompiler. 
        */
  -    protected boolean isOutDated() {
  -        return outDated;
  +    //protected boolean isOutDated() {
  +    //  return outDated;
  +    //}
  +    public boolean isOutDated() {
  +	
  +	ServletContext ctx = ctxt.getServletContext();
  +	File jspReal = null;
  +	
  +        if (ctx != null) 
  +            jspReal = new File(ctx.getRealPath(jsp.getPath()));
  +        else
  +            jspReal = jsp;
  +	
  +        File classFile = new File(classFileName);
  +        
  +        if (classFile.exists()) {
  +	    outDated = classFile.lastModified() < jspReal.lastModified();
  +	} else
  +	    outDated = true;
  +
  +	return outDated;
       }
   
       public static String [] keywords = { 
  @@ -184,7 +207,7 @@
       }
   
       public final void computeJavaFileName() {
  -	javaFileName = className + ".java";
  +	javaFileName = getClassName() + ".java";
   	if (outputDir != null && !outputDir.equals(""))
   	    javaFileName = outputDir + File.separatorChar + javaFileName;
       }
  @@ -252,7 +275,7 @@
   
   
       private final void computeClassFileData()
  -	throws JasperException
  +	//throws JasperException
       {
           ServletContext ctx = ctxt.getServletContext();
           
  @@ -280,15 +303,19 @@
   		// be computed only if someone ask for it.
   		cfd = new ClassFileData(outDated, classFileName, null);
   	    }
  -            String classNameFromFile = ClassName.getClassName(classFileName);
  -            String cn = cfd.getClassName();
  -            int lastDot = cn.lastIndexOf('.');
  -            if (lastDot != -1)
  -                className = cn.substring(lastDot+1,
  -                                         classNameFromFile.length());
  -            else
  -                className = cn;	    
  -        }
  +	    try {
  +		String classNameFromFile = ClassName.getClassName(classFileName);
  +		String cn = cfd.getClassName();
  +		int lastDot = cn.lastIndexOf('.');
  +		if (lastDot != -1)
  +		    className = cn.substring(lastDot+1,
  +					     classNameFromFile.length());
  +		else
  +		    className = cn;
  +	    } catch (JasperException ex) {
  +		ex.printStackTrace();
  +	    }
  +	}
       }
   }
   
  @@ -321,9 +348,9 @@
                                                     className.length())).intValue();
       }
   	
  -    public boolean isOutDated() {
  -        return outDated;
  -    }
  +    //public boolean isOutDated() {
  +    //  return outDated;
  +    //}
   	
       public String getClassName() {
           if(className==null)
  @@ -369,3 +396,5 @@
           }
       }
   }
  +
  +
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.2.4.2   +5 -4      jakarta-tomcat/src/share/org/apache/jasper/runtime/JspLoader.java
  
  Index: JspLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/runtime/JspLoader.java,v
  retrieving revision 1.2.4.1
  retrieving revision 1.2.4.2
  diff -u -r1.2.4.1 -r1.2.4.2
  --- JspLoader.java	2000/02/06 20:40:42	1.2.4.1
  +++ JspLoader.java	2000/03/27 17:11:23	1.2.4.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/runtime/JspLoader.java,v 1.2.4.1 2000/02/06 20:40:42 akv Exp $
  - * $Revision: 1.2.4.1 $
  - * $Date: 2000/02/06 20:40:42 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/runtime/JspLoader.java,v 1.2.4.2 2000/03/27 17:11:23 mandar Exp $
  + * $Revision: 1.2.4.2 $
  + * $Date: 2000/03/27 17:11:23 $
    *
    * ====================================================================
    * 
  @@ -224,7 +224,8 @@
           Compiler compiler = ctxt.createCompiler();
           
           try {
  -            outDated = compiler.compile();
  +	    if (jspClass == null || compiler.isOutDated())
  +		outDated = compiler.compile();
           } catch (FileNotFoundException ex) {
               throw ex;
           } catch (JasperException ex) {