1 29 30 package com.caucho.ejb; 31 32 import javax.ejb.EJBException ; 33 34 37 public class EJBExceptionWrapper extends EJBException 38 { 39 private Throwable _rootCause; 40 41 44 public EJBExceptionWrapper() 45 { 46 } 47 52 public EJBExceptionWrapper(String msg) 53 { 54 super(msg); 55 } 56 57 62 public EJBExceptionWrapper(Throwable rootCause) 63 { 64 super(rootCause.toString()); 65 66 _rootCause = rootCause; 67 68 initCause(rootCause); 69 } 70 71 76 public EJBExceptionWrapper(String msg, Throwable rootCause) 77 { 78 super(msg); 79 80 _rootCause = rootCause; 81 82 initCause(rootCause); 83 } 84 85 public Throwable getCause() 86 { 87 return _rootCause; 88 } 89 90 93 public static EJBException create(Throwable rootCause) 94 { 95 if (rootCause instanceof EJBException ) 96 return ((EJBException ) rootCause); 97 else 98 return new EJBExceptionWrapper(rootCause); 99 } 100 101 104 public static RuntimeException createRuntime(Throwable rootCause) 105 { 106 if (rootCause instanceof RuntimeException ) 107 return ((RuntimeException ) rootCause); 108 else 109 return new EJBExceptionWrapper(rootCause); 110 } 111 } 112 113 | Popular Tags |