1 22 package org.jboss.tm.remoting.server; 23 24 import java.lang.reflect.Proxy ; 25 import java.rmi.AccessException ; 26 import java.rmi.NoSuchObjectException ; 27 import java.rmi.RemoteException ; 28 import java.rmi.UnexpectedException ; 29 30 import javax.transaction.HeuristicCommitException ; 31 import javax.transaction.HeuristicMixedException ; 32 import javax.transaction.HeuristicRollbackException ; 33 import javax.transaction.NotSupportedException ; 34 import javax.transaction.RollbackException ; 35 import javax.transaction.SystemException ; 36 import javax.transaction.Transaction ; 37 import javax.transaction.TransactionManager ; 38 import javax.transaction.TransactionRolledbackException ; 39 import javax.transaction.xa.XAResource ; 40 41 import org.jboss.logging.Logger; 42 import org.jboss.tm.CoordinatorFactory; 43 import org.jboss.tm.GlobalId; 44 import org.jboss.tm.LocalId; 45 import org.jboss.tm.ResourceFactory; 46 import org.jboss.tm.StringRemoteRefConverter; 47 import org.jboss.tm.TransactionImpl; 48 import org.jboss.tm.TMUtil; 49 import org.jboss.tm.TxManager; 50 import org.jboss.tm.XidImpl; 51 import org.jboss.tm.remoting.RemoteProxy; 52 import org.jboss.tm.remoting.Invocation.ICoordinator; 53 import org.jboss.tm.remoting.Invocation.IRecoveryCoordinator; 54 import org.jboss.tm.remoting.Invocation.IResource; 55 import org.jboss.tm.remoting.Invocation.ISynchronization; 56 import org.jboss.tm.remoting.Invocation.ITerminator; 57 import org.jboss.tm.remoting.Invocation.ITransactionFactory; 58 import org.jboss.tm.remoting.interfaces.Coordinator; 59 import org.jboss.tm.remoting.interfaces.HeuristicHazardException; 60 import org.jboss.tm.remoting.interfaces.RecoveryCoordinator; 61 import org.jboss.tm.remoting.interfaces.Resource; 62 import org.jboss.tm.remoting.interfaces.Status; 63 import org.jboss.tm.remoting.interfaces.Synchronization; 64 import org.jboss.tm.remoting.interfaces.Terminator; 65 import org.jboss.tm.remoting.interfaces.TxPropagationContext; 66 import org.jboss.tm.remoting.interfaces.TransactionInactiveException; 67 import org.jboss.tm.remoting.interfaces.TransactionNotPreparedException; 68 import org.jboss.tm.remoting.interfaces.Vote; 69 70 79 public class DTMServant implements ITransactionFactory, 80 ICoordinator, 81 ITerminator, 82 IResource, 83 IRecoveryCoordinator, 84 ISynchronization, 85 CoordinatorFactory, 86 ResourceFactory, 87 StringRemoteRefConverter 88 { 89 90 92 private static final Logger log = 93 Logger.getLogger(DTMServant.class); 94 95 97 private DistributedTransactionManager dtm; 98 99 101 public DTMServant(DistributedTransactionManager dtm) 102 { 103 this.dtm = dtm; 104 } 105 106 108 public TxPropagationContext create(long targetId, int timeout) 109 throws RemoteException 110 { 111 log.trace("TransactionFactory.create"); 112 try 113 { 114 TransactionManager tm = TMUtil.getTransactionManager(); 115 116 if (timeout != 0) 118 tm.setTransactionTimeout(timeout); 119 120 tm.begin(); 122 123 TransactionImpl tx = (TransactionImpl)tm.suspend(); 126 XidImpl xid = tx.getXid(); 127 long localId = xid.getLocalIdValue(); 128 129 TxPropagationContext tpc = tx.getPropagationContext(); 131 132 tpc.terminator = 134 (Terminator ) RemoteProxy.create(Terminator .class, 135 localId, 136 dtm.getLocators()); 137 138 return tpc; 139 } 140 catch (SystemException e) 141 { 142 if (log.isTraceEnabled()) 143 log.trace("Unexpected exception: ", e); 144 throw new UnexpectedException ("Unexpected " + e, e); 145 } 146 catch (NotSupportedException e) 147 { 148 if (log.isTraceEnabled()) 149 log.trace("Unexpected exception: ", e); 150 throw new UnexpectedException ("Unexpected " + e, e); 151 } 152 } 153 154 public TxPropagationContext recreate(long targetId, 155 TxPropagationContext tpc) 156 throws RemoteException 157 { 158 log.trace("TransactionFactory.recreate"); 159 160 if (tpc == null) 161 throw new IllegalArgumentException ( 162 "recreate: TxPropagationContext parameter cannot be null"); 163 164 TxManager tm = (TxManager) TMUtil.getTransactionManager(); 165 TransactionImpl tx = tm.importExternalTransaction(tpc.formatId, 166 tpc.globalId, 167 tpc.coordinator, 168 tpc.timeout * 1000); 169 170 Coordinator subCoordinator = 172 (Coordinator) RemoteProxy.create(Coordinator.class, 173 tx.getLocalIdValue(), 174 dtm.getLocators()); 175 176 return new TxPropagationContext(tpc.formatId, 178 tpc.globalId, 179 tpc.timeout, 180 subCoordinator, 181 null); 182 } 183 184 186 public Status getStatus(long targetId) 187 throws RemoteException 188 { 189 if (log.isTraceEnabled()) 190 log.trace("Coordinator.getStatus, targetId=" + 191 Long.toHexString(targetId)); 192 193 LocalId localId = new LocalId(targetId); 194 Transaction tx = TMUtil.getTransaction(localId); 195 196 if (tx == null) 197 { 198 log.trace("RemoteException in getStatus: transaction not found"); 199 throw new NoSuchObjectException ("No transaction."); 202 } 204 205 int status; 206 207 try 208 { 209 status = tx.getStatus(); 210 } 211 catch (SystemException e) 212 { 213 if (log.isTraceEnabled()) 214 log.trace("Unexpected exception: ", e); 215 throw new UnexpectedException ("Unexpected " + e, e); 216 } 217 return javaxToJBoss(status); 218 } 219 220 public boolean isSameTransaction(long targetId, Coordinator c) 221 throws RemoteException 222 { 223 if (log.isTraceEnabled()) 224 log.trace("Coordinator.isSameTransaction, targetId=" + 225 Long.toHexString(targetId)); 226 return getTransactionId(targetId).equals(c.getTransactionId()); 227 } 228 229 public int hashTransaction(long targetId) 230 throws RemoteException 231 { 232 if (log.isTraceEnabled()) 233 log.trace("Coordinator.hashTransaction, targetId=" + 234 Long.toHexString(targetId)); 235 return getTransactionId(targetId).hashCode(); 236 } 237 238 public RecoveryCoordinator registerResource(long targetId, Resource r) 239 throws RemoteException , 240 TransactionInactiveException 241 { 242 if (log.isTraceEnabled()) 243 log.trace("Coordinator.registerResource, targetId=" + 244 Long.toHexString(targetId)); 245 246 LocalId localId = new LocalId(targetId); 247 TransactionImpl tx = (TransactionImpl)TMUtil.getTransaction(localId); 248 249 if (tx == null) 250 { 251 log.trace("RemoteException in registerResource: " + 252 "transaction not found"); 253 throw new NoSuchObjectException ("No transaction."); 254 } 255 256 try 257 { 258 tx.enlistRemoteResource(r); 259 } 260 catch (RollbackException e) 261 { 262 if (log.isTraceEnabled()) 263 log.trace("Exception: ", e); 264 TransactionRolledbackException ex = 265 new TransactionRolledbackException (e.toString()); 266 ex.detail = e; 267 throw ex; 268 } 269 catch (IllegalStateException e) 270 { 271 if (log.isTraceEnabled()) 272 log.trace("Exception: ", e); 273 throw new TransactionInactiveException(e); 274 } 275 276 RecoveryCoordinator rc = 278 (RecoveryCoordinator) RemoteProxy.create(RecoveryCoordinator.class, 279 targetId, 280 dtm.getLocators()); 281 return rc; 282 } 283 284 public void registerSynchronization(long targetId, 285 final Synchronization sync) 286 throws RemoteException , 287 TransactionInactiveException 288 { 289 if (log.isTraceEnabled()) 290 log.trace("Coordinator.registerSynchronization, targetId=" + 291 Long.toHexString(targetId)); 292 293 LocalId localId = new LocalId(targetId); 294 Transaction tx = TMUtil.getTransaction(localId); 295 296 if (tx == null) 297 { 298 log.trace("RemoteException in registerSynchronization: " + 299 "transaction not found"); 300 throw new NoSuchObjectException ("No transaction."); 301 } 302 303 try 304 { 305 tx.registerSynchronization( 306 new javax.transaction.Synchronization () 307 { 308 public void beforeCompletion() 309 { 310 try 311 { 312 sync.beforeCompletion(); 313 } 314 catch (RemoteException e) 315 { 316 if (log.isTraceEnabled()) 317 log.trace("RemoteException in beforeCompletion: " + e); 318 } 319 } 320 public void afterCompletion(int status) 321 { 322 try 323 { 324 sync.afterCompletion(javaxToJBoss(status)); 325 } 326 catch (RemoteException e) 327 { 328 if (log.isTraceEnabled()) 329 log.trace("RemoteException in afterCompletion: " + e); 330 } 331 } 332 }); 333 } 334 catch (RollbackException e) 335 { 336 if (log.isTraceEnabled()) 337 log.trace("Exception: ", e); 338 TransactionRolledbackException ex = 339 new TransactionRolledbackException (e.toString()); 340 ex.detail = e; 341 throw ex; 342 } 343 catch (IllegalStateException e) 344 { 345 if (log.isTraceEnabled()) 346 log.trace("Unexpected exception: ", e); 347 throw new TransactionInactiveException(e); 348 } 349 catch (SystemException e) 350 { 351 if (log.isTraceEnabled()) 352 log.trace("Unexpected exception: ", e); 353 throw new UnexpectedException ("Unexpected " + e, e); 354 } 355 } 356 357 public void rollbackOnly(long targetId) 358 throws RemoteException , 359 TransactionInactiveException 360 { 361 if (log.isTraceEnabled()) 362 log.trace("Coordinator.rollbackOnly, targetId=" + 363 Long.toHexString(targetId)); 364 365 LocalId localId = new LocalId(targetId); 366 Transaction tx = TMUtil.getTransaction(localId); 367 368 if (tx == null) 369 { 370 log.trace("RemoteException in rollbackOnly: transaction not found"); 371 throw new NoSuchObjectException ("No transaction."); 372 } 373 374 try 375 { 376 tx.setRollbackOnly(); 377 } 378 catch (IllegalStateException e) 379 { 380 if (log.isTraceEnabled()) 381 log.trace("Unexpected exception: ", e); 382 throw new TransactionInactiveException(e); 383 } 384 catch (SystemException e) 385 { 386 if (log.isTraceEnabled()) 387 log.trace("Unexpected exception: ", e); 388 throw new UnexpectedException ("Unexpected " + e, e); 389 } 390 } 391 392 public TxPropagationContext getTransactionContext(long targetId) 393 throws RemoteException , 394 TransactionInactiveException 395 { 396 if (log.isTraceEnabled()) 397 log.trace("Coordinator.getTransactionContext, targetId=" + 398 Long.toHexString(targetId)); 399 400 LocalId localId = new LocalId(targetId); 401 TransactionImpl tx = (TransactionImpl)TMUtil.getTransaction(localId); 402 403 if (tx == null) 404 { 405 log.trace("RemoteException in getTransactionContext: " + 406 "transaction not found"); 407 throw new NoSuchObjectException ("No transaction."); 408 } 409 410 TxPropagationContext txPropagationContext = tx.getPropagationContext(); 411 if (txPropagationContext != null) 412 return tx.getPropagationContext(); 413 else 414 throw new TransactionInactiveException(); 415 } 416 417 public GlobalId getTransactionId(long targetId) 418 throws RemoteException 419 { 420 if (log.isTraceEnabled()) 421 log.trace("Coordinator.getTransactionId, targetId=" 422 + Long.toHexString(targetId)); 423 424 LocalId localId = new LocalId(targetId); 425 TransactionImpl tx = (TransactionImpl)TMUtil.getTransaction(localId); 426 427 if (tx == null) 428 { 429 log.trace("RemoteException in getTransactionId: " + 430 "transaction not found"); 431 throw new NoSuchObjectException ("No transaction."); 432 } 433 434 return tx.getGlobalId(); 435 } 436 437 439 public void commit(long targetId, boolean reportHeuristics) 440 throws RemoteException , 441 HeuristicMixedException , 442 HeuristicHazardException 443 { 444 if (log.isTraceEnabled()) 445 log.trace("Terminator.commit, targetId=" + 446 Long.toHexString(targetId)); 447 448 LocalId localId = new LocalId(targetId); 449 Transaction tx = TMUtil.getTransaction(localId); 450 451 if (tx == null) 452 { 453 log.trace("RemoteException in commit: transaction not found"); 454 throw new NoSuchObjectException ("No transaction."); 455 } 456 457 try 458 { 459 tx.commit(); 460 } 461 catch (RollbackException e) 462 { 463 if (log.isTraceEnabled()) 464 log.trace("Exception: ", e); 465 TransactionRolledbackException ex = 466 new TransactionRolledbackException (e.toString()); 467 ex.detail = e; 468 throw ex; 469 } 470 catch (HeuristicMixedException e) 471 { 472 if (log.isTraceEnabled()) 473 log.trace("Exception: ", e); 474 if (reportHeuristics) 475 { 476 HeuristicMixedException ex = new HeuristicMixedException (); 477 ex.initCause(e); 478 throw ex; 479 } 480 } 481 catch (HeuristicRollbackException e) 482 { 483 if (log.isTraceEnabled()) 484 log.trace("Exception: ", e); 485 TransactionRolledbackException ex = 486 new TransactionRolledbackException (e.toString()); 487 ex.detail = e; 488 throw ex; 489 } 490 catch (SecurityException e) 491 { 492 if (log.isTraceEnabled()) 493 log.trace("Unexpected exception: ", e); 494 throw new AccessException (e.toString(), e); 495 } 496 catch (IllegalStateException e) 497 { 498 if (log.isTraceEnabled()) 499 log.trace("Unexpected exception: ", e); 500 throw new RemoteException (e.toString(), e); 501 } 502 catch (SystemException e) 503 { 504 if (log.isTraceEnabled()) 505 log.trace("Unexpected exception: ", e); 506 throw new UnexpectedException (e.toString(), e); 507 } 508 } 509 510 public void rollback(long targetId) 511 throws RemoteException 512 { 513 if (log.isTraceEnabled()) 514 log.trace("Terminator.rollback, targetId=" + 515 Long.toHexString(targetId)); 516 517 LocalId localId = new LocalId(targetId); 518 Transaction tx = TMUtil.getTransaction(localId); 519 520 if (tx == null) 521 { 522 log.trace("RemoteException in rollback: transaction not found"); 523 throw new NoSuchObjectException ("No transaction."); 524 } 525 526 try 527 { 528 tx.rollback(); 529 } 530 catch (IllegalStateException e) 531 { 532 if (log.isTraceEnabled()) 533 log.trace("Unexpected exception: ", e); 534 throw new RemoteException (e.toString(), e); 535 } 536 catch (SecurityException e) 537 { 538 if (log.isTraceEnabled()) 539 log.trace("Unexpected exception: ", e); 540 throw new AccessException (e.toString(), e); 541 } 542 catch (SystemException e) 543 { 544 if (log.isTraceEnabled()) 545 log.trace("Unexpected exception: ", e); 546 throw new UnexpectedException (e.toString(), e); 547 } 548 } 549 550 552 public Vote prepare(long targetId) 553 throws RemoteException , 554 HeuristicMixedException , 555 HeuristicHazardException 556 { 557 if (log.isTraceEnabled()) 558 log.trace("Resource.prepare, targetId=" + Long.toHexString(targetId)); 559 560 LocalId localId = new LocalId(targetId); 561 TransactionImpl tx = (TransactionImpl)TMUtil.getTransaction(localId); 562 563 if (tx == null) 564 { 565 log.trace("RemoteException in prepare: transaction not found"); 566 throw new NoSuchObjectException ("No transaction."); 567 } 568 569 TransactionManager tm = TMUtil.getTransactionManager(); 570 try 571 { 572 tm.resume(tx); 573 int vote = tx.prepare(null); 574 575 if (vote == XAResource.XA_OK) 576 return Vote.COMMIT; 577 else return Vote.READONLY; 579 } 580 catch (RollbackException e) 581 { 582 return Vote.ROLLBACK; 583 } 584 catch (javax.transaction.HeuristicMixedException e) 585 { 586 if (log.isTraceEnabled()) 587 log.trace("Exception: ", e); 588 HeuristicMixedException ex = new HeuristicMixedException (); 589 ex.initCause(e); 590 throw ex; 591 } 592 catch (javax.transaction.HeuristicRollbackException e) 593 { 594 if (log.isTraceEnabled()) 595 log.trace("Exception: ", e); 596 HeuristicHazardException ex = new HeuristicHazardException(); 597 ex.initCause(e); 598 throw ex; 599 } 600 catch (Exception e) 601 { 602 if (log.isTraceEnabled()) 603 log.trace("Unexpected exception: ", e); 604 throw new UnexpectedException (e.toString(), e); 605 } 606 finally 607 { 608 try 609 { 610 tm.suspend(); 611 } 612 catch (SystemException e) 613 { 614 if (log.isTraceEnabled()) 615 log.trace("Unexpected exception: ", e); 616 throw new UnexpectedException (e.toString(), e); 617 } 618 } 619 } 620 621 public void rollbackResource(long targetId) 622 throws RemoteException , 623 HeuristicCommitException , 624 HeuristicMixedException , 625 HeuristicHazardException 626 { 627 if (log.isTraceEnabled()) 628 log.trace("Resource.rollback, targetId=" + 629 Long.toHexString(targetId)); 630 631 LocalId localId = new LocalId(targetId); 632 TransactionImpl tx = (TransactionImpl)TMUtil.getTransaction(localId); 633 634 if (tx == null) 635 { 636 log.trace("RemoteException in rollback: transaction not found"); 637 throw new NoSuchObjectException ("No transaction."); 638 } 639 640 try 641 { 642 tx.rollbackBranch(); 643 } 644 catch (IllegalStateException e) 645 { 646 if (log.isTraceEnabled()) 647 log.trace("Unexpected exception: ", e); 648 throw new RemoteException (e.toString(), e); 649 } 650 } 651 652 public void commit(long targetId) 653 throws RemoteException , 654 TransactionNotPreparedException, 655 HeuristicRollbackException , 656 HeuristicMixedException , 657 HeuristicHazardException 658 { 659 if (log.isTraceEnabled()) 660 log.trace("Resource.commit, targetId=" + Long.toHexString(targetId)); 661 662 LocalId localId = new LocalId(targetId); 663 TransactionImpl tx = (TransactionImpl)TMUtil.getTransaction(localId); 664 665 if (tx == null) 666 { 667 log.trace("RemoteException in commit: transaction not found"); 668 throw new NoSuchObjectException ("No transaction."); 669 } 670 671 try 672 { 673 tx.commit(false); 674 } 675 catch (IllegalStateException e) 676 { 677 if (log.isTraceEnabled()) 678 log.trace("Exception: ", e); 679 TransactionNotPreparedException ex = 680 new TransactionNotPreparedException(); 681 ex.initCause(e); 682 throw ex; 683 } 684 catch (RollbackException e) 685 { 686 if (log.isTraceEnabled()) 687 log.trace("Exception: ", e); 688 TransactionRolledbackException ex = 689 new TransactionRolledbackException (e.toString()); 690 ex.detail = e; 691 throw ex; 692 } 693 catch (javax.transaction.HeuristicMixedException e) 694 { 695 if (log.isTraceEnabled()) 696 log.trace("Exception: ", e); 697 HeuristicMixedException ex = new HeuristicMixedException (); 698 ex.initCause(e); 699 throw ex; 700 } 701 catch (javax.transaction.HeuristicRollbackException e) 702 { 703 if (log.isTraceEnabled()) 704 log.trace("Exception: ", e); 705 HeuristicRollbackException ex = new HeuristicRollbackException (); 706 ex.initCause(e); 707 throw ex; 708 } 709 catch (SystemException e) 710 { 711 if (log.isTraceEnabled()) 712 log.trace("Unexpected exception: ", e); 713 throw new UnexpectedException (e.toString(), e); 714 } 715 } 716 717 public void commitOnePhase(long targetId) 718 throws RemoteException , 719 HeuristicHazardException 720 { 721 if (log.isTraceEnabled()) 722 log.trace("Resource.commitOnePhase, targetId=" + 723 Long.toHexString(targetId)); 724 725 LocalId localId = new LocalId(targetId); 726 TransactionImpl tx = (TransactionImpl)TMUtil.getTransaction(localId); 727 728 if (tx == null) 729 { 730 log.trace("RemoteException in commit: transaction not found"); 731 throw new NoSuchObjectException ("No transaction."); 732 } 733 734 try 735 { 736 tx.commit(true); 737 } 738 catch (RollbackException e) 739 { 740 if (log.isTraceEnabled()) 741 log.trace("Exception: ", e); 742 TransactionRolledbackException ex = 743 new TransactionRolledbackException (e.toString()); 744 ex.detail = e; 745 throw ex; 746 } 747 catch (javax.transaction.HeuristicMixedException e) 748 { 749 if (log.isTraceEnabled()) 750 log.trace("Exception: ", e); 751 throw new UnexpectedException (e.toString(), e); 752 } 753 catch (javax.transaction.HeuristicRollbackException e) 754 { 755 if (log.isTraceEnabled()) 756 log.trace("Exception: ", e); 757 throw new UnexpectedException (e.toString(), e); 758 } 759 catch (SystemException e) 760 { 761 if (log.isTraceEnabled()) 762 log.trace("Unexpected exception: ", e); 763 throw new UnexpectedException (e.toString(), e); 764 } 765 } 766 767 public void forget(long targetId) 768 throws RemoteException 769 { 770 if (log.isTraceEnabled()) 771 log.trace("Resource.forget, targetId=" + Long.toHexString(targetId)); 772 773 LocalId localId = new LocalId(targetId); 774 TransactionImpl tx = (TransactionImpl)TMUtil.getTransaction(localId); 775 776 if (tx == null) 777 { 778 log.trace("RemoteException in forget: transaction not found"); 779 throw new NoSuchObjectException ("No transaction."); 780 } 781 782 tx.forget(); 783 } 784 785 787 public Status replayCompletion(long targetId, final Resource r) 788 throws RemoteException , 789 TransactionNotPreparedException 790 { 791 if (log.isTraceEnabled()) 792 log.trace("RecoveryCoordinator.replayCompletion, targetId=" + 793 Long.toHexString(targetId)); 794 795 TxManager tm = (TxManager) TMUtil.getTransactionManager(); 796 if (tm.isRecoveryPending()) 797 { 798 if (log.isTraceEnabled()) 799 log.trace("RecoveryCoordinator.replayCompletion called on" + 800 " targetId=" + Long.toHexString(targetId) + 801 " before recovery is complete.\n" + 802 " Throwing RemoteException."); 803 throw new RemoteException ("Transaction manager not ready."); 804 } 805 806 LocalId localId = new LocalId(targetId); 807 TransactionImpl tx = (TransactionImpl)TMUtil.getTransaction(localId); 808 809 if (tx == null) 810 { 811 log.trace("RemoteException in replayCompletion: " + 812 "transaction not found"); 813 throw new NoSuchObjectException ("No transaction."); 814 } 815 816 int status = tx.replayCompletion(r); 817 818 if (status == javax.transaction.Status.STATUS_MARKED_ROLLBACK || 819 status == javax.transaction.Status.STATUS_NO_TRANSACTION || 820 status == javax.transaction.Status.STATUS_ROLLEDBACK || 821 status == javax.transaction.Status.STATUS_ROLLING_BACK) 822 { 823 Runnable runnable = new Runnable () 824 { 825 public void run() 826 { 827 try 828 { 829 r.rollback(); 830 } 831 catch (Exception ignore) 832 { 833 if (log.isTraceEnabled()) 837 log.trace("Ignoring exception in remote resource rollback", 838 ignore); 839 } 840 } 841 }; 842 Thread t = new Thread (runnable, "resourceRollbackThread"); 843 844 t.start(); 845 } 846 return javaxToJBoss(status); 847 } 848 849 852 public void beforeCompletion(long targetId) 853 { 854 if (log.isTraceEnabled()) 856 log.trace("Synchronization.beforeCompletion, targetId=" + 857 Long.toHexString(targetId)); 858 } 859 860 public void afterCompletion(long targetId) 861 { 862 if (log.isTraceEnabled()) 864 log.trace("Synchronization.afterCompletion, targetId=" + 865 Long.toHexString(targetId)); 866 } 867 868 870 875 public Coordinator createCoordinator(long localId) 876 { 877 return (Coordinator) RemoteProxy.create(Coordinator.class, 878 localId, 879 dtm.getLocators()); 880 } 881 882 884 889 public Resource createResource(long localId) 890 { 891 return (Resource ) RemoteProxy.create(Resource .class, 892 localId, 893 dtm.getLocators()); 894 } 895 896 898 905 public Resource stringToResource(String strResource) 906 { 907 try 908 { 909 return (Resource ) RemoteProxy.fromString(strResource); 910 } 911 catch (Exception e) 912 { 913 throw new RuntimeException (e); 914 } 915 } 916 917 925 public RecoveryCoordinator stringToRecoveryCoordinator( 926 String strRecCoordinator) 927 { 928 try 929 { 930 return (RecoveryCoordinator) RemoteProxy.fromString(strRecCoordinator); 931 } 932 catch (Exception e) 933 { 934 throw new RuntimeException (e); 935 } 936 } 937 938 944 public String resourceToString(Resource res) 945 { 946 return RemoteProxy.toString((Proxy )res); 947 } 948 949 956 public String recoveryCoordinatorToString(RecoveryCoordinator recoveryCoord) 957 { 958 return RemoteProxy.toString((Proxy )recoveryCoord); 959 } 960 961 963 private static Status javaxToJBoss(int status) 964 { 965 return Status.fromInteger(status); 966 } 967 } 968 | Popular Tags |