You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ru...@locus.apache.org on 2000/02/23 10:44:37 UTC
cvs commit: jakarta-tomcat/src/share/org/apache/jasper/runtime JspServlet.java
rubys 00/02/23 01:44:37
Modified: src/share/org/apache/jasper/compiler Compiler.java
JspCompiler.java
src/share/org/apache/jasper/runtime JspServlet.java
Log:
Eliminate unnecessary calls to getClassName, which is implemented by
parsing the actual class file. Prior to this change, this method was
called twice even if the generated servlet was up to date!
Submitted by: Alex Cruikshank <al...@epitonic.com>
Revision Changes Path
1.13 +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.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Compiler.java 2000/02/13 06:25:24 1.12
+++ Compiler.java 2000/02/23 09:44:36 1.13
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/Compiler.java,v 1.12 2000/02/13 06:25:24 akv Exp $
- * $Revision: 1.12 $
- * $Date: 2000/02/13 06:25:24 $
+ * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/Compiler.java,v 1.13 2000/02/23 09:44:36 rubys Exp $
+ * $Revision: 1.13 $
+ * $Date: 2000/02/23 09:44:36 $
*
* ====================================================================
*
@@ -268,7 +268,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.7 +33 -24 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- JspCompiler.java 2000/02/07 07:51:18 1.6
+++ JspCompiler.java 2000/02/23 09:44:36 1.7
@@ -115,16 +115,6 @@
}
- /**
- * Return true if the .class file is outdated w.r.t
- * the JSP file.
- *
- * Can (meant to) be overridden by subclasses of JspCompiler.
- */
- protected boolean isOutDated() {
- return outDated;
- }
-
public static String [] keywords = {
"abstract", "boolean", "break", "byte",
"case", "catch", "char", "class",
@@ -188,7 +178,7 @@
}
public final void computeJavaFileName() {
- javaFileName = className + ".java";
+ javaFileName = getClassName() + ".java";
if (outputDir != null && !outputDir.equals(""))
javaFileName = outputDir + File.separatorChar + javaFileName;
}
@@ -254,9 +244,27 @@
return new String(result);
}
+ /**
+ * Determines whether the current JSP class is older than the JSP file
+ * from whence it came
+ */
+ public boolean isOutDated()
+ {
+ File jspReal = null;
+
+ jspReal = new File(ctxt.getRealPath(jsp.getPath()));
+
+ File classFile = new File(classFileName);
+ if (classFile.exists()) {
+ outDated = classFile.lastModified() < jspReal.lastModified();
+ } else {
+ outDated = true;
+ }
+ return outDated;
+ }
+
private final void computeClassFileData()
- throws JasperException
{
File jspReal = null;
@@ -282,14 +290,19 @@
} else {
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,10 +334,6 @@
= Integer.valueOf(className.substring(className.lastIndexOf(Constants.JSP_TOKEN)+
Constants.JSP_TOKEN.length(),
className.length())).intValue();
- }
-
- public boolean isOutDated() {
- return outDated;
}
public String getClassName() {
1.17 +7 -1 jakarta-tomcat/src/share/org/apache/jasper/runtime/JspServlet.java
Index: JspServlet.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/runtime/JspServlet.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- JspServlet.java 2000/02/13 06:25:25 1.16
+++ JspServlet.java 2000/02/23 09:44:37 1.17
@@ -392,7 +392,7 @@
* @param classpath explicitly set the JSP compilation path.
* @return true if JSP files is newer
*/
- public synchronized boolean loadJSP(String name, String classpath,
+ public boolean loadJSP(String name, String classpath,
boolean isErrorPage, HttpServletRequest req, HttpServletResponse res)
throws JasperException, FileNotFoundException
{
@@ -409,6 +409,12 @@
try {
outDated = compiler.compile();
+ if ((jspClass == null) || (compiler.isOutDated())) {
+ synchronized ( this ) {
+ if ((jspClass == null) || (compiler.isOutDated() ))
+ outDated = compiler.compile();
+ }
+ }
} catch (FileNotFoundException ex) {
throw ex;
} catch (JasperException ex) {