1 /**
2 *
3 * Copyright 2003-2004 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.geronimo.management.stats;
18
19 import java.io.Serializable;
20 import javax.management.j2ee.statistics.Statistic;
21
22 /**
23 * Implementation of the JSR-77 Statistic interface (JSR77.6.4)
24 *
25 * @version $Rev: 355877 $ $Date: 2005-12-10 18:48:27 -0800 (Sat, 10 Dec 2005) $
26 */
27 public class StatisticImpl implements Statistic, Serializable {
28
29 public final static String UNIT_TIME_HOUR = "HOUR";
30 public final static String UNIT_TIME_MINUTE = "MINUTE";
31 public final static String UNIT_TIME_SECOND = "SECOND";
32 public final static String UNIT_TIME_MILLISECOND = "MILLISECOND";
33 public final static String UNIT_TIME_MICROSECOND = "MICROSECOND";
34 public final static String UNIT_TIME_NANOSECOND = "NANOSECOND";
35
36 public final static String UNIT_MEMORY_BYTES = "BYTE";
37 public final static String UNIT_MEMORY_KILOBYTES = "KILOBYTE";
38 public final static String UNIT_MEMORY_MEGABYTES = "MEGABYTE";
39 public final static String UNIT_MEMORY_GIGABYTES = "GIGABYTE";
40 public final static String UNIT_COUNT = "COUNT";
41
42 private String name;
43 private String unit;
44 private String description;
45 private long startTime;
46 private long lastSampleTime;
47
48 public StatisticImpl(String name, String unit, String description) {
49 this.name = name;
50 this.unit = unit;
51 this.description = description;
52 }
53
54 public String getName() {
55 return name;
56 }
57
58 public String getUnit() {
59 return unit;
60 }
61
62 public String getDescription() {
63 return description;
64 }
65
66 public long getStartTime() {
67 return startTime;
68 }
69
70 public void setStartTime() {
71 this.startTime = System.currentTimeMillis();
72 }
73
74 public void setStartTime(long startTime) {
75 this.startTime = startTime;
76 }
77
78 public long getLastSampleTime() {
79 return lastSampleTime;
80 }
81
82 public void setLastSampleTime(long lastSampleTime) {
83 this.lastSampleTime = lastSampleTime;
84 }
85
86 public void setLastSampleTime() {
87 this.lastSampleTime = System.currentTimeMillis();
88 }
89 }