costin 2003/02/06 14:06:34 Modified: catalina/src/share/org/apache/catalina/core StandardWrapper.java StandardWrapperValve.java Log: Merge few changes from 5.0. This only adds getters and setters and some more statistical info for the servlet execution. Revision Changes Path 1.45 +37 -6 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapper.java Index: StandardWrapper.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapper.java,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- StandardWrapper.java 10 Dec 2002 12:47:05 -0000 1.44 +++ StandardWrapper.java 6 Feb 2003 22:06:33 -0000 1.45 @@ -123,7 +123,8 @@ public StandardWrapper() { super(); - pipeline.setBasic(new StandardWrapperValve()); + swValve=new StandardWrapperValve(); + pipeline.setBasic(swValve); } @@ -172,6 +173,7 @@ */ private Servlet instance = null; + private StandardWrapperValve swValve; /** * The support object for our instance listeners. @@ -833,7 +835,6 @@ // Nothing to do if we already have an instance or an instance pool if (!singleThreadModel && (instance != null)) return instance; - PrintStream out = System.out; if (swallowOutput) { SystemLogHandler.startCapture(); @@ -1360,5 +1361,35 @@ } + public long getProcessingTime() { + return swValve.getProcessingTime(); + } + + public void setProcessingTime(long processingTime) { + swValve.setProcessingTime(processingTime); + } + + public long getMaxTime() { + return swValve.getMaxTime(); + } + + public void setMaxTime(long maxTime) { + swValve.setMaxTime(maxTime); + } + public int getRequestCount() { + return swValve.getRequestCount(); + } + + public void setRequestCount(int requestCount) { + swValve.setRequestCount(requestCount); + } + + public int getErrorCount() { + return swValve.getErrorCount(); + } + + public void setErrorCount(int errorCount) { + swValve.setErrorCount(errorCount); + } } 1.35 +50 -23 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java Index: StandardWrapperValve.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- StandardWrapperValve.java 15 Mar 2002 19:12:49 -0000 1.34 +++ StandardWrapperValve.java 6 Feb 2003 22:06:33 -0000 1.35 @@ -66,34 +66,22 @@ import java.io.IOException; -import java.io.PrintWriter; -import javax.servlet.FilterConfig; -import javax.servlet.RequestDispatcher; import javax.servlet.Servlet; -import javax.servlet.ServletContext; import javax.servlet.ServletException; -import javax.servlet.ServletOutputStream; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.UnavailableException; -import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.catalina.Container; import org.apache.catalina.Context; import org.apache.catalina.Globals; import org.apache.catalina.HttpRequest; -import org.apache.catalina.HttpResponse; import org.apache.catalina.Logger; import org.apache.catalina.Request; import org.apache.catalina.Response; import org.apache.catalina.ValveContext; -import org.apache.catalina.Wrapper; -import org.apache.catalina.deploy.ErrorPage; import org.apache.catalina.deploy.FilterDef; import org.apache.catalina.deploy.FilterMap; -import org.apache.catalina.util.InstanceSupport; -import org.apache.catalina.util.RequestUtil; import org.apache.catalina.util.StringManager; import org.apache.catalina.valves.ValveBase; @@ -124,6 +112,13 @@ */ private FilterDef filterDef = null; + // Some JMX statistics. This vavle is associated with a StandardWrapper. + // We exponse the StandardWrapper as JMX ( j2eeType=Servlet ). The fields + // are here for performance. + private long processingTime; + private long maxTime; + private int requestCount; + private int errorCount; /** * The descriptive information related to this implementation. @@ -169,7 +164,8 @@ public void invoke(Request request, Response response, ValveContext valveContext) throws IOException, ServletException { - + long t1=System.currentTimeMillis(); + requestCount++; // Initialize local variables we may need boolean unavailable = false; Throwable throwable = null; @@ -337,7 +333,10 @@ exception(request, response, e); } } - + long t2=System.currentTimeMillis(); + long time=t2-t1; + processingTime+=time; + if( time > maxTime ) maxTime=time; } @@ -465,7 +464,7 @@ */ private void exception(Request request, Response response, Throwable exception) { - + errorCount++; ServletRequest sreq = request.getRequest(); sreq.setAttribute(Globals.EXCEPTION_ATTR, exception); @@ -519,10 +518,8 @@ String containerName = null; if (container != null) containerName = container.getName(); - System.out.println("StandardWrapperValve[" + containerName - + "]: " + message); - System.out.println("" + throwable); - throwable.printStackTrace(System.out); + log( "StandardWrapperValve[" + containerName + + "]: " + message, throwable); } } @@ -608,5 +605,35 @@ } + public long getProcessingTime() { + return processingTime; + } + + public void setProcessingTime(long processingTime) { + this.processingTime = processingTime; + } + + public long getMaxTime() { + return maxTime; + } + public void setMaxTime(long maxTime) { + this.maxTime = maxTime; + } + + public int getRequestCount() { + return requestCount; + } + + public void setRequestCount(int requestCount) { + this.requestCount = requestCount; + } + + public int getErrorCount() { + return errorCount; + } + + public void setErrorCount(int errorCount) { + this.errorCount = errorCount; + } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]