1 23 24 28 29 51 package com.sun.jts.CosTransactions; 52 53 import java.io.*; 54 55 import org.omg.CORBA.*; 56 import org.omg.CosTransactions.*; 57 import com.sun.corba.ee.spi.presentation.rmi.StubAdapter; 58 59 74 75 82 class SuperiorInfo { 83 86 Long localTID = null; 87 88 91 GlobalTID globalTID = null; 92 93 96 Coordinator superior = null; 97 98 104 RecoveryCoordinator recovery = null; 105 106 112 SubtransactionAwareResource resource = null; 113 114 private CoordinatorLog logRecord = null; 115 private java.lang.Object logSection = null; 116 private int resyncRetries = 0; 117 118 private final static String LOG_SECTION_NAME = "SI"; 119 120 129 SuperiorInfo() { } 130 131 148 SuperiorInfo(Long localTID, GlobalTID globalTID, 149 Coordinator superior, CoordinatorLog log) { 150 151 this.localTID = localTID; 152 this.globalTID = globalTID; 153 this.superior = superior; 154 recovery = null; 155 resource = null; 156 logRecord = log; 157 resyncRetries = 0; 158 159 161 if (log != null) { 162 163 165 logSection = log.createSection(LOG_SECTION_NAME); 166 167 169 log.addData(logSection,globalTID.toBytes()); 170 } 171 } 172 173 182 public void finalize() { 183 184 186 188 190 if (superior != null && 191 !(superior instanceof org.omg.CORBA.LocalObject )) { 192 superior._release(); 193 } 194 195 201 if (recovery != null && 202 !(recovery instanceof org.omg.CORBA.LocalObject )) { 203 recovery._release(); 204 } 205 206 208 localTID = null; 209 globalTID = null; 210 superior = null; 211 recovery = null; 212 resource = null; 213 } 214 215 235 void reconstruct(CoordinatorLog log, CoordinatorImpl coord) { 236 237 superior = null; 238 239 242 logSection = log.createSection(LOG_SECTION_NAME); 243 byte[][] logData = log.getData(logSection); 244 245 247 globalTID = new GlobalTID(logData[0]); 248 249 252 localTID = log.localTID; 253 logRecord = log; 254 resyncRetries = 0; 255 256 260 RecoveryManager.addCoordinator(globalTID, localTID, coord, 0); 261 262 265 java.lang.Object [] logObjects = log.getObjects(logSection); 266 267 try { 268 if (logObjects.length > 1) { 269 if (((org.omg.CORBA.Object ) logObjects[0]). 270 _is_a(RecoveryCoordinatorHelper.id())) { 271 java.lang.Object rcimpl = logObjects[0]; 273 274 String [] ids = StubAdapter.getTypeIds(rcimpl); 275 280 281 java.lang.Object crimpl = logObjects[1]; 283 284 ids = StubAdapter.getTypeIds(crimpl); 285 290 recovery = RecoveryCoordinatorHelper. 291 narrow((org.omg.CORBA.Object ) logObjects[0]); 292 293 resource = SubtransactionAwareResourceHelper. 294 narrow((org.omg.CORBA.Object ) logObjects[1]); 295 } else { 296 recovery = RecoveryCoordinatorHelper. 297 narrow((org.omg.CORBA.Object ) logObjects[1]); 298 resource = SubtransactionAwareResourceHelper. 299 narrow((org.omg.CORBA.Object ) logObjects[0]); 300 } 301 } else { 302 recovery = null; 303 resource = null; 304 } 305 } catch (Throwable exc) {} 306 } 307 308 void delegated_reconstruct(CoordinatorLog log, CoordinatorImpl coord, String logPath) { 310 311 superior = null; 312 313 316 logSection = log.createSection(LOG_SECTION_NAME); 317 byte[][] logData = log.getData(logSection); 318 319 321 globalTID = new GlobalTID(logData[0]); 322 323 326 localTID = log.localTID; 327 logRecord = log; 328 resyncRetries = 0; 329 330 334 DelegatedRecoveryManager.addCoordinator(globalTID, localTID, coord, 0, logPath); 335 336 339 java.lang.Object [] logObjects = log.getObjects(logSection); 340 341 try { 342 if (logObjects.length > 1) { 343 if (((org.omg.CORBA.Object ) logObjects[0]). 344 _is_a(RecoveryCoordinatorHelper.id())) { 345 java.lang.Object rcimpl = logObjects[0]; 347 348 String [] ids = StubAdapter.getTypeIds(rcimpl); 349 354 355 java.lang.Object crimpl = logObjects[1]; 357 358 ids = StubAdapter.getTypeIds(crimpl); 359 364 recovery = RecoveryCoordinatorHelper. 365 narrow((org.omg.CORBA.Object ) logObjects[0]); 366 367 resource = SubtransactionAwareResourceHelper. 368 narrow((org.omg.CORBA.Object ) logObjects[1]); 369 } else { 370 recovery = RecoveryCoordinatorHelper. 371 narrow((org.omg.CORBA.Object ) logObjects[1]); 372 resource = SubtransactionAwareResourceHelper. 373 narrow((org.omg.CORBA.Object ) logObjects[0]); 374 } 375 } else { 376 recovery = null; 377 resource = null; 378 } 379 } catch (Throwable exc) {} 380 } 381 382 383 392 void setRecovery(RecoveryCoordinator rec) { 393 394 if (recovery == null) { 395 recovery = rec; 396 397 399 if (logRecord != null) { 400 logRecord.addObject(logSection, rec); 401 } 402 } 403 } 404 405 414 void setResource(SubtransactionAwareResource res) { 415 416 if (resource == null) { 417 resource = res; 418 419 421 if (logRecord != null) { 422 logRecord.addObject(logSection, res); 423 } 424 } 425 } 426 427 436 int resyncRetries() { 437 438 int result = resyncRetries++; 439 440 return result; 441 } 442 } 443 | Popular Tags |