01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: package mx4j.tools.stats;
10:
11: import java.util.Date;
12:
13: /**
14: * ValueStatisticsRecorder records statistics of an attribute
15: * based on changes on the variable value. If you want to use you have to explictly
16: * set the variable value.
17: * <p/>
18: * Example usage:
19: * <pre>
20: * ObjectName name = new ObjectName("Domain:name=value");
21: * server.createMBean("mx4j.tools.stats.ValueStatisticsRecorder", name, null);
22: * server.invoke(name, "start", null, null);
23: * // Every time the value is set the statistics are updated
24: * server.setAttribute(name, "Attribute", new Double(10));
25: * </pre>
26: *
27: * @version $Revision: 1.5 $
28: */
29: public class ValueStatisticsRecorder extends AbstractStatisticsRecorder
30: implements ValueStatisticsRecorderMBean {
31: protected Number value = null;
32:
33: public void setValue(Number value) {
34: this .value = value;
35: addEntry(new Date(), value);
36: }
37:
38: public Number getValue() {
39: return value;
40: }
41:
42: public String toString() {
43: return "ValueStatisticsRecorder";
44: }
45:
46: }
|