1 22 package org.jboss.test.exception; 23 24 import java.rmi.RemoteException ; 25 import javax.ejb.CreateException ; 26 import javax.ejb.EJBException ; 27 import javax.ejb.EntityBean ; 28 import javax.ejb.EntityContext ; 29 import javax.ejb.FinderException ; 30 31 37 public class EntityExceptionTesterBean 38 implements EntityBean 39 { 40 private EntityContext ctx; 41 42 String key; 43 44 public String ejbCreate(String key) 45 throws CreateException 46 { 47 this.key = key; 48 return key; 49 } 50 51 public void ejbPostCreate(String key) 52 throws CreateException 53 { 54 } 55 56 public String ejbFindByPrimaryKey(String key) 57 throws FinderException 58 { 59 throw new FinderException ("Error, bean instance was discarded!"); 60 } 61 62 public String getKey() 63 { 64 return key; 65 } 66 67 public void applicationExceptionInTx() 68 throws ApplicationException 69 { 70 throw new ApplicationException("Application exception from within " + 71 "an inherited transaction"); 72 } 73 74 public void applicationExceptionInTxMarkRollback() 75 throws ApplicationException 76 { 77 ctx.setRollbackOnly(); 78 throw new ApplicationException("Application exception from within " + 79 "an inherited transaction"); 80 } 81 82 public void applicationErrorInTx() 83 { 84 throw new ApplicationError("Application error from within " + 85 "an inherited transaction"); 86 } 87 88 public void ejbExceptionInTx() 89 { 90 throw new EJBException ("EJB exception from within " + 91 "an inherited transaction"); 92 } 93 94 public void runtimeExceptionInTx() 95 { 96 throw new RuntimeException ("Runtime exception from within " + 97 "an inherited transaction"); 98 } 99 100 public void remoteExceptionInTx() 101 throws RemoteException 102 { 103 throw new RemoteException ("Remote exception from within " + 104 "an inherited transaction"); 105 } 106 107 public void applicationExceptionNewTx() 108 throws ApplicationException 109 { 110 throw new ApplicationException("Application exception from within " + 111 "a new container transaction"); 112 } 113 114 public void applicationExceptionNewTxMarkRollback() 115 throws ApplicationException 116 { 117 ctx.setRollbackOnly(); 118 throw new ApplicationException("Application exception from within " + 119 "a new container transaction"); 120 } 121 122 public void applicationErrorNewTx() 123 { 124 throw new ApplicationError("Application error from within " + 125 "a new container transaction"); 126 } 127 128 public void ejbExceptionNewTx() 129 { 130 throw new EJBException ("EJB exception from within " + 131 "a new container transaction"); 132 } 133 134 public void runtimeExceptionNewTx() 135 { 136 throw new RuntimeException ("Runtime exception from within " + 137 "a new container transaction"); 138 } 139 140 public void remoteExceptionNewTx() 141 throws RemoteException 142 { 143 throw new RemoteException ("Remote exception from within " + 144 "a new container transaction"); 145 } 146 147 public void applicationExceptionNoTx() 148 throws ApplicationException 149 { 150 throw new ApplicationException("Application exception without " + 151 "a transaction"); 152 } 153 154 public void applicationErrorNoTx() 155 { 156 throw new ApplicationError("Application error from within " + 157 " an inherited transaction"); 158 } 159 160 public void ejbExceptionNoTx() 161 { 162 throw new EJBException ("EJB exception without " + 163 "a transaction"); 164 } 165 166 public void runtimeExceptionNoTx() 167 { 168 throw new RuntimeException ("Runtime exception without " + 169 "a transaction"); 170 } 171 172 public void remoteExceptionNoTx() 173 throws RemoteException 174 { 175 throw new RemoteException ("Remote exception without " + 176 "a transaction"); 177 } 178 179 public void setEntityContext(EntityContext ctx) 180 { 181 this.ctx = ctx; 182 } 183 184 public void unsetEntityContext() 185 { 186 } 187 188 public void ejbLoad() 189 { 190 } 191 192 public void ejbStore() 193 { 194 } 195 196 public void ejbActivate() 197 { 198 } 199 200 public void ejbPassivate() 201 { 202 } 203 204 public void ejbRemove() 205 { 206 } 207 } | Popular Tags |