01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.management.beans;
06:
07: import com.tc.l2.state.StateManager;
08: import com.tc.util.State;
09:
10: import java.util.HashMap;
11: import java.util.Map;
12:
13: public class StateChangeNotificationInfo {
14: // order matters: msg, attribute name, attribute type
15: private static final String[] ACTIVE_INFO = new String[] {
16: "TCServer active", "Active", "jmx.terracotta.L2.active" };
17: private static final String[] PASSIVE_UNINIT_INFO = new String[] {
18: "TCServer passive-uninitialized", "Paasive-Uninitialized",
19: "jmx.terracotta.L2.passive-uninitialized" };
20: private static final String[] PASSIVE_STANDBY_INFO = new String[] {
21: "TCServer passive-standby", "Passive-Standby",
22: "jmx.terracotta.L2.passive-standby" };
23: private static final String[] START_INFO = new String[] {
24: "TCServer start-state", "Start-State",
25: "jmx.terracotta.L2.start-state" };
26: private static final String[] STOP_INFO = new String[] {
27: "TCServer stop-state", "Stop-State",
28: "jmx.terracotta.L2.stop-state" };
29:
30: private final Map map;
31:
32: public StateChangeNotificationInfo() {
33: map = new HashMap();
34: map.put(StateManager.ACTIVE_COORDINATOR.getName(), ACTIVE_INFO);
35: map.put(StateManager.PASSIVE_STANDBY.getName(),
36: PASSIVE_STANDBY_INFO);
37: map.put(StateManager.PASSIVE_UNINTIALIZED.getName(),
38: PASSIVE_UNINIT_INFO);
39: map.put(StateManager.START_STATE.getName(), START_INFO);
40: map.put(StateManager.STOP_STATE.getName(), STOP_INFO);
41: }
42:
43: public String getMsg(State state) {
44: String[] info = (String[]) map.get(state.getName());
45: return info[0];
46: }
47:
48: public String getAttributeName(State state) {
49: String[] info = (String[]) map.get(state.getName());
50: return info[1];
51: }
52:
53: public String getAttributeType(State state) {
54: String[] info = (String[]) map.get(state.getName());
55: return info[2];
56: }
57:
58: }
|