You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2001/01/21 00:25:45 UTC
cvs commit: jakarta-tomcat/src/facade22/org/apache/tomcat/facade JspInterceptor.java ServletHandler.java
costin 01/01/20 15:25:45
Modified: src/admin/WEB-INF/classes/tadm GTestTag.java
src/admin/test test.jsp
src/facade22/org/apache/tomcat/facade JspInterceptor.java
ServletHandler.java
Log:
- accept a "target" request parameter ( to run a subset of the tests )
- make sure the context logs go to the context log
- added (the initial) code to support using JspServlet as an option.
( that is turned now on by default - will change after this is tested
and finished )
XXX missing - add code to support setting all options supported by jasper,
in both cases - JspServlet params or the TomcatOptions for interceptor-only.
Revision Changes Path
1.3 +4 -2 jakarta-tomcat/src/admin/WEB-INF/classes/tadm/GTestTag.java
Index: GTestTag.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/admin/WEB-INF/classes/tadm/GTestTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- GTestTag.java 2001/01/20 21:50:23 1.2
+++ GTestTag.java 2001/01/20 23:25:44 1.3
@@ -74,6 +74,7 @@
/** Set the target - a subset of tests to be run
*/
public void setTarget( String s ) {
+ System.out.println("Setting target " + s );
target=s;
}
@@ -89,8 +90,9 @@
private void runTest( String base) throws IOException {
PrintWriter out=pageContext.getResponse().getWriter();
try {
- System.out.println("RUN TEST " + base + " " + testFileName + " "
- + target );
+ out.flush();
+ out.println("Running test " + base + " " + testFileName + " "
+ + target + "</br>" );
File testFile=new File( base + testFileName);
1.2 +2 -1 jakarta-tomcat/src/admin/test/test.jsp
Index: test.jsp
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/admin/test/test.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- test.jsp 2001/01/20 21:50:23 1.1
+++ test.jsp 2001/01/20 23:25:44 1.2
@@ -15,9 +15,10 @@
action="setLogger"
value="webapps/test/context_log.txt" />
+
<adm:gtest testFile="WEB-INF/test-tomcat.xml"
testApp="/test"
- target="file" />
+ target='<%= request.getParameter("target") %>' />
1.6 +45 -3 jakarta-tomcat/src/facade22/org/apache/tomcat/facade/JspInterceptor.java
Index: JspInterceptor.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/JspInterceptor.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JspInterceptor.java 2001/01/20 21:33:04 1.5
+++ JspInterceptor.java 2001/01/20 23:25:44 1.6
@@ -85,10 +85,20 @@
*/
public class JspInterceptor extends BaseInterceptor {
TomcatOptions options=new TomcatOptions();
-
+ boolean useJspServlet=true;
+
static final String JIKES="org.apache.jasper.compiler.JikesJavaCompiler";
// -------------------- Configurable properties --------------------
+
+ /** Use the old JspServlet to execute Jsps, instead of the
+ new code. Note that init() never worked (AFAIK) and it'll
+ be slower - but given the stability of JspServlet it may
+ be a safe option
+ */
+ public void setUseJspServlet( boolean b ) {
+ useJspServlet=b;
+ }
public void setJavaCompiler( String type ) {
// shortcut
@@ -186,6 +196,33 @@
return 0;
}
+ if( useJspServlet ) {
+ ServletHandler jspServlet=(ServletHandler)wrapper;
+ if( ! "jsp".equals( jspServlet.getServletClassName()) )
+ return 0; // it's all set, the JspServlet will do the job.
+
+ if( debug > 0 ) {
+ log( "Using jsp servlet !");
+ //enable jasperServlet logging
+ org.apache.jasper.Constants.jasperLog=
+ org.apache.tomcat.util.log.Logger.getDefaultLogger();
+ org.apache.jasper.Constants.jasperLog.
+ setVerbosityLevel("debug");
+ }
+
+ // it's the first time a jsp is invoked, the jspServlet
+ // is not setup
+ jspServlet.
+ setServletClassName("org.apache.jasper.servlet.JspServlet");
+
+ // XXX set the options
+ // jspServlet.getServletInfo().addInitParam("jspCompilerPlugin",
+ // "org.apache.jasper.compiler.JikesJavaCompiler");
+ return 0;
+ // nothing else happens during request map
+ // XXX this can be done at context add time
+ }
+
ServletHandler handler=null;
String jspFile=null;
@@ -342,7 +379,8 @@
dep.setLastModified( System.currentTimeMillis() );
// Update the class name in wrapper
- log.log( "Update class Name " + mangler.getServletClassName());
+ if( debug> 1 )
+ log.log( "Update class Name " + mangler.getServletClassName());
handler.setServletClassName( mangler.getServletClassName() );
compile( handler, req, mangler );
@@ -389,7 +427,11 @@
if(debug>0)log.log( "Generated " + mangler.getClassFileName() );
} catch( Exception ex ) {
- log.log("compile: req="+req, ex);
+ Context ctx=req.getContext();
+ if( ctx!=null )
+ ctx.log("compile error: req="+req, ex);
+ else
+ log.log("compile error: req="+req, ex);
wrapper.setErrorException(ex);
wrapper.setState(Handler.STATE_DISABLED);
// until the jsp cahnges, when it'll be enabled again
1.12 +39 -10 jakarta-tomcat/src/facade22/org/apache/tomcat/facade/ServletHandler.java
Index: ServletHandler.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/ServletHandler.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ServletHandler.java 2000/12/28 01:15:37 1.11
+++ ServletHandler.java 2001/01/20 23:25:44 1.12
@@ -190,7 +190,11 @@
try {
doDestroy();
} catch( Exception ex ) {
- log( "Error during destroy ", ex );
+ if( context!=null )
+ context.log( "Error during destroy ", ex );
+ else
+ log( "Error during destroy ", ex );
+
}
@@ -228,7 +232,11 @@
// preInit may either throw exception or setState DELAYED_INIT
} catch( Exception ex ) {
// save error, assume permanent
- log("Exception in preInit " + ex.getMessage(), ex );
+ if(context!=null)
+ context.log("Exception in preInit " +
+ ex.getMessage(), ex );
+ else
+ log("Exception in preInit " + ex.getMessage(), ex );
setErrorException(ex);
setState(STATE_DISABLED);
return;
@@ -258,7 +266,10 @@
// if success, we are ready to serve
} catch( Exception ex ) {
// save error, assume permanent
- log("Exception in init " + ex.getMessage(), ex );
+ if( context!=null )
+ context.log("Exception in init " + ex.getMessage(), ex );
+ else
+ log("Exception in init " + ex.getMessage(), ex );
setErrorException(ex);
state=STATE_DISABLED;
}
@@ -295,7 +306,10 @@
try {
destroy();
} catch(Exception ex ) {
- log( "Error in destroy ", ex );
+ if( context!=null )
+ context.log( "Error in destroy ", ex );
+ else
+ log( "Error in destroy ", ex );
}
}
@@ -359,7 +373,10 @@
}
} catch(Exception ex) {
// Should never come here...
- log( "Error in destroy ", ex );
+ if( context!=null)
+ context.log( "Error in destroy ", ex );
+ else
+ log( "Error in destroy ", ex );
}
}
}
@@ -523,8 +540,12 @@
res.setHeader("Retry-After", Integer.toString(unavailableTime));
}
String msg=t.getMessage();
- log( "UnavailableException in: " + req +
- ", time remaining " + unavailableTime + " seconds : " + msg, t);
+ String logMsg="UnavailableException in: " + req +
+ ", time remaining " + unavailableTime + " seconds : " + msg;
+ if( context!=null)
+ context.log( logMsg, t);
+ else
+ log( logMsg, t);
req.setAttribute("javax.servlet.error.message", msg );
req.setAttribute("tomcat.servlet.error.service.unavailableTime", new Integer(unavailableTime));
contextM.handleStatus( req, res, HttpServletResponse.SC_SERVICE_UNAVAILABLE );
@@ -578,8 +599,12 @@
// disable the error - it expired
unavailableTime=-1;
setErrorException(null);
- log(getName() +
- " unavailable time expired, trying again ");
+ if( context!=null)
+ context.log(getName() +
+ " unavailable time expired, trying again ");
+ else
+ log(getName() +
+ " unavailable time expired, trying again ");
return true;
}
// still unavailable
@@ -602,7 +627,11 @@
// disable the error - it expired
setErrorException(null);
unavailableTime=-1;
- log(getName() +
+ if( context!=null)
+ context.log(getName() +
+ " unavailable time expired, trying again ");
+ else
+ log(getName() +
" unavailable time expired, trying again ");
}
return true;