1 23 24 28 29 51 package com.sun.jts.CosTransactions; 52 53 import java.util.*; 54 55 import org.omg.CORBA.*; 56 import org.omg.CosTransactions.*; 57 58 69 70 77 class RegisteredStatics { 78 79 private Vector registered = new Vector(); 80 81 90 RegisteredStatics() {} 91 92 101 public void finalize() { 102 103 if (registered != null) { 104 registered.removeAllElements(); 105 } 106 registered = null; 107 } 108 109 124 void distributeStart(ControlImpl control, boolean begin) { 125 126 128 org.omg.CosTransactions.Coordinator coord = null; 129 130 try { 131 coord = control.get_coordinator(); 132 } catch (Unavailable exc) {} 133 134 136 if (coord != null) { 137 138 for (int i = 0; i < registered.size(); i++) { 139 140 StaticResource resource = 141 (StaticResource) registered.elementAt(i); 142 143 try { 144 resource.startAssociation(coord, begin); 145 } catch (INVALID_TRANSACTION exc) { 146 151 for (int j = i - 1; j >= 0; j--) { 152 ((StaticResource) registered.elementAt(j)). 153 endAssociation(coord, begin); 154 } 155 156 throw (INVALID_TRANSACTION)exc.fillInStackTrace(); 157 } catch (Throwable exc) { 158 } 160 } 161 } 162 } 163 164 181 void distributeEnd(ControlImpl control, boolean complete) { 182 183 185 org.omg.CosTransactions.Coordinator coord = null; 186 187 try { 188 coord = control.get_coordinator(); 189 } catch (Unavailable exc) {} 190 191 193 if (coord != null) { 194 for (int i = 0; i < registered.size(); i++) { 195 StaticResource resource = 196 (StaticResource)registered.elementAt(i); 197 try { 198 resource.endAssociation(coord, complete); 199 } catch (Throwable e) { 200 } 202 } 203 } 204 } 205 206 219 220 void addStatic(StaticResource obj) { 221 222 registered.addElement(obj); 223 224 226 try { 227 org.omg.CosTransactions.Coordinator coord = 228 CurrentTransaction.getCurrentCoordinator(); 229 230 234 if (coord != null) { 235 obj.startAssociation(coord, true); 236 } 237 } catch(Throwable exc) { 238 } 240 } 241 242 252 boolean removeStatic(StaticResource obj) { 253 254 boolean result = registered.removeElement(obj); 255 return result; 256 } 257 } 258 | Popular Tags |