1 23 24 package com.sun.enterprise.admin.common; 25 26 import com.sun.enterprise.util.LocalStringsImpl; 27 import java.io.Serializable ; 29 30 34 public class Status implements Serializable 35 { 36 37 public static final long serialVersionUID = -211313166471337363L; 38 public static final int kInstanceRunningCode = 0; 39 public static final int kInstanceStartingCode = 1; 40 public static final int kInstanceStoppingCode = 2; 41 public static final int kInstanceNotRunningCode = 3; 42 public static final int kEntityEnabledCode = 4; 43 public static final int kEntityDisabledCode = 5; 44 public static final int kClusterPartiallyRunningCode = 6; 45 public static final int kInstanceSynchronizingCode = 7; 46 public static final int kInstanceFailedCode = 8; 47 48 public static final String kInstanceRunningMsg; 49 public static final String kInstanceStartingMsg; 50 public static final String kInstanceStoppingMsg; 51 public static final String kInstanceNotRunningMsg; 52 public static final String kUnknownStateMsg; 53 public static final String kPartiallyRunningMsg; 54 public static final String kInstanceSynchronizingMsg; 55 public static final String kInstanceFailedMsg; 56 57 protected int mStatusCode; 58 protected String mStatusString; 59 60 static 61 { 62 String pre = "admin.common.status."; 64 LocalStringsImpl ls = new LocalStringsImpl(); 65 66 kInstanceRunningMsg = ls.get(pre + "0"); 67 kInstanceStartingMsg = ls.get(pre + "1"); 68 kInstanceStoppingMsg = ls.get(pre + "2"); 69 kInstanceNotRunningMsg = ls.get(pre + "3"); 70 kUnknownStateMsg = ls.get(pre + "4"); 71 kPartiallyRunningMsg = ls.get(pre + "6"); 72 kInstanceSynchronizingMsg = ls.get(pre + "7"); 73 kInstanceFailedMsg = ls.get(pre + "8"); 74 } 75 76 80 protected Status() 81 { 82 } 83 84 87 public Status (int code, String str) 88 { 89 mStatusCode = code; 90 mStatusString = str; 91 } 92 93 public Status (int code) 94 { 95 mStatusCode = code; 96 mStatusString = getStatusString(code); 97 } 98 99 104 public int getStatusCode() 105 { 106 return mStatusCode; 107 } 108 109 114 public String getStatusString() 115 { 116 return mStatusString; 117 } 118 119 122 public String toString() 123 { 124 return (mStatusCode + " : " + mStatusString); 125 } 126 127 public static String getStatusString(int code) 128 { 129 String status = kUnknownStateMsg; 130 switch (code) 131 { 132 case kInstanceNotRunningCode : 133 status = kInstanceNotRunningMsg; 134 break; 135 case kInstanceRunningCode : 136 status = kInstanceRunningMsg; 137 break; 138 case kInstanceStartingCode : 139 status = kInstanceStartingMsg; 140 break; 141 case kInstanceFailedCode : 142 status = kInstanceFailedMsg; 143 break; 144 case kInstanceStoppingCode : 145 status = kInstanceStoppingMsg; 146 break; 147 case kClusterPartiallyRunningCode : 148 status = kPartiallyRunningMsg; 149 break; 150 case kInstanceSynchronizingCode : 151 status = kInstanceSynchronizingMsg; 152 break; 153 default : 154 break; 155 } 156 return status; 157 } 158 } 159 | Popular Tags |