1 22 package org.jboss.test.recover.bean; 23 24 import java.rmi.RemoteException ; 25 26 import javax.ejb.CreateException ; 27 import javax.ejb.EJBException ; 28 import javax.naming.Context ; 29 import javax.naming.InitialContext ; 30 import javax.naming.NamingException ; 31 import javax.rmi.PortableRemoteObject ; 32 import javax.transaction.RollbackException ; 33 import javax.transaction.SystemException ; 34 import javax.transaction.Transaction ; 35 import javax.transaction.TransactionManager ; 36 import javax.transaction.xa.XAResource ; 37 38 import org.jboss.logging.Logger; 39 import org.jboss.test.recover.interfaces.XAResourceEnlister; 40 import org.jboss.test.recover.interfaces.XAResourceEnlisterHome; 41 import org.jboss.test.util.ejb.SessionSupport; 42 import org.jboss.tm.recovery.Recoverable; 43 44 50 public class XAResourceEnlisterCallerBean 51 extends SessionSupport 52 { 53 private static final Logger log = 54 Logger.getLogger(XAResourceEnlisterCallerBean.class); 55 56 private TransactionManager tm; 57 private Recoverable recoverable1; 58 private Recoverable recoverable2; 59 private XAResourceEnlister xaResEnlisterJBRem1; 60 private XAResourceEnlister xaResEnlisterJBRem2; 61 private XAResourceEnlister xaResEnlisterIIOP1; 62 private XAResourceEnlister xaResEnlisterIIOP2; 63 64 public void ejbCreate() 65 { 66 try 67 { 68 Context ctx = new InitialContext (); 69 70 tm = (TransactionManager ) ctx.lookup("java:/TransactionManager"); 71 recoverable1 = (Recoverable) ctx.lookup("DummyRecoverableProxy1"); 72 recoverable2 = (Recoverable) ctx.lookup("DummyRecoverableProxy2"); 73 74 Object obj; 75 XAResourceEnlisterHome home; 76 77 obj = ctx.lookup("java:comp/env/ejb/XAResEnlisterJBRem1"); 78 home = (XAResourceEnlisterHome) 79 PortableRemoteObject.narrow(obj, XAResourceEnlisterHome.class); 80 xaResEnlisterJBRem1 = home.create(); 81 82 obj = ctx.lookup("java:comp/env/ejb/XAResEnlisterJBRem2"); 83 home = (XAResourceEnlisterHome) 84 PortableRemoteObject.narrow(obj, XAResourceEnlisterHome.class); 85 xaResEnlisterJBRem2 = home.create(); 86 87 obj = ctx.lookup("java:comp/env/ejb/XAResEnlisterIIOP1"); 88 home = (XAResourceEnlisterHome) 89 PortableRemoteObject.narrow(obj, XAResourceEnlisterHome.class); 90 xaResEnlisterIIOP1 = home.create(); 91 92 obj = ctx.lookup("java:comp/env/ejb/XAResEnlisterIIOP2"); 93 home = (XAResourceEnlisterHome) 94 PortableRemoteObject.narrow(obj, XAResourceEnlisterHome.class); 95 xaResEnlisterIIOP2 = home.create(); 96 } 97 catch (NamingException e) 98 { 99 log.info(e); 100 throw new EJBException (e); 101 } 102 catch (RemoteException e) 103 { 104 log.info(e); 105 throw new EJBException (e); 106 } 107 catch (CreateException e) 108 { 109 log.info(e); 110 throw new EJBException (e); 111 } 112 113 } 114 115 public void callXAResourceEnlistersOverJBRem() 116 { 117 log.info("callXAResourceEnlistersOverJBRem called"); 118 try 119 { 120 Transaction tx = tm.getTransaction(); 121 log.info("tx=" + tx); 122 123 XAResource xaRes1 = recoverable1.getResource(); 125 tx.enlistResource(xaRes1); 126 log.info("enlisted xaRes1=" + xaRes1); 127 XAResource xaRes2 = recoverable2.getResource(); 128 tx.enlistResource(xaRes2); 129 log.info("enlisted xaRes2=" + xaRes2); 130 131 xaResEnlisterJBRem1.method(); 133 xaResEnlisterJBRem2.method(); 134 } 135 catch (SystemException e) 136 { 137 log.info(e); 138 throw new EJBException (e); 139 } 140 catch (RollbackException e) 141 { 142 log.info(e); 143 throw new EJBException (e); 144 } 145 catch (RemoteException e) 146 { 147 log.info(e); 148 throw new EJBException (e); 149 } 150 } 151 152 public void callXAResourceEnlistersOverIIOP() 153 { 154 log.info("callXAResourceEnlistersOverIIOP called"); 155 try 156 { 157 Transaction tx = tm.getTransaction(); 158 log.info("tx=" + tx); 159 160 XAResource xaRes1 = recoverable1.getResource(); 162 tx.enlistResource(xaRes1); 163 log.info("enlisted xaRes1=" + xaRes1); 164 XAResource xaRes2 = recoverable2.getResource(); 165 tx.enlistResource(xaRes2); 166 log.info("enlisted xaRes2=" + xaRes2); 167 168 xaResEnlisterIIOP1.method(); 170 xaResEnlisterIIOP2.method(); 171 } 172 catch (SystemException e) 173 { 174 log.info(e); 175 throw new EJBException (e); 176 } 177 catch (RollbackException e) 178 { 179 log.info(e); 180 throw new EJBException (e); 181 } 182 catch (RemoteException e) 183 { 184 log.info(e); 185 throw new EJBException (e); 186 } 187 } 188 189 public void callXAResourceEnlistersOverJBRemAndIIOP() 190 { 191 log.info("callXAResourceEnlistersOverJBRemAndIIOP called"); 192 try 193 { 194 Transaction tx = tm.getTransaction(); 195 log.info("tx=" + tx); 196 197 XAResource xaRes1 = recoverable1.getResource(); 199 tx.enlistResource(xaRes1); 200 log.info("enlisted xaRes1=" + xaRes1); 201 XAResource xaRes2 = recoverable2.getResource(); 202 tx.enlistResource(xaRes2); 203 log.info("enlisted xaRes2=" + xaRes2); 204 205 xaResEnlisterJBRem1.method(); 207 xaResEnlisterIIOP2.method(); 208 } 209 catch (SystemException e) 210 { 211 log.info(e); 212 throw new EJBException (e); 213 } 214 catch (RollbackException e) 215 { 216 log.info(e); 217 throw new EJBException (e); 218 } 219 catch (RemoteException e) 220 { 221 log.info(e); 222 throw new EJBException (e); 223 } 224 } 225 226 public void callXAResourceEnlistersOverIIOPAndJBRem() 227 { 228 log.info("callXAResourceEnlistersOverIIOPAndJBRem called"); 229 try 230 { 231 Transaction tx = tm.getTransaction(); 232 log.info("tx=" + tx); 233 234 XAResource xaRes1 = recoverable1.getResource(); 236 tx.enlistResource(xaRes1); 237 log.info("enlisted xaRes1=" + xaRes1); 238 XAResource xaRes2 = recoverable2.getResource(); 239 tx.enlistResource(xaRes2); 240 log.info("enlisted xaRes2=" + xaRes2); 241 242 xaResEnlisterIIOP1.method(); 244 xaResEnlisterJBRem2.method(); 245 } 246 catch (SystemException e) 247 { 248 log.info(e); 249 throw new EJBException (e); 250 } 251 catch (RollbackException e) 252 { 253 log.info(e); 254 throw new EJBException (e); 255 } 256 catch (RemoteException e) 257 { 258 log.info(e); 259 throw new EJBException (e); 260 } 261 } 262 263 public void enlistOneXAResourcePerAppServerOverJBRem() 264 { 265 log.info("enlistOneXAResourcePerServerOverJBRem called"); 266 try 267 { 268 Transaction tx = tm.getTransaction(); 269 log.info("tx=" + tx); 270 271 XAResource xaRes1 = recoverable1.getResource(); 273 tx.enlistResource(xaRes1); 274 275 xaResEnlisterJBRem1.enlistXAResource(2); 277 xaResEnlisterJBRem2.enlistXAResource(3); 278 } 279 catch (SystemException e) 280 { 281 log.info(e); 282 throw new EJBException (e); 283 } 284 catch (RollbackException e) 285 { 286 log.info(e); 287 throw new EJBException (e); 288 } 289 catch (RemoteException e) 290 { 291 log.info(e); 292 throw new EJBException (e); 293 } 294 } 295 296 public void enlistOneXAResourcePerAppServerOverIIOP() 297 { 298 log.info("enlistOneXAResourcePerServerOverIIOP called"); 299 try 300 { 301 Transaction tx = tm.getTransaction(); 302 log.info("tx=" + tx); 303 304 XAResource xaRes1 = recoverable1.getResource(); 306 tx.enlistResource(xaRes1); 307 308 xaResEnlisterIIOP1.enlistXAResource(2); 310 xaResEnlisterIIOP2.enlistXAResource(3); 311 } 312 catch (SystemException e) 313 { 314 log.info(e); 315 throw new EJBException (e); 316 } 317 catch (RollbackException e) 318 { 319 log.info(e); 320 throw new EJBException (e); 321 } 322 catch (RemoteException e) 323 { 324 log.info(e); 325 throw new EJBException (e); 326 } 327 } 328 329 public void enlistOneXAResourcePerAppServerOverJBRemAndIIOP() 330 { 331 log.info("enlistOneXAResourcePerServerOverJBRemAndIIOP called"); 332 try 333 { 334 Transaction tx = tm.getTransaction(); 335 log.info("tx=" + tx); 336 337 XAResource xaRes1 = recoverable1.getResource(); 339 tx.enlistResource(xaRes1); 340 341 xaResEnlisterJBRem1.enlistXAResource(2); 343 xaResEnlisterIIOP2.enlistXAResource(3); 344 } 345 catch (SystemException e) 346 { 347 log.info(e); 348 throw new EJBException (e); 349 } 350 catch (RollbackException e) 351 { 352 log.info(e); 353 throw new EJBException (e); 354 } 355 catch (RemoteException e) 356 { 357 log.info(e); 358 throw new EJBException (e); 359 } 360 } 361 362 public void enlistOneXAResourcePerAppServerOverIIOPAndJBRem() 363 { 364 log.info("enlistOneXAResourcePerServerOverIIOPAndJBRem called"); 365 try 366 { 367 Transaction tx = tm.getTransaction(); 368 log.info("tx=" + tx); 369 370 XAResource xaRes1 = recoverable1.getResource(); 372 tx.enlistResource(xaRes1); 373 374 xaResEnlisterIIOP1.enlistXAResource(2); 376 xaResEnlisterJBRem2.enlistXAResource(3); 377 } 378 catch (SystemException e) 379 { 380 log.info(e); 381 throw new EJBException (e); 382 } 383 catch (RollbackException e) 384 { 385 log.info(e); 386 throw new EJBException (e); 387 } 388 catch (RemoteException e) 389 { 390 log.info(e); 391 throw new EJBException (e); 392 } 393 } 394 395 } 396 | Popular Tags |