1 22 package org.jboss.deployment; 23 24 import java.io.IOException ; 25 import java.io.ObjectInputStream ; 26 import java.io.ObjectOutputStream ; 27 import java.util.Collection ; 28 import java.util.Iterator ; 29 30 37 public class IncompleteDeploymentException extends DeploymentException 38 { 39 40 private static final long serialVersionUID = 1428860525880893167L; 41 42 43 private transient final Collection mbeansWaitingForClasses; 44 private transient final Collection mbeansWaitingForDepends; 45 private transient final Collection rootCause; 46 private transient final Collection incompletePackages; 47 private transient final Collection waitingForDeployer; 48 49 50 private String string; 51 52 61 public IncompleteDeploymentException(final Collection mbeansWaitingForClasses, 62 final Collection mbeansWaitingForDepends, 63 final Collection rootCause, 64 final Collection incompletePackages, 65 final Collection waitingForDeployer) 66 { 67 if (mbeansWaitingForClasses == null 68 || mbeansWaitingForDepends == null 69 || rootCause == null 70 ||incompletePackages == null 71 || waitingForDeployer == null) 72 { 73 throw new IllegalArgumentException ("All lists in IncompleteDeploymentException constructor must be supplied"); 74 } 76 this.mbeansWaitingForClasses = mbeansWaitingForClasses; 77 this.mbeansWaitingForDepends = mbeansWaitingForDepends; 78 this.rootCause = rootCause; 79 this.incompletePackages = incompletePackages; 80 this.waitingForDeployer = waitingForDeployer; 81 } 82 83 87 public Collection getMbeansWaitingForClasses() 88 { 89 return mbeansWaitingForClasses; 90 } 91 92 96 public Collection getMbeansWaitingForDepends() 97 { 98 return mbeansWaitingForDepends; 99 } 100 101 105 public Collection getIncompletePackages() 106 { 107 return incompletePackages; 108 } 109 110 114 public Collection getWaitingForDeployer() 115 { 116 return waitingForDeployer; 117 } 118 119 122 public boolean isEmpty() 123 { 124 return mbeansWaitingForClasses.size() == 0 125 && mbeansWaitingForDepends.size() == 0 126 && rootCause.size() == 0 127 && incompletePackages.size() == 0 128 && waitingForDeployer.size() == 0; 129 } 130 131 134 public String toString() 135 { 136 if (string != null) 137 { 138 return string; 139 } 140 141 StringBuffer result = new StringBuffer ("Incomplete Deployment listing:\n\n"); 142 if (waitingForDeployer.size() != 0) 143 { 144 result.append("--- Packages waiting for a deployer ---\n"); 145 appendCollection(result, waitingForDeployer); 146 } 147 148 if (incompletePackages.size() != 0) 149 { 150 result.append("--- Incompletely deployed packages ---\n"); 151 appendCollection(result, incompletePackages); 152 } 153 154 if (mbeansWaitingForClasses.size() != 0) 155 { 156 result.append("--- MBeans waiting for classes ---\n"); 157 appendCollection(result, mbeansWaitingForClasses); 158 } 159 160 if (mbeansWaitingForDepends.size() != 0) 161 { 162 result.append("--- MBeans waiting for other MBeans ---\n"); 163 appendCollection(result, mbeansWaitingForDepends); 164 } 165 166 if (rootCause.size() != 0) 167 { 168 result.append("--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---\n"); 169 appendCollection(result, rootCause); 170 } 171 172 string = result.toString(); 173 return string; 174 } 175 176 private void appendCollection(StringBuffer result, Collection c) 177 { 178 for (Iterator i = c.iterator(); i.hasNext();) 179 result.append(i.next().toString()).append('\n'); 180 } 181 182 185 private void readObject(ObjectInputStream s) throws IOException , ClassNotFoundException 186 { 187 s.defaultReadObject(); 188 } 189 190 193 private void writeObject(ObjectOutputStream s) throws IOException 194 { 195 toString(); 196 s.defaultWriteObject(); 197 } 198 199 } 200 | Popular Tags |