01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: */package org.apache.geronimo.management.stats;
17:
18: import javax.management.j2ee.statistics.RangeStatistic;
19:
20: /**
21: * @version $Rev: 503407 $ $Date: 2007-02-04 05:57:40 -0800 (Sun, 04 Feb 2007) $
22: */
23: public class RangeStatisticImpl extends StatisticImpl implements
24: RangeStatistic {
25: private long highWaterMark;
26: private long lowWaterMark;
27: private long current;
28:
29: public RangeStatisticImpl(String name, String unit,
30: String description) {
31: super (name, unit, description);
32: }
33:
34: public RangeStatisticImpl(String name, String unit,
35: String description, long currentValue) {
36: super (name, unit, description);
37: highWaterMark = lowWaterMark = current = currentValue;
38: }
39:
40: public long getHighWaterMark() {
41: return highWaterMark;
42: }
43:
44: public long getLowWaterMark() {
45: return lowWaterMark;
46: }
47:
48: public long getCurrent() {
49: return current;
50: }
51:
52: public void setCurrent(long current) {
53: this .current = current;
54: if (current < lowWaterMark) {
55: lowWaterMark = current;
56: }
57: if (current > highWaterMark) {
58: highWaterMark = current;
59: }
60: }
61:
62: public void setHighWaterMark(long highWaterMark) {
63: this .highWaterMark = highWaterMark;
64: }
65:
66: public void setLowWaterMark(long lowWaterMark) {
67: this .lowWaterMark = lowWaterMark;
68: }
69:
70: public String toString() {
71: return (getName() + " in " + getUnit() + " -- current: "
72: + current + ", highWaterMark: " + highWaterMark
73: + ", lowWaterMark: " + lowWaterMark);
74: }
75: }
|