1 23 24 29 30 package com.sun.enterprise.deployapi; 31 32 import java.io.ByteArrayOutputStream ; 33 import java.io.PrintWriter ; 34 35 import javax.enterprise.deploy.shared.StateType ; 36 import javax.enterprise.deploy.shared.CommandType ; 37 38 43 public class DeploymentStatusImplWithError extends DeploymentStatusImpl { 44 45 46 private Throwable cause = null; 47 48 private CommandType commandType = null; 49 50 51 public DeploymentStatusImplWithError() { 52 } 53 54 55 public DeploymentStatusImplWithError(CommandType commandType, Throwable cause) { 56 super(); 57 initCause(cause); 58 setState(StateType.FAILED); 59 setCommand(commandType); 60 } 61 62 66 public void initCause(Throwable cause) { 67 this.cause = cause; 68 setMessage(cause.getMessage()); 69 } 70 71 75 public Throwable getCause() { 76 return cause; 77 } 78 79 83 public String toString() { 84 StringBuffer result = new StringBuffer (super.toString()); 85 if (cause != null) { 86 String lineSep = System.getProperty("line.separator"); 87 result.append(lineSep).append("Cause: "); 88 ByteArrayOutputStream baos = new ByteArrayOutputStream (); 89 PrintWriter pw = new PrintWriter (baos); 90 cause.printStackTrace(pw); 91 pw.close(); 92 result.append(baos.toString()); 93 } 94 return result.toString(); 95 } 96 } 97 | Popular Tags |