1 23 24 25 package org.objectweb.clif.supervisor.api; 26 27 28 import java.io.Serializable ; 29 import java.util.Collection ; 30 31 32 36 public class BladeState implements Serializable 37 { 38 static private int instanceCount = 0; 39 static private BladeState[] instances = new BladeState[14]; 40 static public final BladeState UNDEPLOYED = new BladeState("undeployed"); 41 static public final BladeState DEPLOYING = new BladeState("deploying"); 42 static public final BladeState DEPLOYED = new BladeState("deployed"); 43 static public final BladeState INITIALIZING = new BladeState("initializing"); 44 static public final BladeState INITIALIZED = new BladeState("initialized"); 45 static public final BladeState STARTING = new BladeState("starting"); 46 static public final BladeState RUNNING = new BladeState("running"); 47 static public final BladeState SUSPENDING = new BladeState("suspending"); 48 static public final BladeState SUSPENDED = new BladeState("suspended"); 49 static public final BladeState RESUMING = new BladeState("resuming"); 50 static public final BladeState COMPLETED = new BladeState("completed"); 51 static public final BladeState STOPPING = new BladeState("stopping"); 52 static public final BladeState STOPPED = new BladeState("stopped"); 53 static public final BladeState ABORTED = new BladeState("aborted"); 54 55 56 static public BladeState get(int code) 57 { 58 return instances[code]; 59 } 60 61 62 static public BladeState getGlobalState(Collection states) 63 { 64 BladeState result = null; 65 if (states.contains(BladeState.DEPLOYING)) 67 { 68 result = BladeState.DEPLOYING; 69 } 70 else if (states.contains(BladeState.INITIALIZING)) 71 { 72 result = BladeState.INITIALIZING; 73 } 74 else if (states.contains(BladeState.STARTING)) 75 { 76 result = BladeState.STARTING; 77 } 78 else if (states.contains(BladeState.SUSPENDING)) 79 { 80 result = BladeState.SUSPENDING; 81 } 82 else if (states.contains(BladeState.RESUMING)) 83 { 84 result = BladeState.RESUMING; 85 } 86 else if (states.contains(BladeState.STOPPING)) 87 { 88 result = BladeState.STOPPING; 89 } 90 else if (states.contains(BladeState.UNDEPLOYED)) 92 { 93 result = BladeState.UNDEPLOYED; 94 } 95 else if (states.contains(BladeState.DEPLOYED)) 96 { 97 result = BladeState.DEPLOYED; 98 } 99 else if (states.contains(BladeState.INITIALIZED)) 100 { 101 result = BladeState.INITIALIZED; 102 } 103 else if (states.contains(BladeState.RUNNING)) 104 { 105 result = BladeState.RUNNING; 106 } 107 else if (states.contains(SUSPENDED)) 108 { 109 result = BladeState.SUSPENDED; 110 } 111 else 112 { 113 result = BladeState.STOPPED; 114 } 115 return result; 116 } 117 118 119 int code; 120 transient String label; 121 122 123 protected BladeState(String label) 124 { 125 code = instanceCount; 126 this.label = label; 127 instances[instanceCount++] = this; 128 } 129 130 131 public String toString() 132 { 133 return label; 134 } 135 136 137 public int getCode() 138 { 139 return code; 140 } 141 142 143 public boolean equals(Object obj) 144 { 145 return code == ((BladeState)obj).code; 146 } 147 148 149 private Object readResolve() 150 { 151 return instances[code]; 152 } 153 } 154 | Popular Tags |