1 9 10 package org.jboss.tm.iiop; 11 12 import java.util.HashMap ; 13 14 import javax.naming.Context ; 15 import javax.naming.InitialContext ; 16 import javax.naming.NamingException ; 17 import javax.transaction.HeuristicMixedException ; 18 import javax.transaction.HeuristicRollbackException ; 19 import javax.transaction.InvalidTransactionException ; 20 import javax.transaction.NotSupportedException ; 21 import javax.transaction.RollbackException ; 22 import javax.transaction.SystemException ; 23 import javax.transaction.Transaction ; 24 import javax.transaction.TransactionManager ; 25 import javax.transaction.xa.Xid ; 26 27 import org.omg.CORBA.BAD_INV_ORDER ; 28 import org.omg.CORBA.BAD_OPERATION ; 29 import org.omg.CORBA.BAD_PARAM ; 30 import org.omg.CORBA.OBJECT_NOT_EXIST ; 31 import org.omg.CORBA.ORB ; 32 import org.omg.CORBA.ORBPackage.InvalidName ; 33 import org.omg.CORBA.INVALID_TRANSACTION ; 34 import org.omg.CORBA.NO_IMPLEMENT ; 35 import org.omg.CORBA.NO_PERMISSION ; 36 import org.omg.CORBA.TRANSACTION_ROLLEDBACK ; 37 import org.omg.CORBA.UNKNOWN ; 38 import org.omg.CosTransactions.Control; 39 import org.omg.CosTransactions.ControlHelper; 40 import org.omg.CosTransactions.Coordinator; 41 import org.omg.CosTransactions.CoordinatorHelper; 42 import org.omg.CosTransactions.HeuristicHazard; 43 import org.omg.CosTransactions.HeuristicMixed; 44 import org.omg.CosTransactions.Inactive; 45 import org.omg.CosTransactions.NotSubtransaction; 46 import org.omg.CosTransactions.PropagationContext; 47 import org.omg.CosTransactions.RecoveryCoordinator; 48 import org.omg.CosTransactions.Resource; 49 import org.omg.CosTransactions.Status; 50 import org.omg.CosTransactions.SubtransactionAwareResource; 51 import org.omg.CosTransactions.SubtransactionsUnavailable; 52 import org.omg.CosTransactions.Synchronization; 53 import org.omg.CosTransactions.SynchronizationUnavailable; 54 import org.omg.CosTransactions.Terminator; 55 import org.omg.CosTransactions.TerminatorHelper; 56 import org.omg.CosTransactions.TransactionFactoryHelper; 57 import org.omg.CosTransactions.TransIdentity; 58 import org.omg.CosTransactions.Unavailable; 59 import org.omg.CosTransactions.otid_t; 60 import org.omg.PortableServer.POA ; 61 import org.omg.PortableServer.CurrentPackage.NoContext ; 62 63 import org.jboss.logging.Logger; 64 import org.jboss.tm.LocalId; 65 import org.jboss.tm.TransactionImpl; 66 import org.jboss.tm.TransactionPropagationContextFactory; 67 import org.jboss.tm.TransactionPropagationContextImporter; 68 import org.jboss.tm.TxManager; 69 import org.jboss.tm.XidImpl; 70 71 77 public class TransactionServiceImpl 78 extends TransactionServicePOA 79 { 80 82 private static final Logger log = 83 Logger.getLogger(TransactionServiceImpl.class); 84 85 87 88 private static final byte CONTROL = 0x43; 89 90 91 private static final byte COORDINATOR = 0x63; 92 93 94 private static final byte TX_FACTORY = 0x46; 95 96 97 private static final byte TERMINATOR = 0x74; 98 99 101 102 private static final String [] controlInterfaceIds = { 103 ControlHelper.id() 104 }; 105 106 107 private static final String [] coordinatorInterfaceIds = { 108 CoordinatorExtHelper.id(), 109 CoordinatorHelper.id() 110 }; 111 112 113 private static final String [] txFactoryInterfaceIds = { 114 TransactionFactoryExtHelper.id(), 115 TransactionFactoryHelper.id() 116 }; 117 118 119 private static final String [] terminatorInterfaceIds = { 120 TerminatorHelper.id() 121 }; 122 123 125 private static TransactionManager tm; 126 private static TransactionPropagationContextImporter tpcImporter; 127 128 130 private ORB orb; 131 private POA poa; 132 private org.omg.PortableServer.Current poaCurrent; 133 134 136 static byte[] theFactoryId() { return new byte[] { TX_FACTORY }; } 137 138 140 TransactionServiceImpl(ORB orb, POA poa) 141 { 142 this.orb = orb; 143 this.poa = poa; 144 145 Context ic; 146 147 try 148 { 149 org.omg.CORBA.Object obj = 150 orb.resolve_initial_references("POACurrent"); 151 poaCurrent = org.omg.PortableServer.CurrentHelper.narrow(obj); 152 } 153 catch (InvalidName e) { 155 log.warn("Call to resolve_initial_references failed: ", e); 156 throw new RuntimeException ( 157 "Call to resolve_initial_references failed: " + e); 158 } 159 catch (BAD_PARAM e) { 161 log.warn("Call to narrow failed: ", e); 162 throw new RuntimeException ("Call to narrow failed: " + e); 163 } 164 } 165 166 public String [] _all_interfaces(POA poa, byte[] oid) 168 { 169 if (oid[0] == TX_FACTORY) 170 return txFactoryInterfaceIds; 171 else if (oid[0] == CONTROL) 172 return controlInterfaceIds; 173 else if (oid[0] == COORDINATOR) 174 return coordinatorInterfaceIds; 175 else if (oid[0] == TERMINATOR) 176 return terminatorInterfaceIds; 177 else 178 throw new BAD_PARAM ("Unknown CORBA object id"); 179 } 180 181 183 public TransactionDesc create_transaction(int timeout) 184 { 185 checkInvocationTarget(TX_FACTORY); 186 try 187 { 188 TransactionManager tm = getTransactionManager(); 189 190 if (timeout != 0) 192 tm.setTransactionTimeout(timeout); 193 194 tm.begin(); 196 197 TransactionImpl tx = (TransactionImpl)tm.suspend(); 200 XidImpl xid = tx.getXid(); 201 long localId = xid.getLocalIdValue(); 202 203 byte[] oid = new byte[9]; 205 oid[0] = COORDINATOR; 206 LocalId.toByteArray(localId, oid, 1); 207 208 Coordinator coord = CoordinatorHelper.narrow( 210 poa.create_reference_with_id(oid, CoordinatorHelper.id())); 211 212 oid[0] = TERMINATOR; 214 Terminator term = TerminatorHelper.narrow( 215 poa.create_reference_with_id(oid, TerminatorHelper.id())); 216 217 PropagationContext pc = new PropagationContext(); 219 pc.current = createTransIdentity(xid, coord, term); 220 pc.timeout = timeout; 221 pc.parents = new TransIdentity[0]; 222 pc.implementation_specific_data = orb.create_any(); 223 224 TransactionDesc td = new TransactionDesc(); 226 td.control = ControlHelper.narrow( 227 poa.create_reference_with_id(oid, ControlHelper.id())); 228 td.propagationContext = pc; 229 230 return td; 232 } 233 catch (SystemException e) 234 { 235 log.trace("Unexpected exception: ", e); 236 throw new UNKNOWN (e.toString()); 237 } 238 catch (NotSupportedException e) 239 { 240 log.trace("Unexpected exception: ", e); 241 throw new BAD_INV_ORDER (e.toString()); 242 } 243 } 244 245 247 public Control create(int timeout) 248 { 249 checkInvocationTarget(TX_FACTORY); 250 try 251 { 252 TransactionManager tm = getTransactionManager(); 253 254 if (timeout != 0) 256 tm.setTransactionTimeout(timeout); 257 258 tm.begin(); 260 261 TransactionImpl tx = (TransactionImpl)tm.suspend(); 264 XidImpl xid = tx.getXid(); 265 long localId = xid.getLocalIdValue(); 266 267 byte[] oid = new byte[9]; 269 oid[0] = CONTROL; 270 LocalId.toByteArray(localId, oid, 1); 271 272 return ControlHelper.narrow( 274 poa.create_reference_with_id(oid, ControlHelper.id())); 275 } 276 catch (SystemException e) 277 { 278 log.trace("Unexpected exception: ", e); 279 throw new UNKNOWN (e.toString()); 280 } 281 catch (NotSupportedException e) 282 { 283 log.trace("Unexpected exception: ", e); 284 throw new BAD_INV_ORDER (e.toString()); 285 } 286 } 287 288 public Control recreate(PropagationContext pc) 289 { 290 checkInvocationTarget(TX_FACTORY); 291 log.trace("Operation recreate is not implemented"); 292 throw new NO_IMPLEMENT ("recreate not implemented"); 293 } 294 295 297 public Terminator get_terminator() 298 throws Unavailable 299 { 300 byte[] oid = getTargetId(); 301 if (oid[0] != CONTROL) 302 throw new BAD_OPERATION (); 303 oid[0] = TERMINATOR; 304 return TerminatorHelper.narrow( 305 poa.create_reference_with_id(oid, TerminatorHelper.id())); 306 } 307 308 public Coordinator get_coordinator() 309 throws Unavailable 310 { 311 byte[] oid = getTargetId(); 312 if (oid[0] != CONTROL) 313 throw new BAD_OPERATION (); 314 oid[0] = COORDINATOR; 315 return CoordinatorHelper.narrow( 316 poa.create_reference_with_id(oid, CoordinatorHelper.id())); 317 } 318 319 321 public void commit(boolean reportHeuristics) 322 throws HeuristicHazard, HeuristicMixed 323 { 324 byte[] oid = getTargetId(); 325 if (oid[0] != TERMINATOR) 326 throw new BAD_OPERATION (); 327 328 long localIdValue = LocalId.fromByteArray(oid, 1); 329 LocalId localId = new LocalId(localIdValue); 330 Transaction tx = getTransaction(localId); 331 332 if (tx == null) 333 { 334 log.trace("RuntimeException in commit: transaction not found"); 335 throw new OBJECT_NOT_EXIST ("No transaction."); 336 } 337 338 TransactionManager tm = getTransactionManager(); 339 try 340 { 341 tm.resume(tx); 342 tm.commit(); 343 } 344 catch (RollbackException e) 345 { 346 log.trace("Exception: ", e); 347 throw new TRANSACTION_ROLLEDBACK (e.toString()); 348 } 349 catch (HeuristicMixedException e) 350 { 351 log.trace("Exception: ", e); 352 if (reportHeuristics) 353 throw new HeuristicMixed(e.toString()); 354 } 355 catch (HeuristicRollbackException e) 356 { 357 log.trace("Exception: ", e); 358 if (reportHeuristics) 359 throw new HeuristicHazard(e.toString()); 360 } 361 catch (InvalidTransactionException e) 362 { 363 log.trace("Unexpected exception: ", e); 364 throw new INVALID_TRANSACTION (e.toString()); 365 } 366 catch (IllegalStateException e) 367 { 368 log.trace("Unexpected exception: ", e); 369 throw new BAD_INV_ORDER (e.toString()); 370 } 371 catch (SystemException e) 372 { 373 log.trace("Unexpected exception: ", e); 374 throw new UNKNOWN (e.toString()); 375 } 376 catch (SecurityException e) 377 { 378 log.trace("Unexpected exception: ", e); 379 throw new NO_PERMISSION (e.toString()); 380 } 381 } 382 383 public void rollback() 384 { 385 byte[] oid = getTargetId(); 386 if (oid[0] != TERMINATOR) 387 throw new BAD_OPERATION (); 388 389 long localIdValue = LocalId.fromByteArray(oid, 1); 390 LocalId localId = new LocalId(localIdValue); 391 Transaction tx = getTransaction(localId); 392 393 if (tx == null) 394 { 395 log.trace("RuntimeException in rollback: transaction not found"); 396 throw new OBJECT_NOT_EXIST ("No transaction."); 397 } 398 399 TransactionManager tm = getTransactionManager(); 400 try 401 { 402 tm.resume(tx); 403 tm.rollback(); 404 } 405 catch (InvalidTransactionException e) 406 { 407 log.trace("Unexpected exception: ", e); 408 throw new INVALID_TRANSACTION (e.toString()); 409 } 410 catch (IllegalStateException e) 411 { 412 log.trace("Unexpected exception: ", e); 413 throw new BAD_INV_ORDER (e.toString()); 414 } 415 catch (SystemException e) 416 { 417 log.trace("Unexpected exception: ", e); 418 throw new UNKNOWN (e.toString()); 419 } 420 catch (SecurityException e) 421 { 422 log.trace("Unexpected exception: ", e); 423 throw new NO_PERMISSION (e.toString()); 424 } 425 } 426 427 429 public TransactionId get_transaction_id() 430 { 431 byte[] oid = getTargetId(); 432 if (oid[0] != COORDINATOR) 433 throw new BAD_OPERATION (); 434 435 long localIdValue = LocalId.fromByteArray(oid, 1); 436 LocalId localId = new LocalId(localIdValue); 437 TransactionImpl tx = (TransactionImpl)getTransaction(localId); 438 439 if (tx == null) 440 { 441 log.trace("RuntimeException in get_transaction_id: transaction not found"); 442 throw new OBJECT_NOT_EXIST ("No transaction."); 443 } 444 445 Xid xid = tx.getXid(); 446 return new TransactionId(xid.getFormatId(), 447 xid.getGlobalTransactionId()); 448 } 449 450 452 public Status get_status() 453 { 454 byte[] oid = getTargetId(); 455 if (oid[0] != COORDINATOR) 456 throw new BAD_OPERATION (); 457 458 long localIdValue = LocalId.fromByteArray(oid, 1); 459 LocalId localId = new LocalId(localIdValue); 460 Transaction tx = getTransaction(localId); 461 462 if (tx == null) 463 { 464 log.trace("RuntimeException in get_status: transaction not found"); 465 throw new OBJECT_NOT_EXIST ("No transaction."); 468 } 470 471 int status; 472 473 try 474 { 475 status = tx.getStatus(); 476 } 477 catch (SystemException e) 478 { 479 log.trace("Unexpected exception: ", e); 480 throw new UNKNOWN (e.toString()); 481 } 482 return javaxToCosTransactions(status); 483 } 484 485 public Status get_parent_status() 486 { 487 return get_status(); 491 } 492 493 public Status get_top_level_status() 494 { 495 return get_status(); 499 } 500 501 public boolean is_same_transaction(Coordinator other) 502 { 503 byte[] oid = getTargetId(); 504 if (oid[0] != COORDINATOR) 505 throw new BAD_OPERATION (); 506 507 long localIdValue = LocalId.fromByteArray(oid, 1); 508 LocalId localId = new LocalId(localIdValue); 509 TransactionImpl tx = (TransactionImpl)getTransaction(localId); 510 511 if (tx == null) 512 { 513 log.trace("RuntimeException in is_same_transaction: transaction not found"); 514 throw new OBJECT_NOT_EXIST ("No transaction."); 515 } 516 517 Xid xid = tx.getXid(); 518 519 try 520 { 521 CoordinatorExt otherExt = CoordinatorExtHelper.narrow(other); 522 TransactionId otherId = otherExt.get_transaction_id(); 523 return compare(xid, 524 otherId.formatId, 525 otherId.globalId, 526 otherId.globalId.length); 527 } 528 catch (BAD_PARAM e) 529 { 530 try 532 { 533 otid_t otherOtid = other.get_txcontext().current.otid; 534 return compare(xid, 535 otherOtid.formatID, 536 otherOtid.tid, 537 otherOtid.tid.length - otherOtid.bqual_length); 538 } 539 catch (Unavailable u) 540 { 541 log.trace("Foreign Coordinator do not support get_txcontext(): ", 542 e); 543 throw new BAD_PARAM (e.toString()); 544 } 545 } 546 } 547 548 public boolean is_ancestor_transaction(Coordinator other) 549 { 550 return is_same_transaction(other); 553 } 554 555 public boolean is_descendant_transaction(Coordinator other) 556 { 557 return is_same_transaction(other); 560 } 561 562 public boolean is_related_transaction(Coordinator other) 563 { 564 return is_same_transaction(other); 567 } 568 569 public boolean is_top_level_transaction() 570 { 571 checkInvocationTarget(COORDINATOR); 572 return true; } 574 575 public int hash_transaction() 576 { 577 byte[] oid = getTargetId(); 578 if (oid[0] != COORDINATOR) 579 throw new BAD_OPERATION (); 580 581 long localIdValue = LocalId.fromByteArray(oid, 1); 582 LocalId localId = new LocalId(localIdValue); 583 TransactionImpl tx = (TransactionImpl)getTransaction(localId); 584 if (tx == null) 585 { 586 log.trace("RuntimeException in is_same_transaction: transaction not found"); 587 throw new OBJECT_NOT_EXIST ("No transaction."); 588 } 589 return tx.getXid().hashCode(); 590 } 591 592 public int hash_top_level_tran() 593 { 594 return hash_transaction(); 597 } 598 599 public RecoveryCoordinator register_resource(Resource r) 600 throws Inactive 601 { 602 checkInvocationTarget(COORDINATOR); 603 throw new NO_IMPLEMENT ("Two-phase commit is not supported."); } 605 606 public void register_synchronization(final Synchronization sync) 607 throws SynchronizationUnavailable, Inactive 608 { 609 byte[] oid = getTargetId(); 610 if (oid[0] != COORDINATOR) 611 throw new BAD_OPERATION (); 612 613 long localIdValue = LocalId.fromByteArray(oid, 1); 614 LocalId localId = new LocalId(localIdValue); 615 Transaction tx = getTransaction(localId); 616 617 if (tx == null) 618 { 619 log.trace("RuntimeException in register_synchronization: transaction not found"); 620 throw new OBJECT_NOT_EXIST ("No transaction."); 621 } 622 623 try 624 { 625 tx.registerSynchronization( 626 new javax.transaction.Synchronization () 627 { 628 public void beforeCompletion() 629 { 630 sync.before_completion(); 631 } 632 public void afterCompletion(int status) 633 { 634 sync.after_completion(javaxToCosTransactions(status)); 635 } 636 }); 637 } 638 catch (RollbackException e) 639 { 640 log.trace("Exception: ", e); 641 throw new TRANSACTION_ROLLEDBACK (e.toString()); 642 } 643 catch (IllegalStateException e) 644 { 645 log.trace("Unexpected exception: ", e); 646 throw new BAD_INV_ORDER (e.toString()); 647 } 648 catch (SystemException e) 649 { 650 log.trace("Unexpected exception: ", e); 651 throw new UNKNOWN (e.toString()); 652 } 653 } 654 655 public void register_subtran_aware(SubtransactionAwareResource r) 656 throws NotSubtransaction, Inactive 657 { 658 checkInvocationTarget(COORDINATOR); 659 throw new NotSubtransaction("Nested transactions are not supported"); 660 } 661 662 public void rollback_only() 663 throws Inactive 664 { 665 byte[] oid = getTargetId(); 666 if (oid[0] != COORDINATOR) 667 throw new BAD_OPERATION (); 668 669 long localIdValue = LocalId.fromByteArray(oid, 1); 670 LocalId localId = new LocalId(localIdValue); 671 Transaction tx = getTransaction(localId); 672 673 if (tx == null) 674 { 675 log.trace("RuntimeException in rollback_only: transaction not found"); 676 throw new OBJECT_NOT_EXIST ("No transaction."); 677 } 678 679 try 680 { 681 tx.setRollbackOnly(); 682 } 683 catch (IllegalStateException e) 684 { 685 log.trace("Unexpected exception: ", e); 686 throw new BAD_INV_ORDER (e.toString()); 687 } 688 catch (SystemException e) 689 { 690 log.trace("Unexpected exception: ", e); 691 throw new UNKNOWN (e.toString()); 692 } 693 } 694 695 public String get_transaction_name() 696 { 697 byte[] oid = getTargetId(); 698 if (oid[0] != COORDINATOR) 699 throw new BAD_OPERATION (); 700 701 long localIdValue = LocalId.fromByteArray(oid, 1); 702 LocalId localId = new LocalId(localIdValue); 703 Transaction tx = getTransaction(localId); 704 705 if (tx == null) 706 { 707 log.trace("RuntimeException in get_transaction_name: transaction not found"); 708 throw new OBJECT_NOT_EXIST ("No transaction."); 709 } 710 return tx.toString(); 711 } 712 713 public Control create_subtransaction() 714 throws SubtransactionsUnavailable, Inactive 715 { 716 checkInvocationTarget(COORDINATOR); 717 throw new SubtransactionsUnavailable( 718 "Nested transactions are not supported"); 719 } 720 721 public PropagationContext get_txcontext() 722 throws Unavailable 723 { 724 byte[] oid = getTargetId(); 725 if (oid[0] != COORDINATOR) 726 throw new BAD_OPERATION (); 727 728 long localIdValue = LocalId.fromByteArray(oid, 1); 729 LocalId localId = new LocalId(localIdValue); 730 TransactionImpl tx = (TransactionImpl)getTransaction(localId); 731 if (tx == null) 732 { 733 log.trace("RuntimeException in get_txcontext: transaction not found"); 734 throw new OBJECT_NOT_EXIST ("No transaction."); 735 } 736 Xid xid = tx.getXid(); 737 738 Coordinator coord = CoordinatorHelper.narrow( 740 poa.create_reference_with_id(oid, CoordinatorHelper.id())); 741 742 PropagationContext pc = new PropagationContext(); 744 pc.current = createTransIdentity(xid, coord, null); 745 pc.timeout = divideAndRoundUp(tx.getTimeLeftBeforeTimeout(), 1000); 746 pc.parents = new TransIdentity[0]; 747 pc.implementation_specific_data = orb.create_any(); 748 749 return pc; 751 } 752 753 755 758 protected static TransactionManager getTransactionManager() 759 { 760 if (tm == null) 761 { 762 try 763 { 764 Context ctx = new InitialContext (); 765 tm = (TransactionManager )ctx.lookup("java:/TransactionManager"); 766 } 767 catch (NamingException ex) 768 { 769 log.error("java:/TransactionManager lookup failed", ex); 770 } 771 } 772 return tm; 773 } 774 775 778 protected static TransactionPropagationContextImporter getTPCImporter() 779 { 780 if (tpcImporter == null) 781 { 782 try 783 { 784 Context ctx = new InitialContext (); 785 tpcImporter = (TransactionPropagationContextImporter)ctx.lookup( 786 "java:/TransactionPropagationContextImporter"); 787 } 788 catch (NamingException ex) 789 { 790 log.error( 791 "java:/TransactionPropagationContextImporter lookup failed", 792 ex); 793 } 794 } 795 return tpcImporter; 796 } 797 798 800 private static Transaction getTransaction(LocalId localId) 801 { 802 return getTPCImporter().importTransactionPropagationContext(localId); 803 } 804 805 private byte[] getTargetId() 806 { 807 byte[] id = null; 808 try 809 { 810 id = poaCurrent.get_object_id(); 811 } 812 catch (NoContext e) 813 { 814 log.trace("Unexpected exception: " + e); 815 throw new RuntimeException ("Unexpected exception: " + e); 816 } 817 return id; 818 } 819 820 private void checkInvocationTarget(int targetType) 821 { 822 if (getTargetId()[0] != targetType) 823 throw new BAD_OPERATION (); 824 } 825 826 829 private static TransIdentity createTransIdentity(Xid xid, 830 Coordinator coord, 831 Terminator term) 832 { 833 byte gtrid[] = xid.getGlobalTransactionId(); 835 byte bqual[] = xid.getBranchQualifier(); 836 byte[] trid = new byte[gtrid.length + bqual.length]; 837 System.arraycopy(gtrid, 0, trid, 0, gtrid.length); 838 System.arraycopy(bqual, 0, trid, gtrid.length, bqual.length); 839 840 TransIdentity ti = new TransIdentity(); 842 ti.coord = coord; 843 ti.term = term; 844 ti.otid = new otid_t(xid.getFormatId(), bqual.length, trid); 845 return ti; 846 } 847 848 private static int divideAndRoundUp(long m, long n) 849 { 850 long retval = m / n; 851 852 if ((m % n) != 0) 853 retval = retval + 1; 854 return (int)retval ; 855 } 856 857 private static Status javaxToCosTransactions(int status) 858 { 859 switch (status) 860 { 861 case javax.transaction.Status.STATUS_ACTIVE: 862 return org.omg.CosTransactions.Status.StatusActive; 863 case javax.transaction.Status.STATUS_COMMITTED: 864 return org.omg.CosTransactions.Status.StatusCommitted; 865 case javax.transaction.Status.STATUS_COMMITTING: 866 return org.omg.CosTransactions.Status.StatusCommitting; 867 case javax.transaction.Status.STATUS_MARKED_ROLLBACK: 868 return org.omg.CosTransactions.Status.StatusMarkedRollback; 869 case javax.transaction.Status.STATUS_NO_TRANSACTION: 870 return org.omg.CosTransactions.Status.StatusNoTransaction; 871 case javax.transaction.Status.STATUS_PREPARED: 872 return org.omg.CosTransactions.Status.StatusPrepared; 873 case javax.transaction.Status.STATUS_PREPARING: 874 return org.omg.CosTransactions.Status.StatusPreparing; 875 case javax.transaction.Status.STATUS_ROLLEDBACK: 876 return org.omg.CosTransactions.Status.StatusRolledBack; 877 case javax.transaction.Status.STATUS_ROLLING_BACK: 878 return org.omg.CosTransactions.Status.StatusRollingBack; 879 case javax.transaction.Status.STATUS_UNKNOWN: 880 return org.omg.CosTransactions.Status.StatusUnknown; 881 default: 882 log.trace("Invalid transaction status."); 883 return org.omg.CosTransactions.Status.StatusUnknown; 884 } 885 } 886 887 private static boolean compare(Xid xid, 888 int otherFormatId, 889 byte[] otherGlobalId, 890 int otherLength) 891 { 892 if (xid.getFormatId() != otherFormatId) 893 return false; 894 895 byte[] globalId = xid.getGlobalTransactionId(); 896 int len = globalId.length; 897 898 if (len != otherLength) 899 return false; 900 901 for (int i = 0; i < len; ++i) 902 if (globalId[i] != otherGlobalId[i]) 903 return false; 904 905 return true; 906 } 907 908 } 909 | Popular Tags |