1 22 package org.jboss.system; 23 24 import java.util.Arrays ; 25 import java.util.HashSet ; 26 import java.util.Set ; 27 28 import org.jboss.util.state.State; 29 import org.jboss.util.state.StateMachine; 30 import org.jboss.util.state.Transition; 31 32 40 public final class ServiceMBeanState 41 { 42 public static final State STATE_UNREGISTERED = new State("Unregistered"); public static final State STATE_REGISTERED = new State("Registered"); 45 public static final State STATE_CREATED = new State("Created"); 46 public static final State STATE_STARTING = new State("Starting"); 47 public static final State STATE_STARTED = new State("Started"); 48 public static final State STATE_STOPPING = new State("Stopping"); 49 public static final State STATE_STOPPED = new State("Stopped"); 50 public static final State STATE_DESTROYED = new State("Destroyed"); 51 public static final State STATE_FAILED = new State("Failed"); 52 53 public static final Transition TRANS_REGISTER = new Transition("register", STATE_REGISTERED); 55 public static final Transition TRANS_CREATE = new Transition("create", STATE_CREATED); 56 public static final Transition TRANS_START_BEGIN = new Transition("startBegin", STATE_STARTING); 57 public static final Transition TRANS_START_END = new Transition("startEnd", STATE_STARTED); 58 public static final Transition TRANS_STOP_BEGIN = new Transition("stopBegin", STATE_STOPPING); 59 public static final Transition TRANS_STOP_END = new Transition("stopEnd", STATE_STOPPED); 60 public static final Transition TRANS_DESTROY = new Transition("destroy", STATE_DESTROYED); 61 public static final Transition TRANS_UNREGISTER = new Transition("unregister", STATE_UNREGISTERED); 62 public static final Transition TRANS_FAIL = new Transition("fail", STATE_FAILED); 63 64 65 public static final Set STATES = new HashSet ( 66 Arrays.asList(new State[] { 67 STATE_UNREGISTERED, 68 STATE_REGISTERED, 69 STATE_CREATED, 70 STATE_STARTING, 71 STATE_STARTED, 72 STATE_STOPPING, 73 STATE_STOPPED, 74 STATE_DESTROYED, 75 STATE_FAILED 76 })); 77 78 static 81 { 82 STATE_UNREGISTERED 83 .addTransition(TRANS_REGISTER) 84 .addTransition(TRANS_FAIL); 85 86 STATE_REGISTERED 87 .addTransition(TRANS_CREATE) 88 .addTransition(TRANS_UNREGISTER) 89 .addTransition(TRANS_FAIL); 90 91 STATE_CREATED 92 .addTransition(TRANS_START_BEGIN) 93 .addTransition(TRANS_DESTROY) 94 .addTransition(TRANS_FAIL); 95 96 STATE_STARTING 97 .addTransition(TRANS_START_END) 98 .addTransition(TRANS_FAIL); 99 100 STATE_STARTED 101 .addTransition(TRANS_STOP_BEGIN) 102 .addTransition(TRANS_FAIL); 103 104 STATE_STOPPING 105 .addTransition(TRANS_STOP_END) 106 .addTransition(TRANS_FAIL); 107 108 STATE_STOPPED 109 .addTransition(TRANS_START_BEGIN) 110 .addTransition(TRANS_DESTROY) 111 .addTransition(TRANS_FAIL); 112 113 STATE_DESTROYED 114 .addTransition(TRANS_CREATE) 115 .addTransition(TRANS_UNREGISTER) 116 .addTransition(TRANS_FAIL); 117 118 } 120 121 128 public static StateMachine createStateMachine(String description) 129 { 130 return new StateMachine(STATES, STATE_UNREGISTERED, description); 131 } 132 133 136 private ServiceMBeanState() 137 { 138 } 140 141 } 142 | Popular Tags |