1 45 package org.exolab.jms.client; 46 47 import javax.transaction.xa.XAException ; 48 import javax.transaction.xa.XAResource ; 49 import javax.transaction.xa.Xid ; 50 51 import org.exolab.jms.server.ServerSession; 52 53 63 class JmsXAResource implements XAResource { 64 65 68 private ServerSession _session; 69 70 73 private String _rmId = null; 74 75 76 81 public JmsXAResource(ServerSession session) { 82 if (session == null) { 83 throw new IllegalArgumentException ("Argument 'session' is null"); 84 } 85 _session = session; 86 87 } 88 89 103 public void start(Xid xid, int flags) 104 throws XAException { 105 _session.start(xid, flags); 106 } 107 108 120 public int prepare(Xid xid) throws XAException { 121 return _session.prepare(xid); 122 } 123 124 133 public void commit(Xid xid, boolean onePhase) 134 throws XAException { 135 _session.commit(xid, onePhase); 136 } 137 138 139 149 public void end(Xid xid, int flags) 150 throws XAException { 151 _session.end(xid, flags); 152 } 153 154 161 public void forget(Xid xid) 162 throws XAException { 163 _session.forget(xid); 164 } 165 166 176 public int getTransactionTimeout() 177 throws XAException { 178 return _session.getTransactionTimeout(); 179 } 180 181 195 public boolean setTransactionTimeout(int seconds) 196 throws XAException { 197 return _session.setTransactionTimeout(seconds); 198 } 199 200 211 public boolean isSameRM(XAResource xares) throws XAException { 212 boolean result = (xares instanceof JmsXAResource); 213 if (result) { 214 JmsXAResource other = (JmsXAResource) xares; 215 result = (other.getResourceManagerId() == getResourceManagerId()); 216 } 217 218 return result; 219 } 220 221 235 public Xid [] recover(int flag) 236 throws XAException { 237 return _session.recover(flag); 238 } 239 240 247 public void rollback(Xid xid) 248 throws XAException { 249 _session.rollback(xid); 250 } 251 252 259 public synchronized String getResourceManagerId() throws XAException { 260 if (_rmId == null) { 261 _rmId = _session.getResourceManagerId(); 262 } 263 return _rmId; 264 } 265 266 } 267 | Popular Tags |