Class StatusTransformer


  • public class StatusTransformer
    extends java.lang.Object
    This is a refactoring of the servlet to externalize the output into a simple class. Although we could use XSLT, that is unnecessarily complex.
    Author:
    Peter Lin
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String formatSeconds​(java.lang.Object obj)
      Formats the given time (given in seconds) as a string.
      static java.lang.String formatSize​(java.lang.Object obj, boolean mb)
      Display the given size in bytes, either as KB or MB.
      static java.lang.String formatTime​(java.lang.Object obj, boolean seconds)
      Display the given time in ms, either as ms or s.
      static void setContentType​(HttpServletResponse response, int mode)  
      static void writeBody​(java.io.PrintWriter writer, java.lang.Object[] args, int mode)
      Write the header body.
      static void writeConnectorState​(java.io.PrintWriter writer, javax.management.ObjectName tpName, java.lang.String name, javax.management.MBeanServer mBeanServer, java.util.Vector<javax.management.ObjectName> globalRequestProcessors, java.util.Vector<javax.management.ObjectName> requestProcessors, int mode, java.lang.Object[] args)
      Write connector state.
      protected static void writeContext​(java.io.PrintWriter writer, javax.management.ObjectName objectName, javax.management.MBeanServer mBeanServer, int mode)
      Write context state.
      static void writeDetailedState​(java.io.PrintWriter writer, javax.management.MBeanServer mBeanServer, int mode)
      Write applications state.
      static void writeFooter​(java.io.PrintWriter writer, int mode)  
      static void writeHeader​(java.io.PrintWriter writer, java.lang.Object[] args, int mode)
      Write an HTML or XML header.
      static void writeJspMonitor​(java.io.PrintWriter writer, java.util.Set<javax.management.ObjectName> jspMonitorONs, javax.management.MBeanServer mBeanServer, int mode)
      Write JSP monitoring information.
      static void writeManager​(java.io.PrintWriter writer, java.lang.Object[] args, int mode)
      Write the manager webapp information.
      static void writeManager​(java.io.PrintWriter writer, javax.management.ObjectName objectName, javax.management.MBeanServer mBeanServer, int mode)
      Write detailed information about a manager.
      static void writeOSState​(java.io.PrintWriter writer, int mode, java.lang.Object[] args)
      Write the OS state.
      static void writePageHeading​(java.io.PrintWriter writer, java.lang.Object[] args, int mode)  
      protected static void writeProcessorState​(java.io.PrintWriter writer, javax.management.ObjectName pName, javax.management.MBeanServer mBeanServer, int mode)
      Write processor state.
      static void writeServerInfo​(java.io.PrintWriter writer, java.lang.Object[] args, int mode)  
      static void writeVMState​(java.io.PrintWriter writer, int mode, java.lang.Object[] args)
      Write the VM state.
      static void writeWrapper​(java.io.PrintWriter writer, javax.management.ObjectName objectName, javax.management.MBeanServer mBeanServer, int mode)
      Write detailed information about a wrapper.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StatusTransformer

        public StatusTransformer()
    • Method Detail

      • setContentType

        public static void setContentType​(HttpServletResponse response,
                                          int mode)
      • writeHeader

        public static void writeHeader​(java.io.PrintWriter writer,
                                       java.lang.Object[] args,
                                       int mode)
        Write an HTML or XML header.
        Parameters:
        writer - the PrintWriter to use
        args - Path prefix for URLs
        mode - - 0 = HTML header, 1 = XML declaration
      • writeBody

        public static void writeBody​(java.io.PrintWriter writer,
                                     java.lang.Object[] args,
                                     int mode)
        Write the header body. XML output doesn't bother to output this stuff, since it's just title.
        Parameters:
        writer - The output writer
        args - What to write
        mode - 0 means write
      • writeManager

        public static void writeManager​(java.io.PrintWriter writer,
                                        java.lang.Object[] args,
                                        int mode)
        Write the manager webapp information.
        Parameters:
        writer - The output writer
        args - What to write
        mode - 0 means write
      • writePageHeading

        public static void writePageHeading​(java.io.PrintWriter writer,
                                            java.lang.Object[] args,
                                            int mode)
      • writeServerInfo

        public static void writeServerInfo​(java.io.PrintWriter writer,
                                           java.lang.Object[] args,
                                           int mode)
      • writeFooter

        public static void writeFooter​(java.io.PrintWriter writer,
                                       int mode)
      • writeOSState

        public static void writeOSState​(java.io.PrintWriter writer,
                                        int mode,
                                        java.lang.Object[] args)
        Write the OS state.
        Parameters:
        writer - The output writer
        mode - Mode 0 will generate HTML. Mode 1 will generate XML.
        args - I18n labels for the OS state values
      • writeVMState

        public static void writeVMState​(java.io.PrintWriter writer,
                                        int mode,
                                        java.lang.Object[] args)
                                 throws java.lang.Exception
        Write the VM state.
        Parameters:
        writer - The output writer
        mode - Mode 0 will generate HTML. Mode 1 will generate XML.
        args - I18n labels for the VM state values
        Throws:
        java.lang.Exception - Propagated JMX error
      • writeConnectorState

        public static void writeConnectorState​(java.io.PrintWriter writer,
                                               javax.management.ObjectName tpName,
                                               java.lang.String name,
                                               javax.management.MBeanServer mBeanServer,
                                               java.util.Vector<javax.management.ObjectName> globalRequestProcessors,
                                               java.util.Vector<javax.management.ObjectName> requestProcessors,
                                               int mode,
                                               java.lang.Object[] args)
                                        throws java.lang.Exception
        Write connector state.
        Parameters:
        writer - The output writer
        tpName - MBean name of the thread pool
        name - Connector name
        mBeanServer - MBean server
        globalRequestProcessors - MBean names for the global request processors
        requestProcessors - MBean names for the request processors
        mode - Mode 0 will generate HTML. Mode 1 will generate XML.
        args - I18n labels for the Connector state values
        Throws:
        java.lang.Exception - Propagated JMX error
      • writeProcessorState

        protected static void writeProcessorState​(java.io.PrintWriter writer,
                                                  javax.management.ObjectName pName,
                                                  javax.management.MBeanServer mBeanServer,
                                                  int mode)
                                           throws java.lang.Exception
        Write processor state.
        Parameters:
        writer - The output writer
        pName - MBean name of the processor
        mBeanServer - MBean server
        mode - Mode 0 will generate HTML. Mode 1 will generate XML.
        Throws:
        java.lang.Exception - Propagated JMX error
      • writeDetailedState

        public static void writeDetailedState​(java.io.PrintWriter writer,
                                              javax.management.MBeanServer mBeanServer,
                                              int mode)
                                       throws java.lang.Exception
        Write applications state.
        Parameters:
        writer - The output writer
        mBeanServer - MBean server
        mode - Mode 0 will generate HTML. Mode 1 will generate XML.
        Throws:
        java.lang.Exception - Propagated JMX error
      • writeContext

        protected static void writeContext​(java.io.PrintWriter writer,
                                           javax.management.ObjectName objectName,
                                           javax.management.MBeanServer mBeanServer,
                                           int mode)
                                    throws java.lang.Exception
        Write context state.
        Parameters:
        writer - The output writer
        objectName - The context MBean name
        mBeanServer - MBean server
        mode - Mode 0 will generate HTML. Mode 1 will generate XML.
        Throws:
        java.lang.Exception - Propagated JMX error
      • writeManager

        public static void writeManager​(java.io.PrintWriter writer,
                                        javax.management.ObjectName objectName,
                                        javax.management.MBeanServer mBeanServer,
                                        int mode)
                                 throws java.lang.Exception
        Write detailed information about a manager.
        Parameters:
        writer - The output writer
        objectName - The manager MBean name
        mBeanServer - MBean server
        mode - Mode 0 will generate HTML. Mode 1 will generate XML.
        Throws:
        java.lang.Exception - Propagated JMX error
      • writeJspMonitor

        public static void writeJspMonitor​(java.io.PrintWriter writer,
                                           java.util.Set<javax.management.ObjectName> jspMonitorONs,
                                           javax.management.MBeanServer mBeanServer,
                                           int mode)
                                    throws java.lang.Exception
        Write JSP monitoring information.
        Parameters:
        writer - The output writer
        jspMonitorONs - The JSP MBean names
        mBeanServer - MBean server
        mode - Mode 0 will generate HTML. Mode 1 will generate XML.
        Throws:
        java.lang.Exception - Propagated JMX error
      • writeWrapper

        public static void writeWrapper​(java.io.PrintWriter writer,
                                        javax.management.ObjectName objectName,
                                        javax.management.MBeanServer mBeanServer,
                                        int mode)
                                 throws java.lang.Exception
        Write detailed information about a wrapper.
        Parameters:
        writer - The output writer
        objectName - The wrapper MBean names
        mBeanServer - MBean server
        mode - Mode 0 will generate HTML. Mode 1 will generate XML.
        Throws:
        java.lang.Exception - Propagated JMX error
      • formatSize

        public static java.lang.String formatSize​(java.lang.Object obj,
                                                  boolean mb)
        Display the given size in bytes, either as KB or MB.
        Parameters:
        obj - The object to format
        mb - true to display megabytes, false for kilobytes
        Returns:
        formatted size
      • formatTime

        public static java.lang.String formatTime​(java.lang.Object obj,
                                                  boolean seconds)
        Display the given time in ms, either as ms or s.
        Parameters:
        obj - The object to format
        seconds - true to display seconds, false for milliseconds
        Returns:
        formatted time
      • formatSeconds

        public static java.lang.String formatSeconds​(java.lang.Object obj)
        Formats the given time (given in seconds) as a string.
        Parameters:
        obj - Time object to be formatted as string
        Returns:
        formatted time