1 23 24 29 30 package com.sun.enterprise.admin.servermgmt; 31 32 import com.sun.enterprise.admin.common.Status; 33 34 import java.io.Serializable ; 35 import java.util.ArrayList ; 36 37 42 public class RuntimeStatusList extends ArrayList implements Serializable { 43 44 public RuntimeStatusList() { 45 super(); 46 } 47 48 public RuntimeStatusList(int capacity) 49 { 50 super(capacity); 51 } 52 53 59 public RuntimeStatus getStatus(int index) throws IndexOutOfBoundsException 60 { 61 return (RuntimeStatus)super.get(index); 62 } 63 64 65 69 public boolean anyRunning() 70 { 71 return numRunning() > 0 ? true : false; 72 } 73 74 79 public boolean allRunning() 80 { 81 if (isEmpty()) { 82 return false; 83 } else { 84 return numRunning() == size() ? true : false; 85 } 86 } 87 88 92 public int numRunning() 93 { 94 int count = 0; 95 for (int i = 0; i < size(); i++) { 96 if (((RuntimeStatus)get(i)).isRunning()) { 97 count++; 98 } 99 } 100 return count; 101 } 102 103 108 public int numNeedingRestart() 109 { 110 int count = 0; 111 for (int i = 0; i < size(); i++) { 112 if (((RuntimeStatus)get(i)).isRunning() && 114 ((RuntimeStatus)get(i)).isRestartNeeded()) 115 { 116 count++; 117 } 118 } 119 return count; 120 } 121 122 126 public int numStopped() 127 { 128 return size() - numRunning(); 129 } 130 131 135 public boolean isEmpty() 136 { 137 return size() == 0 ? true : false; 138 } 139 140 141 146 public String toString() 147 { 148 if (allRunning()) { 149 return Status.getStatusString(Status.kInstanceRunningCode); 150 } else if (anyRunning()) { 151 return Status.getStatusString(Status.kClusterPartiallyRunningCode); 152 } else { 153 return Status.getStatusString(Status.kInstanceNotRunningCode); 154 } 155 } 156 } 157 158 | Popular Tags |