01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package jmx;
05:
06: import java.util.ArrayList;
07:
08: /**
09: * Example of a Standard Bean using various data types
10: */
11: public class SimpleStandard extends TCStandardBean implements
12: SimpleStandardMBean {
13:
14: private static final String INIT_STATE = "Initial State";
15:
16: private String _state = null;
17: private ArrayList _allStates = new ArrayList();
18: private int _changeCount = 0;
19:
20: public SimpleStandard() {
21: setState(INIT_STATE);
22: }
23:
24: /**
25: *
26: */
27:
28: public String getState() {
29: return _state;
30: }
31:
32: public String[] getAllStates() {
33: String rv[] = new String[_allStates.size()];
34: _allStates.toArray(rv);
35: return rv;
36: }
37:
38: /**
39: *
40: */
41:
42: public void setState(String s) {
43: System.err.println("Setting state to: " + s);
44: _state = s;
45: _allStates.add(s);
46: _changeCount++;
47: }
48:
49: /**
50: *
51: */
52:
53: public Integer getNbChanges() {
54: return new Integer(_changeCount);
55: }
56:
57: public int getNbChangesInt() {
58: return _changeCount;
59: }
60:
61: /**
62: *
63: */
64:
65: public void reset() {
66: _state = INIT_STATE;
67: _changeCount = 0;
68: _allStates.clear();
69: }
70:
71: }
|