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 31 import java.util.Vector ; 32 import java.util.Enumeration ; 33 import java.util.Hashtable ; 34 35 import org.objectweb.joram.shared.stream.Streamable; 36 import org.objectweb.joram.shared.stream.StreamUtil; 37 38 43 public final class XACnxRollback extends AbstractJmsRequest { 44 45 private byte[] bq; 46 47 public void setBQ(byte[] bq) { 48 this.bq = bq; 49 } 50 51 52 public byte[] getBQ() { 53 return bq; 54 } 55 56 57 private int fi; 58 59 public void setFI(int fi) { 60 this.fi = fi; 61 } 62 63 64 public int getFI() { 65 return fi; 66 } 67 68 69 private byte[] gti; 70 71 public void setGTI(byte[] gti) { 72 this.gti = gti; 73 } 74 75 76 public byte[] getGTI() { 77 return gti; 78 } 79 80 81 private Hashtable qDenyings = null; 82 83 private Hashtable subDenyings = null; 84 85 94 public void add(String target, Vector ids, boolean queueMode) { 95 if (queueMode) { 96 if (qDenyings == null) 97 qDenyings = new Hashtable (); 98 qDenyings.put(target, ids); 99 } else { 100 if (subDenyings == null) 101 subDenyings = new Hashtable (); 102 subDenyings.put(target, ids); 103 } 104 } 105 106 107 108 public Enumeration getQueues() { 109 if (qDenyings == null) 110 return (new Hashtable ()).keys(); 111 return qDenyings.keys(); 112 } 113 114 115 public Vector getQueueIds(String queue) { 116 if (qDenyings == null) 117 return null; 118 return (Vector ) qDenyings.get(queue); 119 } 120 121 122 public Enumeration getSubs() { 123 if (subDenyings == null) 124 return (new Hashtable ()).keys(); 125 return subDenyings.keys(); 126 } 127 128 129 public void setQDenyings(Hashtable qDenyings) { 130 this.qDenyings = qDenyings; 131 } 132 133 134 public void setSubDenyings(Hashtable subDenyings) { 135 this.subDenyings = subDenyings; 136 } 137 138 139 public Vector getSubIds(String sub) { 140 if (subDenyings == null) 141 return null; 142 return (Vector ) subDenyings.get(sub); 143 } 144 145 protected int getClassId() { 146 return XA_CNX_ROLLBACK; 147 } 148 149 156 public XACnxRollback(byte[] bq, int fi, byte[] gti) { 157 super(null); 158 this.bq = bq; 159 this.fi = fi; 160 this.gti = gti; 161 } 162 163 166 public XACnxRollback() {} 167 168 171 172 178 public void writeTo(OutputStream os) throws IOException { 179 super.writeTo(os); 180 StreamUtil.writeTo(bq, os); 181 StreamUtil.writeTo(fi, os); 182 StreamUtil.writeTo(gti, os); 183 if (qDenyings == null) { 184 StreamUtil.writeTo(-1, os); 185 } else { 186 int size = qDenyings.size(); 187 for (Enumeration keys = qDenyings.keys(); keys.hasMoreElements(); ) { 188 String key = (String ) keys.nextElement(); 189 StreamUtil.writeTo(key, os); 190 Vector ids = (Vector ) qDenyings.get(key); 191 StreamUtil.writeVectorOfStringTo(ids, os); 192 } 193 } 194 if (subDenyings == null) { 195 StreamUtil.writeTo(-1, os); 196 } else { 197 int size = subDenyings.size(); 198 for (Enumeration keys = subDenyings.keys(); keys.hasMoreElements(); ) { 199 String key = (String ) keys.nextElement(); 200 StreamUtil.writeTo(key, os); 201 Vector ids = (Vector ) subDenyings.get(key); 202 StreamUtil.writeVectorOfStringTo(ids, os); 203 } 204 } 205 } 206 207 213 public void readFrom(InputStream is) throws IOException { 214 super.readFrom(is); 215 bq = StreamUtil.readByteArrayFrom(is); 216 fi = StreamUtil.readIntFrom(is); 217 gti = StreamUtil.readByteArrayFrom(is); 218 int size = StreamUtil.readIntFrom(is); 219 if (size == -1) { 220 qDenyings = null; 221 } else { 222 qDenyings = new Hashtable (size*4/3); 223 for (int i=0; i<size; i++) { 224 String target = StreamUtil.readStringFrom(is); 225 Vector ids = StreamUtil.readVectorOfStringFrom(is); 226 qDenyings.put(target, ids); 227 } 228 } 229 size = StreamUtil.readIntFrom(is); 230 if (size == -1) { 231 subDenyings = null; 232 } else { 233 subDenyings = new Hashtable (size*4/3); 234 for (int i=0; i<size; i++) { 235 String target = StreamUtil.readStringFrom(is); 236 Vector ids = StreamUtil.readVectorOfStringFrom(is); 237 subDenyings.put(target, ids); 238 } 239 } 240 } 241 } 242 | Popular Tags |