1 23 24 package com.sun.gjc.spi; 25 26 import javax.transaction.xa.Xid ; 27 import javax.transaction.xa.XAException ; 28 import javax.transaction.xa.XAResource ; 29 import com.sun.gjc.spi.ManagedConnection; 30 31 37 public class XAResourceImpl implements XAResource { 38 39 XAResource xar; 40 ManagedConnection mc; 41 42 48 public XAResourceImpl(XAResource xar, ManagedConnection mc) { 49 this.xar = xar; 50 this.mc = mc; 51 } 52 53 60 public void commit(Xid xid, boolean onePhase) throws XAException { 61 try{ 68 xar.commit(xid, onePhase); 69 }catch(XAException xae){ 70 throw xae; 71 }catch(Exception e){ 72 throw new XAException (e.getMessage()); 73 }finally{ 74 mc.transactionCompleted(); 75 } 76 } 77 78 85 public void end(Xid xid, int flags) throws XAException { 86 xar.end(xid, flags); 87 } 90 91 96 public void forget(Xid xid) throws XAException { 97 xar.forget(xid); 98 } 99 100 106 public int getTransactionTimeout() throws XAException { 107 return xar.getTransactionTimeout(); 108 } 109 110 119 public boolean isSameRM(XAResource xares) throws XAException { 120 return xar.isSameRM(xares); 121 } 122 123 134 public int prepare(Xid xid) throws XAException { 135 try{ 136 return xar.prepare(xid); 137 }catch(XAException xae){ 138 mc.transactionCompleted(); 139 throw xae; 140 }catch(Exception e){ 141 mc.transactionCompleted(); 142 throw new XAException (e.getMessage()); 143 } 144 } 145 146 156 public Xid [] recover(int flag) throws XAException { 157 return xar.recover(flag); 158 } 159 160 165 public void rollback(Xid xid) throws XAException { 166 try{ 173 xar.rollback(xid); 174 }catch(XAException xae){ 175 throw xae; 176 }catch(Exception e){ 177 throw new XAException (e.getMessage()); 178 }finally{ 179 mc.transactionCompleted(); 180 } 181 } 182 183 189 public boolean setTransactionTimeout(int seconds) throws XAException { 190 return xar.setTransactionTimeout(seconds); 191 } 192 193 199 public void start(Xid xid, int flags) throws XAException { 200 mc.transactionStarted(); 202 xar.start(xid, flags); 203 } 204 } 205 | Popular Tags |