Top Description Constructors Methods
org.apache.catalina.manager

public Class StatusTransformer

extends Object
Class Inheritance
Imports
java.io.PrintWriter, java.lang.management.ManagementFactory, .MemoryPoolMXBean, .MemoryUsage, java.text.MessageFormat, java.util.Date, .Iterator, .List, .Set, .SortedMap, .TreeMap, javax.management.MBeanServer, .ObjectInstance, .ObjectName, jakarta.servlet.http.HttpServletResponse, org.apache.tomcat.util.json.JSONFilter, org.apache.tomcat.util.security.Escape

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

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static PrintWriter
public static String

Returns:

formatted time
formatSeconds
(Object
Time object to be formatted as string
obj
)

Formats the given time (given in seconds) as a string.

public static String

Returns:

formatted size
formatSize
(Object
The object to format
obj
,
boolean
true to display MiB, false for KiB
mb
)

Display the given size in bytes, either as KiB or MiB.

public static String

Returns:

formatted time
formatTime
(Object
The object to format
obj
,
boolean
true to display seconds, false for milliseconds
seconds
)

Display the given time in ms, either as ms or s.

private static PrintWriter
indent(PrintWriter writer, int count)

public static void
setContentType(HttpServletResponse response, int mode)

public static void
writeBody(PrintWriter
The output writer
writer
,
Object[]
What to write
args
,
int
0 means write
mode
)

Write the header body.

public static void
writeConnectorsState(PrintWriter
The output writer
writer
,
MBeanServer
MBean server
mBeanServer
,
List<ObjectName>
MBean names for the thread pools of the connectors
threadPools
,
List<ObjectName>
MBean names for the global request processors
globalRequestProcessors
,
List<ObjectName>
MBean names for the request processors
requestProcessors
,
int
Mode 0 will generate HTML. Mode 1 will generate XML.
mode
,
Object[]
I18n labels for the Connector state values
args
)

Write connector state.

public static void
writeConnectorState(PrintWriter
The output writer
writer
,
ObjectName
MBean name of the thread pool
tpName
,
String
Connector name
name
,
MBeanServer
MBean server
mBeanServer
,
List<ObjectName>
MBean names for the global request processors
globalRequestProcessors
,
List<ObjectName>
MBean names for the request processors
requestProcessors
,
int
Mode 0 will generate HTML. Mode 1 will generate XML.
mode
,
Object[]
I18n labels for the Connector state values
args
)

Write connector state.

protected static void
writeContext(PrintWriter
The output writer
writer
,
ObjectName
The context MBean name
objectName
,
MBeanServer
MBean server
mBeanServer
,
int
Mode 0 will generate HTML. Mode 1 will generate XML.
mode
)

Write context state.

public static void
writeDetailedState(PrintWriter
The output writer
writer
,
MBeanServer
MBean server
mBeanServer
,
int
Mode 0 will generate HTML. Mode 1 will generate XML.
mode
)

Write applications state.

public static void
writeFooter(PrintWriter writer, int mode)

public static void
writeHeader(PrintWriter
the PrintWriter to use
writer
,
Object[]
Path prefix for URLs
args
,
int
- 0 = HTML header, 1 = XML declaration, 2 = JSON
mode
)

Write an HTML or XML header.

public static void
writeJspMonitor(PrintWriter
The output writer
writer
,
Set<ObjectName>
The JSP MBean names
jspMonitorONs
,
MBeanServer
MBean server
mBeanServer
,
int
Mode 0 will generate HTML. Mode 1 will generate XML.
mode
)

Write JSP monitoring information.

public static void
writeManager(PrintWriter
The output writer
writer
,
Object[]
What to write
args
,
int
0 means write
mode
)

Write the manager webapp information.

public static void
writeManager(PrintWriter
The output writer
writer
,
ObjectName
The manager MBean name
objectName
,
MBeanServer
MBean server
mBeanServer
,
int
Mode 0 will generate HTML. Mode 1 will generate XML.
mode
)

Write detailed information about a manager.

public static void
writePageHeading(PrintWriter writer, Object[] args, int mode)

protected static void
writeProcessorState(PrintWriter
The output writer
writer
,
ObjectName
MBean name of the processor
pName
,
MBeanServer
MBean server
mBeanServer
,
int
Mode 0 will generate HTML. Mode 1 will generate XML.
mode
)

Write processor state.

public static void
writeServerInfo(PrintWriter writer, Object[] args, int mode)

public static void
writeVMState(PrintWriter
The output writer
writer
,
int
Mode 0 will generate HTML. Mode 1 will generate XML.
mode
,
Object[]
I18n labels for the VM state values
args
)

Write the VM state.

public static void
writeWrapper(PrintWriter
The output writer
writer
,
ObjectName
The wrapper MBean names
objectName
,
MBeanServer
MBean server
mBeanServer
,
int
Mode 0 will generate HTML. Mode 1 will generate XML.
mode
)

Write detailed information about a wrapper.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

StatusTransformerback to summary
public StatusTransformer()

Method Detail

appendJSonValueback to summary
private static PrintWriter appendJSonValue(PrintWriter writer, String name, String value)
formatSecondsback to summary
public static String formatSeconds(Object obj)

Formats the given time (given in seconds) as a string.

Parameters
obj:Object

Time object to be formatted as string

Returns:String

formatted time

formatSizeback to summary
public static String formatSize(Object obj, boolean mb)

Display the given size in bytes, either as KiB or MiB.

Parameters
obj:Object

The object to format

mb:boolean

true to display MiB, false for KiB

Returns:String

formatted size

formatTimeback to summary
public static String formatTime(Object obj, boolean seconds)

Display the given time in ms, either as ms or s.

Parameters
obj:Object

The object to format

seconds:boolean

true to display seconds, false for milliseconds

Returns:String

formatted time

indentback to summary
private static PrintWriter indent(PrintWriter writer, int count)
setContentTypeback to summary
public static void setContentType(HttpServletResponse response, int mode)
writeBodyback to summary
public static void writeBody(PrintWriter writer, Object[] args, int mode)

Write the header body. XML output doesn't bother to output this stuff, since it's just title.

Parameters
writer:PrintWriter

The output writer

args:Object[]

What to write

mode:int

0 means write

writeConnectorsStateback to summary
public static void writeConnectorsState(PrintWriter writer, MBeanServer mBeanServer, List<ObjectName> threadPools, List<ObjectName> globalRequestProcessors, List<ObjectName> requestProcessors, int mode, Object[] args) throws Exception

Write connector state.

Parameters
writer:PrintWriter

The output writer

mBeanServer:MBeanServer

MBean server

threadPools:List<ObjectName>

MBean names for the thread pools of the connectors

globalRequestProcessors:List<ObjectName>

MBean names for the global request processors

requestProcessors:List<ObjectName>

MBean names for the request processors

mode:int

Mode 0 will generate HTML. Mode 1 will generate XML.

args:Object[]

I18n labels for the Connector state values

Exceptions
Exception:
Propagated JMX error
writeConnectorStateback to summary
public static void writeConnectorState(PrintWriter writer, ObjectName tpName, String name, MBeanServer mBeanServer, List<ObjectName> globalRequestProcessors, List<ObjectName> requestProcessors, int mode, Object[] args) throws Exception

Write connector state.

Parameters
writer:PrintWriter

The output writer

tpName:ObjectName

MBean name of the thread pool

name:String

Connector name

mBeanServer:MBeanServer

MBean server

globalRequestProcessors:List<ObjectName>

MBean names for the global request processors

requestProcessors:List<ObjectName>

MBean names for the request processors

mode:int

Mode 0 will generate HTML. Mode 1 will generate XML.

args:Object[]

I18n labels for the Connector state values

Exceptions
Exception:
Propagated JMX error
writeContextback to summary
protected static void writeContext(PrintWriter writer, ObjectName objectName, MBeanServer mBeanServer, int mode) throws Exception

Write context state.

Parameters
writer:PrintWriter

The output writer

objectName:ObjectName

The context MBean name

mBeanServer:MBeanServer

MBean server

mode:int

Mode 0 will generate HTML. Mode 1 will generate XML.

Exceptions
Exception:
Propagated JMX error
writeDetailedStateback to summary
public static void writeDetailedState(PrintWriter writer, MBeanServer mBeanServer, int mode) throws Exception

Write applications state.

Parameters
writer:PrintWriter

The output writer

mBeanServer:MBeanServer

MBean server

mode:int

Mode 0 will generate HTML. Mode 1 will generate XML.

Exceptions
Exception:
Propagated JMX error
writeFooterback to summary
public static void writeFooter(PrintWriter writer, int mode)
writeHeaderback to summary
public static void writeHeader(PrintWriter writer, Object[] args, int mode)

Write an HTML or XML header.

Parameters
writer:PrintWriter

the PrintWriter to use

args:Object[]

Path prefix for URLs

mode:int

- 0 = HTML header, 1 = XML declaration, 2 = JSON

writeJspMonitorback to summary
public static void writeJspMonitor(PrintWriter writer, Set<ObjectName> jspMonitorONs, MBeanServer mBeanServer, int mode) throws Exception

Write JSP monitoring information.

Parameters
writer:PrintWriter

The output writer

jspMonitorONs:Set<ObjectName>

The JSP MBean names

mBeanServer:MBeanServer

MBean server

mode:int

Mode 0 will generate HTML. Mode 1 will generate XML.

Exceptions
Exception:
Propagated JMX error
writeManagerback to summary
public static void writeManager(PrintWriter writer, Object[] args, int mode)

Write the manager webapp information.

Parameters
writer:PrintWriter

The output writer

args:Object[]

What to write

mode:int

0 means write

writeManagerback to summary
public static void writeManager(PrintWriter writer, ObjectName objectName, MBeanServer mBeanServer, int mode) throws Exception

Write detailed information about a manager.

Parameters
writer:PrintWriter

The output writer

objectName:ObjectName

The manager MBean name

mBeanServer:MBeanServer

MBean server

mode:int

Mode 0 will generate HTML. Mode 1 will generate XML.

Exceptions
Exception:
Propagated JMX error
writePageHeadingback to summary
public static void writePageHeading(PrintWriter writer, Object[] args, int mode)
writeProcessorStateback to summary
protected static void writeProcessorState(PrintWriter writer, ObjectName pName, MBeanServer mBeanServer, int mode) throws Exception

Write processor state.

Parameters
writer:PrintWriter

The output writer

pName:ObjectName

MBean name of the processor

mBeanServer:MBeanServer

MBean server

mode:int

Mode 0 will generate HTML. Mode 1 will generate XML.

Exceptions
Exception:
Propagated JMX error
writeServerInfoback to summary
public static void writeServerInfo(PrintWriter writer, Object[] args, int mode)
writeVMStateback to summary
public static void writeVMState(PrintWriter writer, int mode, Object[] args) throws Exception

Write the VM state.

Parameters
writer:PrintWriter

The output writer

mode:int

Mode 0 will generate HTML. Mode 1 will generate XML.

args:Object[]

I18n labels for the VM state values

Exceptions
Exception:
Propagated JMX error
writeWrapperback to summary
public static void writeWrapper(PrintWriter writer, ObjectName objectName, MBeanServer mBeanServer, int mode) throws Exception

Write detailed information about a wrapper.

Parameters
writer:PrintWriter

The output writer

objectName:ObjectName

The wrapper MBean names

mBeanServer:MBeanServer

MBean server

mode:int

Mode 0 will generate HTML. Mode 1 will generate XML.

Exceptions
Exception:
Propagated JMX error