PwcServletStatsImplpublic class PwcServletStatsImpl extends Object implements com.sun.enterprise.web.monitor.PwcServletStats
Fields Summary |
---|
private transient MBeanServer | server | private ObjectName | servletObjName |
Constructors Summary |
---|
public PwcServletStatsImpl(String domain, String vsId, String contextPath, String servletName, String appName, String serverName)Constructor.
The ObjectName of the Servlet MBean follows this pattern:
:j2eeType=Servlet,name=,
WebModule=,J2EEApplication=,
J2EEServer=
Example: com.sun.appserv:j2eeType=Servlet,name=default,
WebModule=//server/,J2EEApplication=null,J2EEServer=server
// Get an instance of the MBeanServer
ArrayList servers = MBeanServerFactory.findMBeanServer(null);
if(servers != null && !servers.isEmpty())
server = (MBeanServer)servers.get(0);
else
server = MBeanServerFactory.createMBeanServer();
// Construct the ObjectName of the Servlet MBean
String objNameStr = domain
+ ":j2eeType=Servlet"
+ ",name=" + servletName
+ ",WebModule=" + createTomcatWebModuleName(vsId, contextPath)
+ ",J2EEApplication=" + appName
+ ",J2EEServer=" + serverName;
try {
servletObjName = new ObjectName(objNameStr);
} catch (Throwable t) {
MonitorUtil.log(Level.SEVERE,
"pwc.monitoring.objectNameCreationError",
new Object[] { objNameStr },
t);
}
|
Methods Summary |
---|
private java.lang.String | createTomcatWebModuleName(java.lang.String vsId, java.lang.String contextPath)
final String PREFIX = "//";
String tcWebModuleName;
if ((contextPath != null) && (!contextPath.equals(""))) {
tcWebModuleName = PREFIX + vsId + contextPath;
} else {
tcWebModuleName = PREFIX + vsId + "/";
}
return tcWebModuleName;
| public int | getErrorCount()Gets the number of requests processed by the servlet being monitored
that resulted in errors.
return getIntValue(queryStatistic(servletObjName, "errorCount"));
| private int | getIntValue(java.lang.Object resultObj)
int result = 0;
if (resultObj != null) {
Integer countObj = (Integer)resultObj;
result = countObj.intValue();
}
return result;
| private long | getLongValue(java.lang.Object resultObj)
long result = 0;
if (resultObj != null) {
Long countObj = (Long)resultObj;
result = countObj.longValue();
}
return result;
| public long | getMaxTimeMillis()Gets the maximum request processing time of the servlet being
monitored.
return getLongValue(queryStatistic(servletObjName, "maxTimeMillis"));
| public long | getMinTimeMillis()Gets the minimum request processing time of the servlet being monitored.
return getLongValue(queryStatistic(servletObjName, "minTimeMillis"));
| public long | getProcessingTimeMillis()Gets the total execution time of the service method of the servlet being
monitored.
return getLongValue(queryStatistic(servletObjName,
"processingTimeMillis"));
| public int | getRequestCount()Gets the number of requests processed by the servlet being monitored.
return getIntValue(queryStatistic(servletObjName, "requestCount"));
| private java.lang.Object | queryStatistic(javax.management.ObjectName on, java.lang.String attrName)
Object resultObj = null;
try {
resultObj = server.getAttribute(on, attrName);
} catch (Throwable t) {
MonitorUtil.log(Level.SEVERE,
"pwc.monitoring.queryError",
new Object[] { attrName, on },
t);
}
return resultObj;
| private void | readObject(java.io.ObjectInputStream ois)
ois.defaultReadObject();
// Get an instance of the MBeanServer
ArrayList servers = MBeanServerFactory.findMBeanServer(null);
if (servers != null && !servers.isEmpty()) {
server = (MBeanServer)servers.get(0);
} else {
server = MBeanServerFactory.createMBeanServer();
}
|
|