1 24 package org.objectweb.joram.shared.client; 25 26 import java.io.Externalizable ; 27 import java.io.InputStream ; 28 import java.io.OutputStream ; 29 import java.io.IOException ; 30 import java.util.Vector ; 31 32 import org.objectweb.joram.shared.stream.Streamable; 33 import org.objectweb.joram.shared.stream.StreamUtil; 34 35 40 public final class XACnxPrepare extends AbstractJmsRequest { 41 42 private byte[] bq; 43 44 45 public byte[] getBQ() { 46 return bq; 47 } 48 49 public void setBQ(byte[] bq) { 50 this.bq = bq; 51 } 52 53 54 private int fi; 55 56 57 public int getFI() { 58 return fi; 59 } 60 61 public void setFI(int fi) { 62 this.fi = fi; 63 } 64 65 66 private byte[] gti; 67 68 69 public byte[] getGTI() { 70 return gti; 71 } 72 73 public void setGTI(byte[] gti) { 74 this.gti = gti; 75 } 76 77 78 private Vector sendings; 79 80 81 public Vector getSendings() { 82 if (sendings == null) 83 sendings = new Vector (); 84 return sendings; 85 } 86 87 public void addProducerMessages(ProducerMessages pm) { 88 sendings.addElement(pm); 89 } 90 91 92 private Vector acks; 93 94 95 public Vector getAcks() { 96 if (acks == null) 97 acks = new Vector (); 98 return acks; 99 } 100 101 public void addSessAckRequest(SessAckRequest sar) { 102 acks.addElement(sar); 103 } 104 105 protected int getClassId() { 106 return XA_CNX_PREPARE; 107 } 108 109 118 public XACnxPrepare(byte[] bq, 119 int fi, 120 byte[] gti, 121 Vector sendings, 122 Vector acks) { 123 super(); 124 this.bq = bq; 125 this.fi = fi; 126 this.gti = gti; 127 this.sendings = sendings; 128 this.acks = acks; 129 } 130 131 public XACnxPrepare() { 132 super(null); 133 sendings = new Vector (); 134 acks = new Vector (); 135 } 136 137 140 141 147 public void writeTo(OutputStream os) throws IOException { 148 super.writeTo(os); 149 StreamUtil.writeTo(bq, os); 150 StreamUtil.writeTo(fi, os); 151 StreamUtil.writeTo(gti, os); 152 if (sendings == null) { 153 StreamUtil.writeTo(-1, os); 154 } else { 155 int size = sendings.size(); 156 StreamUtil.writeTo(size, os); 157 for (int i=0; i<size; i++) { 158 ((ProducerMessages) sendings.elementAt(i)).writeTo(os); 159 } 160 } 161 if (acks == null) { 162 StreamUtil.writeTo(-1, os); 163 } else { 164 int size = acks.size(); 165 StreamUtil.writeTo(size, os); 166 for (int i=0; i<size; i++) { 167 ((SessAckRequest) acks.elementAt(i)).writeTo(os); 168 } 169 } 170 } 171 172 178 public void readFrom(InputStream is) throws IOException { 179 super.readFrom(is); 180 bq = StreamUtil.readByteArrayFrom(is); 181 fi = StreamUtil.readIntFrom(is); 182 gti = StreamUtil.readByteArrayFrom(is); 183 int size = StreamUtil.readIntFrom(is); 184 if (size == -1) { 185 sendings = null; 186 } else { 187 sendings = new Vector (size); 188 for (int i=0; i<size; i++) { 189 ProducerMessages pm = new ProducerMessages(); 190 pm.readFrom(is); 191 sendings.addElement(pm); 192 } 193 } 194 size = StreamUtil.readIntFrom(is); 195 if (size == -1) { 196 acks = null; 197 } else { 198 acks = new Vector (size); 199 for (int i=0; i<size; i++) { 200 SessAckRequest ack = new SessAckRequest(); 201 ack.readFrom(is); 202 acks.addElement(ack); 203 } 204 } 205 } 206 } 207 | Popular Tags |