1 23 24 package com.sun.enterprise.web.stats; 25 26 import java.util.logging.Level ; 27 import java.util.logging.Logger ; 28 import javax.management.j2ee.statistics.Statistic ; 29 import javax.management.j2ee.statistics.CountStatistic ; 30 import javax.management.j2ee.statistics.TimeStatistic ; 31 import com.sun.logging.LogDomains; 32 import com.sun.enterprise.admin.monitor.stats.ServletStats; 33 import com.sun.enterprise.admin.monitor.stats.CountStatisticImpl; 34 import com.sun.enterprise.admin.monitor.stats.MutableCountStatistic; 35 import com.sun.enterprise.admin.monitor.stats.MutableCountStatisticImpl; 36 import com.sun.enterprise.admin.monitor.stats.GenericStatsImpl; 37 import com.sun.enterprise.web.monitor.PwcServletStats; 38 39 40 public class ServletStatsImpl implements ServletStats { 41 42 private static Logger _logger = null; 43 44 private GenericStatsImpl baseStatsImpl; 45 private MutableCountStatistic maxTimeMillis; 46 private MutableCountStatistic processingTimeMillis; 47 private TimeStatistic serviceTimeMillis; 48 private MutableCountStatistic requestCount; 49 private MutableCountStatistic errorCount; 50 private PwcServletStats pwcServletStats; 51 52 53 58 public ServletStatsImpl(PwcServletStats pwcServletStats) { 59 60 this.pwcServletStats = pwcServletStats; 61 62 _logger = LogDomains.getLogger(LogDomains.WEB_LOGGER); 63 64 baseStatsImpl = new GenericStatsImpl( 65 com.sun.enterprise.admin.monitor.stats.ServletStats.class, this); 66 67 initializeStatistics(); 69 } 70 71 72 76 public CountStatistic getMaxTime() { 77 maxTimeMillis.setCount(pwcServletStats.getMaxTimeMillis()); 78 return (CountStatistic )maxTimeMillis.unmodifiableView(); 79 } 80 81 82 87 public CountStatistic getProcessingTime() { 88 processingTimeMillis.setCount(pwcServletStats.getProcessingTimeMillis()); 89 return (CountStatistic )processingTimeMillis.unmodifiableView(); 90 } 91 92 93 99 public TimeStatistic getServiceTime() { 100 return serviceTimeMillis; 101 } 102 103 104 108 public CountStatistic getRequestCount() { 109 requestCount.setCount(pwcServletStats.getRequestCount()); 110 return (CountStatistic )requestCount.unmodifiableView(); 111 } 112 113 114 119 public CountStatistic getErrorCount() { 120 errorCount.setCount(pwcServletStats.getErrorCount()); 121 return (CountStatistic )errorCount.unmodifiableView(); 122 } 123 124 125 130 public Statistic [] getStatistics() { 131 return baseStatsImpl.getStatistics(); 132 } 133 134 135 139 public Statistic getStatistic(String str) { 140 return baseStatsImpl.getStatistic(str); 141 } 142 143 144 149 public String [] getStatisticNames() { 150 return baseStatsImpl.getStatisticNames(); 151 } 152 153 154 private void initializeStatistics() { 155 156 CountStatistic c = new CountStatisticImpl("ErrorCount"); 158 errorCount = new MutableCountStatisticImpl(c); 159 160 c = new CountStatisticImpl("MaxTime", "milliseconds"); 162 maxTimeMillis = new MutableCountStatisticImpl(c); 163 164 c = new CountStatisticImpl("ProcessingTime", "milliseconds"); 166 processingTimeMillis = new MutableCountStatisticImpl(c); 167 168 c = new CountStatisticImpl("RequestCount"); 170 requestCount = new MutableCountStatisticImpl(c); 171 172 serviceTimeMillis = new ServletTimeStatisticImpl("ServiceTime", 174 "milliseconds", 175 pwcServletStats); 176 } 177 178 } 179 | Popular Tags |