KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > management > stats > StatisticImpl


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. 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 JavaDoc;
20 import javax.management.j2ee.statistics.Statistic JavaDoc;
21
22 /**
23  * Implementation of the JSR-77 Statistic interface (JSR77.6.4)
24  *
25  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
26  */

27 public class StatisticImpl implements Statistic JavaDoc, Serializable JavaDoc {
28     // Defined in JSR77.6.4.1.2
29
public final static String JavaDoc UNIT_TIME_HOUR = "HOUR";
30     public final static String JavaDoc UNIT_TIME_MINUTE = "MINUTE";
31     public final static String JavaDoc UNIT_TIME_SECOND = "SECOND";
32     public final static String JavaDoc UNIT_TIME_MILLISECOND = "MILLISECOND";
33     public final static String JavaDoc UNIT_TIME_MICROSECOND = "MICROSECOND";
34     public final static String JavaDoc UNIT_TIME_NANOSECOND = "NANOSECOND";
35     // Units that are not defined in JSR-77
36
public final static String JavaDoc UNIT_MEMORY_BYTES = "BYTE";
37     public final static String JavaDoc UNIT_MEMORY_KILOBYTES = "KILOBYTE";
38     public final static String JavaDoc UNIT_MEMORY_MEGABYTES = "MEGABYTE";
39     public final static String JavaDoc UNIT_MEMORY_GIGABYTES = "GIGABYTE";
40     public final static String JavaDoc UNIT_COUNT = "COUNT";
41
42     private String JavaDoc name;
43     private String JavaDoc unit;
44     private String JavaDoc description;
45     private long startTime;
46     private long lastSampleTime;
47
48     public StatisticImpl(String JavaDoc name, String JavaDoc unit, String JavaDoc description) {
49         this.name = name;
50         this.unit = unit;
51         this.description = description;
52     }
53
54     public String JavaDoc getName() {
55         return name;
56     }
57
58     public String JavaDoc getUnit() {
59         return unit;
60     }
61
62     public String JavaDoc 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 }
90
Popular Tags