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 74 class NestingInfo { 75 CoordinatorImpl[] ancestorSeq = null; 76 Vector childSet = new Vector(); 77 boolean removed = false; 78 79 88 NestingInfo() {} 89 90 100 NestingInfo(CoordinatorImpl[] ancestors) { 101 102 105 ancestorSeq = (CoordinatorImpl[])ancestors.clone(); 106 removed = (ancestors.length == 0); 107 } 108 109 118 public void finalize() { 119 120 if( childSet != null ) childSet.removeAllElements(); 121 childSet = null; 122 123 if( ancestorSeq != null ) 124 { 125 for( int i = 0; i < ancestorSeq.length; i++ ) 126 ancestorSeq[i] = null; 127 ancestorSeq = null; 128 } 129 } 130 131 142 boolean addChild(CoordinatorImpl child) { 143 144 boolean result = !childSet.contains(child); 145 if( result ) childSet.addElement(child); 146 147 return result; 148 } 149 150 161 boolean removeChild(CoordinatorImpl child) { 162 boolean result = childSet.removeElement(child); 163 return result; 164 } 165 166 175 void empty() { 176 childSet.removeAllElements(); 177 } 178 179 191 boolean removeFromParent(CoordinatorImpl child) { 192 193 198 boolean result = true; 199 if(!removed) { 200 CoordinatorImpl parent = ancestorSeq[0]; 201 202 result = parent.removeChild(child); 203 removed = true; 204 } 205 206 return result; 207 } 208 209 225 CoordinatorImpl getParent(boolean forgetting) { 226 227 CoordinatorImpl result = null; 228 229 232 if (ancestorSeq.length != 0) 233 result = ancestorSeq[0]; 234 235 238 if( forgetting ) removed = true; 239 240 return result; 241 } 242 243 257 CoordinatorImpl getTopLevel() { 258 259 CoordinatorImpl result = null; 260 261 264 if( ancestorSeq.length != 0 ) 265 result = ancestorSeq[ancestorSeq.length - 1]; 266 267 return result; 268 } 269 270 284 CoordinatorImpl[] getAncestors() { 285 286 CoordinatorImpl[] result = null; 287 288 292 result = (CoordinatorImpl[]) ancestorSeq.clone(); 293 294 return result; 295 } 296 297 308 int numChildren() { 309 return childSet.size(); 310 } 311 312 328 boolean replyCheck() { 329 330 boolean result = false; 331 332 334 for (int i = 0; i < childSet.size() && !result; i++) { 335 CoordinatorImpl child = (CoordinatorImpl) childSet.elementAt(i); 336 result = child.isActive(); 337 } 338 339 return result; 340 } 341 342 355 boolean isDescendant(Coordinator other) { 356 357 boolean result = false; 358 359 362 try { 363 for (int i = 0; i < ancestorSeq.length && !result; i++) { 364 result = ancestorSeq[i].is_same_transaction(other); 365 } 366 } catch(SystemException exc) { 367 result = false; 368 } 369 370 return result; 371 } 372 373 383 void rollbackFamily() { 384 385 388 while (childSet.size() > 0) { 389 390 395 CoordinatorImpl child = (CoordinatorImpl)childSet.elementAt(0); 396 try { 397 child.rollback(true); 398 } catch (Throwable exc) {} 399 } 400 } 401 } 402 | Popular Tags |