1 39 package org.objectweb.jotm.jta.rmi; 40 41 import java.io.Externalizable ; 43 import java.io.IOException ; 44 import java.io.ObjectInput ; 45 import java.io.ObjectOutput ; 46 47 import org.objectweb.jotm.Xid; 49 50 import org.objectweb.carol.rmi.jrmp.interceptor.JServiceContext; 51 import org.objectweb.jotm.Coordinator; 52 import org.objectweb.jotm.InternalTransactionContext; 53 import org.objectweb.jotm.TransactionContext; 54 import org.objectweb.jotm.XidImpl; 55 56 63 public class JTATransactionServiceContext 64 implements JServiceContext, Externalizable { 65 66 69 transient TransactionContext txCtx = null; 70 71 74 transient boolean isReply; 75 76 79 private transient int context_id; 80 81 84 public JTATransactionServiceContext() { 85 this.context_id = JTAClientTransactionInterceptor.TX_CTX_ID; 86 } 87 88 91 public int getContextId() { 92 return context_id; 93 } 94 95 100 public void setContext(TransactionContext txCtx, boolean isReply) { 101 this.txCtx = txCtx; 102 this.isReply = isReply; 103 } 104 105 109 public TransactionContext getTransactionContext() { 110 return txCtx; 111 } 112 113 117 public void readExternal(ObjectInput in) 118 throws IOException , ClassNotFoundException { 119 int fid = in.readInt(); 121 byte[] gti = new byte[in.readInt()]; 122 in.read(gti); 123 byte[] bq = new byte[in.readInt()]; 124 in.read(bq); 125 Xid xid = new XidImpl(fid, gti, bq); 126 Coordinator coor = (Coordinator) in.readObject(); 128 int timeout = in.readInt(); 130 this.txCtx = new InternalTransactionContext(timeout, coor, (javax.transaction.xa.Xid ) xid); 131 } 132 133 137 public void writeExternal(ObjectOutput out) throws IOException { 138 Xid xid = txCtx.getXid(); 140 out.writeInt(xid.getFormatId()); 141 out.writeInt(xid.getGlobalTransactionId().length); 142 out.write(xid.getGlobalTransactionId()); 143 out.writeInt(xid.getBranchQualifier().length); 144 out.write(xid.getBranchQualifier()); 145 out.writeObject(txCtx.getCoordinator()); 147 out.writeInt(txCtx.getTimeout()); 149 } 150 } 151 | Popular Tags |