remm        2003/03/24 04:46:39

  Modified:    catalina/src/share/org/apache/catalina/servlets
                        StatusManagerServlet.java
  Log:
  - Update to XML (and see if Costin complians). The XML is readable enough
    for a human anyway.
  - Use client side XSL for HTML clients.
  - Partially submitted by Tim Funk.
  
  Revision  Changes    Path
  1.4       +68 -79    
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/servlets/StatusManagerServlet.java
  
  Index: StatusManagerServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/servlets/StatusManagerServlet.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StatusManagerServlet.java 23 Mar 2003 18:10:07 -0000      1.3
  +++ StatusManagerServlet.java 24 Mar 2003 12:46:39 -0000      1.4
  @@ -234,10 +234,14 @@
                         HttpServletResponse response)
           throws IOException, ServletException {
   
  -        response.setContentType("text/html");
  +        response.setContentType("text/xml");
   
           PrintWriter writer = response.getWriter();
   
  +        writer.write("<?xml version=\"1.0\"?>");
  +        writer.write
  +            ("<?xml-stylesheet type=\"text/xsl\" href=\"xform.xsl\" ?>");
  +        writer.write("<status>");
           try {
   
               // Display virtual machine statistics
  @@ -253,6 +257,7 @@
           } catch (Exception e) {
               e.printStackTrace();
           }
  +        writer.write("</status>");
   
       }
   
  @@ -263,17 +268,14 @@
       protected void writeVMState(PrintWriter writer)
           throws Exception {
   
  -        writer.print("<h1>JVM</h1>");
  -        writer.print("<br/>");
  +        writer.write("<jvm>");
   
  -        writer.print(" Free memory: ");
  -        writer.print(Runtime.getRuntime().freeMemory());
  -        writer.print(" Total memory: ");
  -        writer.print(Runtime.getRuntime().totalMemory());
  -        writer.print(" Max memory: ");
  -        writer.print(Runtime.getRuntime().maxMemory());
  +        writer.write("<memory");
  +        writer.write(" free='" + Runtime.getRuntime().freeMemory() + "'");
  +        writer.write(" total='" + Runtime.getRuntime().totalMemory() + "'");
  +        writer.write(" max='" + Runtime.getRuntime().maxMemory() + "'/>");
   
  -        writer.print("<br/>");
  +        writer.write("</jvm>");
   
       }
   
  @@ -285,24 +287,15 @@
                                          ObjectName tpName, String name)
           throws Exception {
   
  -        writer.print("<h1>");
  -        writer.print(name);
  -        writer.print("</h1>");
  -
  -        writer.print("<br/>");
  -
  -        writer.print(" Max threads: ");
  -        writer.print(mBeanServer.getAttribute(tpName, "maxThreads"));
  -        writer.print(" Min spare threads: ");
  -        writer.print(mBeanServer.getAttribute(tpName, "minSpareThreads"));
  -        writer.print(" Max spare threads: ");
  -        writer.print(mBeanServer.getAttribute(tpName, "maxSpareThreads"));
  -        writer.print(" Current thread count: ");
  -        writer.print(mBeanServer.getAttribute(tpName, "currentThreadCount"));
  -        writer.print(" Current thread busy: ");
  -        writer.print(mBeanServer.getAttribute(tpName, "currentThreadsBusy"));
  +        writer.write("<connector name='" + name + "'>");
   
  -        writer.print("<br/>");
  +        writer.write("<threadInfo ");
  +        writer.write(" maxThreads=\"" + mBeanServer.getAttribute(tpName, 
"maxThreads") + "\"");
  +        writer.write(" minSpareThreads=\"" + mBeanServer.getAttribute(tpName, 
"minSpareThreads") + "\"");
  +        writer.write(" maxSpareThreads=\"" + mBeanServer.getAttribute(tpName, 
"maxSpareThreads") + "\"");
  +        writer.write(" currentThreadCount=\"" + mBeanServer.getAttribute(tpName, 
"currentThreadCount") + "\"");
  +        writer.write(" currentThreadsBusy=\"" + mBeanServer.getAttribute(tpName, 
"currentThreadsBusy") + "\"");
  +        writer.write(" />");
   
           ObjectName grpName = null;
   
  @@ -314,38 +307,32 @@
               }
           }
   
  -        if (grpName == null) {
  -            return;
  -        }
  -
  -        writer.print(" Max processing time: ");
  -        writer.print(mBeanServer.getAttribute(grpName, "maxTime"));
  -        writer.print(" Processing time:");
  -        writer.print(mBeanServer.getAttribute(grpName, "processingTime"));
  -        writer.print(" Request count: ");
  -        writer.print(mBeanServer.getAttribute(grpName, "requestCount"));
  -        writer.print(" Error count: ");
  -        writer.print(mBeanServer.getAttribute(grpName, "errorCount"));
  -        writer.print(" Bytes received: ");
  -        writer.print(mBeanServer.getAttribute(grpName, "bytesReceived"));
  -        writer.print(" Bytes sent: ");
  -        writer.print(mBeanServer.getAttribute(grpName, "bytesSent"));
  +        if (grpName != null) {
   
  -        writer.print("<br/>");
  +            writer.write("<requestInfo ");
  +            writer.write(" maxTime=\"" + mBeanServer.getAttribute(grpName, 
"maxTime") + "\"");
  +            writer.write(" processingTime=\"" + mBeanServer.getAttribute(grpName, 
"processingTime") + "\"");
  +            writer.write(" requestCount=\"" + mBeanServer.getAttribute(grpName, 
"requestCount") + "\"");
  +            writer.write(" errorCount=\"" + mBeanServer.getAttribute(grpName, 
"errorCount") + "\"");
  +            writer.write(" bytesReceived=\"" + mBeanServer.getAttribute(grpName, 
"bytesReceived") + "\"");
  +            writer.write(" bytesSent=\"" + mBeanServer.getAttribute(grpName, 
"bytesSent") + "\"");
  +            writer.write(" />");
   
  -        writer.print("<table border=\"0\"><tr><th>Stage</th><th>Time</th><th>B 
Sent</th><th>B Recv</th><th>Client</th><th>VHost</th><th>Request</th></tr>");
   
  -        enum = requestProcessors.elements();
  -        while (enum.hasMoreElements()) {
  -            ObjectName objectName = (ObjectName) enum.nextElement();
  -            if (name.equals(objectName.getKeyProperty("worker"))) {
  -                writer.print("<tr>");
  -                writeProcessorState(writer, objectName);
  -                writer.print("</tr>");
  +            writer.write("<workers>");
  +            enum = requestProcessors.elements();
  +            while (enum.hasMoreElements()) {
  +                ObjectName objectName = (ObjectName) enum.nextElement();
  +                if (name.equals(objectName.getKeyProperty("worker"))) {
  +                    writer.write("<worker>");
  +                    writeProcessorState(writer, objectName);
  +                    writer.write("</worker>");
  +                }
               }
  +            writer.write("</workers>");
           }
   
  -        writer.print("</table>");
  +        writer.write("</connector>");
   
       }
   
  @@ -356,13 +343,13 @@
       protected void writeProcessorState(PrintWriter writer, ObjectName pName)
           throws Exception {
   
  -        Integer stageValue = 
  +        Integer stageValue =
               (Integer) mBeanServer.getAttribute(pName, "stage");
           int stage = stageValue.intValue();
           boolean fullStatus = true;
   
  -        writer.write("<td><b>");
   
  +        writer.write("<stage>");
           switch (stage) {
   
           case (1/*org.apache.coyote.Constants.STAGE_PARSE*/):
  @@ -400,42 +387,44 @@
   
           }
   
  -        writer.write("</b></td>");
  +        writer.write("</stage>");
   
           if (fullStatus) {
  -            writer.write("<td>");
  -            writer.print(mBeanServer.getAttribute
  +            writer.write("<requestProcessingTime>");
  +            writer.write("" + mBeanServer.getAttribute
                            (pName, "requestProcessingTime"));
  -            writer.write("</td>");
  -            writer.write("<td>");
  -            writer.print(mBeanServer.getAttribute
  +            writer.write("</requestProcessingTime>");
  +            writer.write("<requestBytesSent>");
  +            writer.write("" + mBeanServer.getAttribute
                            (pName, "requestBytesSent"));
  -            writer.write("</td>");
  -            writer.write("<td>");
  -            writer.print(mBeanServer.getAttribute
  +            writer.write("</requestBytesSent>");
  +            writer.write("<requestBytesReceived>");
  +            writer.write("" + mBeanServer.getAttribute
                            (pName, "requestBytesReceived"));
  -            writer.write("</td>");
  -            writer.write("<td>");
  -            writer.print("" + mBeanServer.getAttribute(pName, "remoteAddr"));
  -            writer.write("</td>");
  -            writer.write("<td nowrap>");
  +            writer.write("</requestBytesReceived>");
  +            writer.write("<remoteAddr>");
  +            writer.write("" + mBeanServer.getAttribute(pName, "remoteAddr"));
  +            writer.write("</remoteAddr>");
  +            writer.write("<virtualHost>");
               writer.write("" + filter(mBeanServer.getAttribute
                                        (pName, "virtualHost").toString()));
  -            writer.write("</td>");
  -            writer.write("<td nowrap>");
  +            writer.write("</virtualHost>");
  +            writer.write("<method>");
               writer.write("" + filter(mBeanServer.getAttribute
                                        (pName, "method").toString()));
  +            writer.write("</method>");
  +            writer.write("<currentUri>");
               writer.write("" + filter(mBeanServer.getAttribute
                                        (pName, "currentUri").toString()));
  +            writer.write("</currentUri>");
  +            writer.write("<currentQueryString>");
               String queryString = (String) mBeanServer.getAttribute
                   (pName, "currentQueryString");
               if ((queryString != null) && (!queryString.equals(""))) {
                   writer.write("?");
  -                writer.print(queryString);
  +                writer.write(queryString);
               }
  -            writer.write("</td>");
  -        } else {
  -            
writer.write("<td>?</td><td>?</td><td>?</td><td>?</td><td>?</td><td>?</td>");
  +            writer.write("</currentQueryString>");
           }
   
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to