You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2003/05/27 00:04:00 UTC

cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core ContainerBase.java StandardContext.java StandardContextValve.java StandardEngineValve.java StandardHostValve.java StandardPipeline.java StandardValveContext.java StandardWrapperValve.java

remm        2003/05/26 15:03:59

  Modified:    catalina/src/share/org/apache/catalina/core
                        ContainerBase.java StandardContext.java
                        StandardContextValve.java StandardEngineValve.java
                        StandardHostValve.java StandardPipeline.java
                        StandardValveContext.java StandardWrapperValve.java
  Log:
  - Remove some useless casts.
  - Make final the methods in the Catalina architecture which are not meant
    to be overridden, such as StdPipeline.invoke.
  
  Revision  Changes    Path
  1.25      +1 -1      jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ContainerBase.java
  
  Index: ContainerBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ContainerBase.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- ContainerBase.java	23 May 2003 10:54:35 -0000	1.24
  +++ ContainerBase.java	26 May 2003 22:03:59 -0000	1.25
  @@ -968,7 +968,7 @@
        * @exception ServletException if a ServletException was thrown
        *  while processing this request
        */
  -    public void invoke(Request request, Response response)
  +    public final void invoke(Request request, Response response)
           throws IOException, ServletException {
   
           pipeline.invoke(request, response);
  
  
  
  1.61      +2 -45     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java
  
  Index: StandardContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- StandardContext.java	25 May 2003 14:27:01 -0000	1.60
  +++ StandardContext.java	26 May 2003 22:03:59 -0000	1.61
  @@ -122,7 +122,6 @@
   import org.apache.catalina.util.ExtensionValidator;
   import org.apache.catalina.util.RequestUtil;
   
  -import org.apache.tomcat.util.log.SystemLogHandler;
   import org.apache.commons.modeler.Registry;
   import org.apache.commons.modeler.ManagedBean;
   import org.apache.commons.logging.Log;
  @@ -2697,48 +2696,6 @@
   
   
       /**
  -     * Process the specified Request, and generate the corresponding Response,
  -     * according to the design of this particular Container.
  -     *
  -     * @param request Request to be processed
  -     * @param response Response to be produced
  -     *
  -     * @exception IOException if an input/output error occurred while
  -     *  processing
  -     * @exception ServletException if a ServletException was thrown
  -     *  while processing this request
  -     */
  -    public void invoke(Request request, Response response)
  -        throws IOException, ServletException {
  -
  -        // Wait if we are reloading
  -        while (getPaused()) {
  -            try {
  -                Thread.sleep(1000);
  -            } catch (InterruptedException e) {
  -                ;
  -            }
  -        }
  -
  -        // Normal request processing
  -        if (swallowOutput) {
  -            try {
  -                SystemLogHandler.startCapture();
  -                super.invoke(request, response);
  -            } finally {
  -                String log = SystemLogHandler.stopCapture();
  -                if (log != null && log.length() > 0) {
  -                    log(log);
  -                }
  -            }
  -        } else {
  -            super.invoke(request, response);
  -        }
  -
  -    }
  -
  -
  -    /**
        * Reload this web application, if reloading is supported.
        * <p>
        * <b>IMPLEMENTATION NOTE</b>:  This method is designed to deal with
  @@ -4602,7 +4559,7 @@
       /**
        * Return the request processing paused flag for this Context.
        */
  -    private boolean getPaused() {
  +    public boolean getPaused() {
   
           return (this.paused);
   
  
  
  
  1.7       +36 -13    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContextValve.java
  
  Index: StandardContextValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContextValve.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StandardContextValve.java	19 May 2003 22:45:24 -0000	1.6
  +++ StandardContextValve.java	26 May 2003 22:03:59 -0000	1.7
  @@ -89,6 +89,10 @@
   import org.apache.catalina.util.StringManager;
   import org.apache.catalina.valves.ValveBase;
   
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +
  +import org.apache.tomcat.util.log.SystemLogHandler;
   
   /**
    * Valve that implements the default basic behavior for the
  @@ -122,6 +126,9 @@
           StringManager.getManager(Constants.Package);
   
   
  +    private static Log log = LogFactory.getLog(StandardContextValve.class);
  +
  +
       // ------------------------------------------------------------- Properties
   
   
  @@ -150,16 +157,10 @@
        * @exception IOException if an input/output error occurred
        * @exception ServletException if a servlet error occurred
        */
  -    public void invoke(Request request, Response response,
  -                       ValveContext valveContext)
  +    public final void invoke(Request request, Response response,
  +                             ValveContext valveContext)
           throws IOException, ServletException {
   
  -        // Validate the request and response object types
  -        if (!(request.getRequest() instanceof HttpServletRequest) ||
  -            !(response.getResponse() instanceof HttpServletResponse)) {
  -            return;     // NOTE - Not much else we can do generically
  -        }
  -
           // Disallow any direct access to resources under WEB-INF or META-INF
           HttpRequest hreq = (HttpRequest) request;
           MessageBytes requestPathMB = hreq.getRequestPathMB();
  @@ -172,6 +173,15 @@
               return;
           }
   
  +        // Wait if we are reloading
  +        while (((StandardContext) container).getPaused()) {
  +            try {
  +                Thread.sleep(1000);
  +            } catch (InterruptedException e) {
  +                ;
  +            }
  +        }
  +
           // Select the Wrapper to be used for this Request
           Wrapper wrapper = request.getWrapper();
           if (wrapper == null) {
  @@ -180,7 +190,20 @@
               return;
           }
   
  -        wrapper.invoke(request, response);
  +        // Normal request processing
  +        if (((StandardContext) container).getSwallowOutput()) {
  +            try {
  +                SystemLogHandler.startCapture();
  +                wrapper.invoke(request, response);
  +            } finally {
  +                String log = SystemLogHandler.stopCapture();
  +                if (log != null && log.length() > 0) {
  +                    container.getLogger().log(log);
  +                }
  +            }
  +        } else {
  +            wrapper.invoke(request, response);
  +        }
   
       }
   
  
  
  
  1.4       +6 -6      jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardEngineValve.java
  
  Index: StandardEngineValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardEngineValve.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StandardEngineValve.java	19 May 2003 22:45:24 -0000	1.3
  +++ StandardEngineValve.java	26 May 2003 22:03:59 -0000	1.4
  @@ -138,8 +138,8 @@
        * @exception IOException if an input/output error occurred
        * @exception ServletException if a servlet error occurred
        */
  -    public void invoke(Request request, Response response,
  -                       ValveContext valveContext)
  +    public final void invoke(Request request, Response response,
  +                             ValveContext valveContext)
           throws IOException, ServletException {
   
           // Select the Host to be used for this Request
  
  
  
  1.5       +6 -6      jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardHostValve.java
  
  Index: StandardHostValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardHostValve.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StandardHostValve.java	19 May 2003 22:45:24 -0000	1.4
  +++ StandardHostValve.java	26 May 2003 22:03:59 -0000	1.5
  @@ -140,8 +140,8 @@
        * @exception IOException if an input/output error occurred
        * @exception ServletException if a servlet error occurred
        */
  -    public void invoke(Request request, Response response,
  -                       ValveContext valveContext)
  +    public final void invoke(Request request, Response response,
  +                             ValveContext valveContext)
           throws IOException, ServletException {
   
           // Select the Context to be used for this Request
  
  
  
  1.12      +5 -5      jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardPipeline.java
  
  Index: StandardPipeline.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardPipeline.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- StandardPipeline.java	13 May 2003 08:39:13 -0000	1.11
  +++ StandardPipeline.java	26 May 2003 22:03:59 -0000	1.12
  @@ -102,7 +102,7 @@
    * @author Craig R. McClanahan
    */
   
  -public class StandardPipeline
  +public final class StandardPipeline
       implements Pipeline, Contained, Lifecycle 
    {
       private static Log log = LogFactory.getLog(StandardPipeline.class);
  @@ -545,7 +545,7 @@
        * @exception IOException if an input/output error occurs
        * @exception ServletException if a servlet exception is thrown
        */
  -    public void invoke(Request request, Response response)
  +    public final void invoke(Request request, Response response)
           throws IOException, ServletException {
   
           // Invoke the first Valve in this pipeline for this request
  
  
  
  1.2       +5 -5      jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardValveContext.java
  
  Index: StandardValveContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardValveContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StandardValveContext.java	25 Nov 2002 21:03:50 -0000	1.1
  +++ StandardValveContext.java	26 May 2003 22:03:59 -0000	1.2
  @@ -81,7 +81,7 @@
    * @author Remy Maucherat
    */
   
  -public class StandardValveContext
  +public final class StandardValveContext
       implements ValveContext {
   
   
  @@ -138,7 +138,7 @@
        * @exception ServletException if there are no further Valves 
        *  configured in the Pipeline currently being processed
        */
  -    public void invokeNext(Request request, Response response)
  +    public final void invokeNext(Request request, Response response)
           throws IOException, ServletException {
   
           int subscript = stage;
  
  
  
  1.15      +18 -25    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java
  
  Index: StandardWrapperValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- StandardWrapperValve.java	26 Mar 2003 21:57:59 -0000	1.14
  +++ StandardWrapperValve.java	26 May 2003 22:03:59 -0000	1.15
  @@ -134,8 +134,8 @@
        * @exception IOException if an input/output error occurred
        * @exception ServletException if a servlet error occurred
        */
  -    public void invoke(Request request, Response response,
  -                       ValveContext valveContext)
  +    public final void invoke(Request request, Response response,
  +                             ValveContext valveContext)
           throws IOException, ServletException {
   
           // Initialize local variables we may need
  @@ -145,18 +145,11 @@
           long t1=System.currentTimeMillis();
           requestCount++;
           StandardWrapper wrapper = (StandardWrapper) getContainer();
  -        HttpRequest hrequest = null;
  -        if (request instanceof HttpRequest)
  -            hrequest = (HttpRequest) request;
  -        ServletRequest sreq = request.getRequest();
  -        ServletResponse sres = response.getResponse();
  +        HttpRequest hrequest = (HttpRequest) request;
           Servlet servlet = null;
  -        HttpServletRequest hreq = null;
  -        if (sreq instanceof HttpServletRequest)
  -            hreq = (HttpServletRequest) sreq;
  -        HttpServletResponse hres = null;
  -        if (sres instanceof HttpServletResponse)
  -            hres = (HttpServletResponse) sres;
  +        HttpServletRequest hreq = (HttpServletRequest) request.getRequest();
  +        HttpServletResponse hres = 
  +            (HttpServletResponse) response.getResponse();
   
           // Check for the application being marked unavailable
           if (!((Context) wrapper.getParent()).getAvailable()) {
  @@ -222,7 +215,7 @@
           try {
               response.sendAcknowledgement();
           } catch (IOException e) {
  -            sreq.removeAttribute(Globals.JSP_FILE_ATTR);
  +            hreq.removeAttribute(Globals.JSP_FILE_ATTR);
               log.error(sm.getString("standardWrapper.acknowledgeException",
                                wrapper.getName()), e);
               throwable = e;
  @@ -238,10 +231,10 @@
           if (hreq != null) {
               requestPathMB = hrequest.getRequestPathMB();
           }
  -        sreq.setAttribute
  +        hreq.setAttribute
               (ApplicationFilterFactory.DISPATCHER_TYPE_ATTR,
                ApplicationFilterFactory.REQUEST_INTEGER);
  -        sreq.setAttribute
  +        hreq.setAttribute
               (ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR, 
                requestPathMB);
           // Create the filter chain for this request
  @@ -256,21 +249,21 @@
           try {
               String jspFile = wrapper.getJspFile();
               if (jspFile != null)
  -                sreq.setAttribute(Globals.JSP_FILE_ATTR, jspFile);
  +                hreq.setAttribute(Globals.JSP_FILE_ATTR, jspFile);
               else
  -                sreq.removeAttribute(Globals.JSP_FILE_ATTR);
  +                hreq.removeAttribute(Globals.JSP_FILE_ATTR);
               if ((servlet != null) && (filterChain != null)) {
  -                filterChain.doFilter(sreq, sres);
  +                filterChain.doFilter(hreq, hres);
               }
  -            sreq.removeAttribute(Globals.JSP_FILE_ATTR);
  +            hreq.removeAttribute(Globals.JSP_FILE_ATTR);
           } catch (IOException e) {
  -            sreq.removeAttribute(Globals.JSP_FILE_ATTR);
  +            hreq.removeAttribute(Globals.JSP_FILE_ATTR);
               log.error(sm.getString("standardWrapper.serviceException",
                                wrapper.getName()), e);
               throwable = e;
               exception(request, response, e);
           } catch (UnavailableException e) {
  -            sreq.removeAttribute(Globals.JSP_FILE_ATTR);
  +            hreq.removeAttribute(Globals.JSP_FILE_ATTR);
               log.error(sm.getString("standardWrapper.serviceException",
                                wrapper.getName()), e);
               //            throwable = e;
  @@ -290,13 +283,13 @@
               // Do not save exception in 'throwable', because we
               // do not want to do exception(request, response, e) processing
           } catch (ServletException e) {
  -            sreq.removeAttribute(Globals.JSP_FILE_ATTR);
  +            hreq.removeAttribute(Globals.JSP_FILE_ATTR);
               log.error(sm.getString("standardWrapper.serviceException",
                                wrapper.getName()), e);
               throwable = e;
               exception(request, response, e);
           } catch (Throwable e) {
  -            sreq.removeAttribute(Globals.JSP_FILE_ATTR);
  +            hreq.removeAttribute(Globals.JSP_FILE_ATTR);
               log.error(sm.getString("standardWrapper.serviceException",
                                wrapper.getName()), e);
               throwable = e;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org