Author: ammulder Date: Thu Apr 20 17:54:15 2006 New Revision: 395743 URL: http://svn.apache.org/viewcvs?rev=395743&view=rev Log: Stats page doesn't break on Tomcat (GERONIMO-1877) Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/webmanager/WebManagerPortlet.java Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/webmanager/WebManagerPortlet.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/webmanager/WebManagerPortlet.java?rev=395743&r1=395742&r2=395743&view=diff ============================================================================== --- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/webmanager/WebManagerPortlet.java (original) +++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/webmanager/WebManagerPortlet.java Thu Apr 20 17:54:15 2006 @@ -109,35 +109,40 @@ WebContainer[] containers = (WebContainer[]) manager.getContainers(); if (containers != null) { WebContainer container = containers[0]; //todo: handle multiple - WebContainerStats webStats = (WebContainerStats) ((StatisticsProvider)container).getStats(); - if (webStats.isStatsOn()) { - renderRequest.setAttribute("statsOn", Boolean.TRUE); - renderRequest.setAttribute("totalRequestCount", new Long(webStats.getTotalRequestCount().getCount())); - renderRequest.setAttribute("totalConnectionCount", new Long(webStats.getTotalConnectionCount().getCount())); - renderRequest.setAttribute("totalErrorCount", new Long(webStats.getTotalErrorCount().getCount())); - renderRequest.setAttribute("activeRequestCountCurrent", new Long(webStats.getActiveRequestCount().getCurrent())); - renderRequest.setAttribute("activeRequestCountLow", new Long(webStats.getActiveRequestCount().getLowWaterMark())); - renderRequest.setAttribute("activeRequestCountHigh", new Long(webStats.getActiveRequestCount().getHighWaterMark())); - renderRequest.setAttribute("connectionRequestCountCurrent", new Long(webStats.getConnectionRequestCount().getCurrent())); - renderRequest.setAttribute("connectionRequestCountLow", new Long(webStats.getConnectionRequestCount().getLowWaterMark())); - renderRequest.setAttribute("connectionRequestCountHigh", new Long(webStats.getConnectionRequestCount().getHighWaterMark())); -// renderRequest.setAttribute("connectionRequestsAve", new Long(0)); /* Can't really compute this for a range ... do we still need it (from old portlet) */ - renderRequest.setAttribute("openConnectionCountCurrent", new Long(webStats.getOpenConnectionCount().getCurrent())); - renderRequest.setAttribute("openConnectionCountLow", new Long(webStats.getOpenConnectionCount().getLowWaterMark())); - renderRequest.setAttribute("openConnectionCountHigh", new Long(webStats.getOpenConnectionCount().getHighWaterMark())); - renderRequest.setAttribute("requestDurationCount", new Long(webStats.getRequestDuration().getCount())); - renderRequest.setAttribute("requestDurationMinTime", new Long(webStats.getRequestDuration().getMinTime())); - renderRequest.setAttribute("requestDurationMaxTime", new Long(webStats.getRequestDuration().getMaxTime())); - renderRequest.setAttribute("requestDurationTotalTime", new Long(webStats.getRequestDuration().getTotalTime())); -// renderRequest.setAttribute("requestDurationAve", new Long(0)); /* Would this be valuable to calculate? We used to show this in the old jetty only portlet */ - renderRequest.setAttribute("connectionDurationCount", new Long(webStats.getConnectionDuration().getCount())); - renderRequest.setAttribute("connectionDurationMinTime", new Long(webStats.getConnectionDuration().getMinTime())); - renderRequest.setAttribute("connectionDurationMaxTime", new Long(webStats.getConnectionDuration().getMaxTime())); - renderRequest.setAttribute("connectionDurationTotalTime", new Long(webStats.getConnectionDuration().getTotalTime())); -// renderRequest.setAttribute("connectionDurationAve", new Long(0)); /* Wouldl this be valueable to calculate? We used to show this in the old jetty only portlet */ + if(container.isStatisticsProvider()) { + WebContainerStats webStats = (WebContainerStats) ((StatisticsProvider)container).getStats(); + if (webStats.isStatsOn()) { + renderRequest.setAttribute("statsOn", Boolean.TRUE); + renderRequest.setAttribute("totalRequestCount", new Long(webStats.getTotalRequestCount().getCount())); + renderRequest.setAttribute("totalConnectionCount", new Long(webStats.getTotalConnectionCount().getCount())); + renderRequest.setAttribute("totalErrorCount", new Long(webStats.getTotalErrorCount().getCount())); + renderRequest.setAttribute("activeRequestCountCurrent", new Long(webStats.getActiveRequestCount().getCurrent())); + renderRequest.setAttribute("activeRequestCountLow", new Long(webStats.getActiveRequestCount().getLowWaterMark())); + renderRequest.setAttribute("activeRequestCountHigh", new Long(webStats.getActiveRequestCount().getHighWaterMark())); + renderRequest.setAttribute("connectionRequestCountCurrent", new Long(webStats.getConnectionRequestCount().getCurrent())); + renderRequest.setAttribute("connectionRequestCountLow", new Long(webStats.getConnectionRequestCount().getLowWaterMark())); + renderRequest.setAttribute("connectionRequestCountHigh", new Long(webStats.getConnectionRequestCount().getHighWaterMark())); + // renderRequest.setAttribute("connectionRequestsAve", new Long(0)); /* Can't really compute this for a range ... do we still need it (from old portlet) */ + renderRequest.setAttribute("openConnectionCountCurrent", new Long(webStats.getOpenConnectionCount().getCurrent())); + renderRequest.setAttribute("openConnectionCountLow", new Long(webStats.getOpenConnectionCount().getLowWaterMark())); + renderRequest.setAttribute("openConnectionCountHigh", new Long(webStats.getOpenConnectionCount().getHighWaterMark())); + renderRequest.setAttribute("requestDurationCount", new Long(webStats.getRequestDuration().getCount())); + renderRequest.setAttribute("requestDurationMinTime", new Long(webStats.getRequestDuration().getMinTime())); + renderRequest.setAttribute("requestDurationMaxTime", new Long(webStats.getRequestDuration().getMaxTime())); + renderRequest.setAttribute("requestDurationTotalTime", new Long(webStats.getRequestDuration().getTotalTime())); + // renderRequest.setAttribute("requestDurationAve", new Long(0)); /* Would this be valuable to calculate? We used to show this in the old jetty only portlet */ + renderRequest.setAttribute("connectionDurationCount", new Long(webStats.getConnectionDuration().getCount())); + renderRequest.setAttribute("connectionDurationMinTime", new Long(webStats.getConnectionDuration().getMinTime())); + renderRequest.setAttribute("connectionDurationMaxTime", new Long(webStats.getConnectionDuration().getMaxTime())); + renderRequest.setAttribute("connectionDurationTotalTime", new Long(webStats.getConnectionDuration().getTotalTime())); + // renderRequest.setAttribute("connectionDurationAve", new Long(0)); /* Wouldl this be valueable to calculate? We used to show this in the old jetty only portlet */ + } else { + renderRequest.setAttribute("statsSupported", Boolean.TRUE); + renderRequest.setAttribute("statsMessage", "Statistics are not currently being collected."); + } } else { - renderRequest.setAttribute("statsSupported", Boolean.TRUE); - renderRequest.setAttribute("statsMessage", "Statistics are not currently being collected."); + renderRequest.setAttribute("statsSupported", Boolean.FALSE); + renderRequest.setAttribute("statsMessage", "Web statistics are not supported for the current web container."); } } else { log.error("Error attempting to retrieve the web containers");