1 23 24 package org.objectweb.dream; 25 26 import java.io.PrintStream ; 27 28 import org.objectweb.fractal.api.Component; 29 import org.objectweb.fractal.api.Interface; 30 import org.objectweb.fractal.api.NoSuchInterfaceException; 31 import org.objectweb.fractal.julia.Util; 32 33 36 public class InitializationException extends Exception 37 { 38 39 42 private final Throwable exception; 43 44 47 private transient Component component; 48 49 56 public InitializationException(final Throwable exception, 57 final Component component, final String message) 58 { 59 super(message); 60 this.exception = exception; 61 this.component = component; 62 } 63 64 69 70 public Throwable getException() 71 { 72 return exception; 73 } 74 75 80 81 public Component getComponent() 82 { 83 if (component != null && !(component instanceof Interface)) 84 { 85 try 86 { 87 return (Component) component.getFcInterface("component"); 88 } 89 catch (NoSuchInterfaceException ignored) 90 { 91 } 92 } 93 return component; 94 } 95 96 100 103 public String toString() 104 { 105 StringBuffer buf = new StringBuffer (); 106 buf.append("InitializationException: "); 107 buf.append(getMessage()); 108 if (getComponent() != null) 109 { 110 buf.append(" (component = "); 111 Util.toString(getComponent(), buf); 112 buf.append(')'); 113 } 114 return buf.toString(); 115 } 116 117 120 public void printStackTrace(final PrintStream s) 121 { 122 super.printStackTrace(s); 123 if (exception != null) 124 { 125 s.print("Caused by : "); 126 exception.printStackTrace(s); 127 } 128 } 129 } | Popular Tags |