01: //========================================================================
02: //$Id: ServletStatsImpl.java 1195 2006-11-12 23:02:51Z janb $
03: //Copyright 200-2004 Mort Bay Consulting Pty. Ltd.
04: //------------------------------------------------------------------------
05: //Licensed under the Apache License, Version 2.0 (the "License");
06: //you may not use this file except in compliance with the License.
07: //You may obtain a copy of the License at
08: //http://www.apache.org/licenses/LICENSE-2.0
09: //Unless required by applicable law or agreed to in writing, software
10: //distributed under the License is distributed on an "AS IS" BASIS,
11: //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: //See the License for the specific language governing permissions and
13: //limitations under the License.
14: //========================================================================
15: package org.mortbay.jetty.servlet.jsr77;
16:
17: import java.io.Serializable;
18:
19: import javax.management.j2ee.statistics.Statistic;
20: import javax.management.j2ee.statistics.TimeStatistic;
21:
22: /**
23: * Jsr77ServletStats
24: *
25: * Implementation of ServletStats from JSR77 specification.
26: *
27: * @author janb
28: */
29: public class ServletStatsImpl implements
30: javax.management.j2ee.statistics.ServletStats, Serializable {
31: private static final String[] statisticNames = new String[] { "ServiceTime" };
32: private TimeStatisticImpl statistic = null;
33: private TimeStatisticImpl[] statistics = new TimeStatisticImpl[1];
34: private String name = null;
35:
36: public ServletStatsImpl(String servletName) {
37: name = servletName;
38: statistic = new TimeStatisticImpl(this , statisticNames[0],
39: "Servlet service method performance statistics",
40: "MILLISECONDS");
41: statistic.setStartTime();
42: statistics[0] = statistic;
43: }
44:
45: /**
46: *
47: * @see javax.management.j2ee.statistics.ServletStats#getServiceTime()
48: */
49: public TimeStatistic getServiceTime() {
50: return statistic;
51: }
52:
53: /** Get the TimeStatistic
54: * @see javax.management.j2ee.statistics.Stats#getStatistic(java.lang.String)
55: */
56: public Statistic getStatistic(String statisticName) {
57: if (statisticNames[0].equalsIgnoreCase(statisticName))
58: return statistic;
59:
60: return null;
61: }
62:
63: /** Get the names of supported statistics.
64: * For ServletStats, only the TimeStatistic is supported
65: * @see javax.management.j2ee.statistics.Stats#getStatisticNames()
66: */
67: public String[] getStatisticNames() {
68: return statisticNames;
69: }
70:
71: /** Get an object of all the types of statistics supported.
72: * For ServletStats, only the TimeStatistic is supported.
73: * @see javax.management.j2ee.statistics.Stats#getStatistics()
74: */
75: public Statistic[] getStatistics() {
76: return statistics;
77: }
78:
79: public String getName() {
80: return name;
81: }
82:
83: public String toString() {
84: return statistic.toString();
85: }
86: }
|