vgritsenko    01/07/27 11:35:29

  Modified:    webapp/WEB-INF web.xml
               src/org/apache/cocoon/servlet CocoonServlet.java
  Log:
  Add configuration parameter to web.xml to show processing time (like in Cocoon 1.8).
  cocoon-showtime request parameter takes precedence over web.xml parameter.
  
  Revision  Changes    Path
  1.7       +16 -6     xml-cocoon2/webapp/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/webapp/WEB-INF/web.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- web.xml   2001/07/19 18:33:34     1.6
  +++ web.xml   2001/07/27 18:35:29     1.7
  @@ -19,11 +19,10 @@
       <description>The main Cocoon2 servlet</description>
   
       <!--
  -      In cases you're facing class loader problems you can alternatively 
  +      In cases you're facing class loader problems you can alternatively
         use the following servlet-class instead of the normal one
   
         <servlet-class>org.apache.cocoon.servlet.ParanoidCocoonServlet</servlet-class>
  -  
       -->
       <servlet-class>org.apache.cocoon.servlet.CocoonServlet</servlet-class>
   
  @@ -148,12 +147,12 @@
         <param-value>/WEB-INF/work</param-value>
       </init-param>
       -->
  -  
  -    <!-- 
  -      This parameter allows to specify additional directories or jars 
  +
  +    <!--
  +      This parameter allows to specify additional directories or jars
         which Cocoon should put into it's own classpath.
         Note that you must separate them using the platforms path.separator
  -      (":" for *nix and ";" for Windows systems). Also not that absolute 
  +      (":" for *nix and ";" for Windows systems). Also note that absolute
         pathes are take as such but relative pathes are rooted at the context
         root of the Cocoon servlet.
   
  @@ -168,6 +167,17 @@
         of your servlet engine.
       -->
       <load-on-startup>1</load-on-startup>
  +
  +    <!-- 
  +      If you set this parameter to 'true' or 'yes', Cocoon will add processing
  +      time to the end of each response. Value 'hide' adds processing as an HTML
  +      comment. By default, processing time is not added (corresponds to value 'no').
  +
  +    <init-param>
  +      <param-name>show-time</param-name>
  +      <param-value>hide</param-value>
  +    </init-param>
  +    -->
     </servlet>
   
     <servlet-mapping>
  
  
  
  1.24      +28 -14    xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- CocoonServlet.java        2001/07/24 09:34:08     1.23
  +++ CocoonServlet.java        2001/07/27 18:35:29     1.24
  @@ -62,7 +62,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a> Aisa
    * @author <a href="mailto:[EMAIL PROTECTED]";>Berin Loritsch</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.23 $ $Date: 2001/07/24 09:34:08 $
  + * @version CVS $Revision: 1.24 $ $Date: 2001/07/27 18:35:29 $
    */
   
   public class CocoonServlet extends HttpServlet {
  @@ -86,6 +86,10 @@
       /** Allow reloading of cocoon by specifying the cocoon-reload parameter with a 
request */
       protected boolean allowReload;
   
  +    /** Allow adding processing time to the response */
  +    protected boolean showTime;
  +    protected boolean hiddenShowTime;
  +
       private static final boolean ALLOW_OVERWRITE = false;
       private static final boolean SILENTLY_RENAME = true;
       private static final boolean SAVE_UPLOADED_FILES_TO_DISK = true;
  @@ -162,6 +166,9 @@
           String value = conf.getInitParameter("allow-reload");
           this.allowReload = (value == null || value.equals("yes") || 
value.equals("true"));
   
  +        value = conf.getInitParameter("show-time");
  +        this.showTime = "yes".equals(value) || "true".equals(value)
  +            || (this.hiddenShowTime = "hide".equals(value));
           this.createCocoon();
       }
   
  @@ -480,6 +487,7 @@
               return;
           }
   
  +        boolean processed = false;
           try {
               if (uri.charAt(0) == '/') {
                   uri = uri.substring(1);
  @@ -496,7 +504,9 @@
               // Add the object model
               ctxStack.push(env.getObjectModel());
   
  -            if (!this.cocoon.process(env)) {
  +            if (this.cocoon.process(env)) {
  +                processed = true;
  +            } else {
   
                   // means SC_NOT_FOUND
                   res.setStatus(res.SC_NOT_FOUND);
  @@ -560,25 +570,29 @@
               res.setContentType(Notifier.notify(n, res.getOutputStream()));
           }
   
  -        ServletOutputStream out = res.getOutputStream();
  -
           long end = new Date().getTime();
           String timeString = processTime(end - start);
           log.info("'" + uri + "' " + timeString);
  -
  -        String showTime = request.getParameter(Constants.SHOWTIME_PARAM);
   
  -        if ((showTime != null) && !showTime.equalsIgnoreCase("no")) {
  -            boolean hide = showTime.equalsIgnoreCase("hide");
  -            out.print((hide) ? "<!-- " : "<p>");
  +        if (processed) {
  +            ServletOutputStream out = res.getOutputStream();
   
  -            out.print(timeString);
  +            String showTime = request.getParameter(Constants.SHOWTIME_PARAM);
  +            boolean show = this.showTime;
  +            if (showTime != null)
  +                show = !showTime.equalsIgnoreCase("no");
  +            if (show) {
  +                boolean hide = this.hiddenShowTime;
  +                if(showTime != null)
  +                    hide = showTime.equalsIgnoreCase("hide");
  +                out.print((hide) ? "<!-- " : "<p>");
  +                out.print(timeString);
  +                out.println((hide) ? " -->" : "</p>");
  +            }
   
  -            out.println((hide) ? " -->" : "</p>");
  +            out.flush();
  +            out.close();
           }
  -
  -        out.flush();
  -        out.close();
       }
   
       /**
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to