1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.transaction;
  6. import java.lang.IllegalArgumentException;
  7. import java.lang.IllegalStateException;
  8. import java.lang.SecurityException;
  9. /**
  10. * The UserTransaction interface defines the methods that allow an
  11. * application to explicitly manage transaction boundaries.
  12. */
  13. public interface UserTransaction {
  14. /**
  15. * Create a new transaction and associate it with the current thread.
  16. *
  17. * @exception NotSupportedException Thrown if the thread is already
  18. * associated with a transaction and the Transaction Manager
  19. * implementation does not support nested transactions.
  20. *
  21. * @exception SystemException Thrown if the transaction manager
  22. * encounters an unexpected error condition
  23. *
  24. */
  25. void begin() throws NotSupportedException, SystemException;
  26. /**
  27. * Complete the transaction associated with the current thread. When this
  28. * method completes, the thread becomes associated with no transaction.
  29. *
  30. * @exception RollbackException Thrown to indicate that
  31. * the transaction has been rolled back rather than committed.
  32. *
  33. * @exception HeuristicMixedException Thrown to indicate that a heuristic
  34. * decision was made and that some relevant updates have been committed
  35. * while others have been rolled back.
  36. *
  37. * @exception HeuristicRollbackException Thrown to indicate that a
  38. * heuristic decision was made and that some relevant updates have been
  39. * rolled back.
  40. *
  41. * @exception SecurityException Thrown to indicate that the thread is
  42. * not allowed to commit the transaction.
  43. *
  44. * @exception IllegalStateException Thrown if the current thread is
  45. * not associated with a transaction.
  46. *
  47. * @exception SystemException Thrown if the transaction manager
  48. * encounters an unexpected error condition
  49. */
  50. void commit() throws RollbackException,
  51. HeuristicMixedException, HeuristicRollbackException, SecurityException,
  52. IllegalStateException, SystemException;
  53. /**
  54. * Roll back the transaction associated with the current thread. When this
  55. * method completes, the thread becomes associated with no transaction.
  56. *
  57. * @exception SecurityException Thrown to indicate that the thread is
  58. * not allowed to roll back the transaction.
  59. *
  60. * @exception IllegalStateException Thrown if the current thread is
  61. * not associated with a transaction.
  62. *
  63. * @exception SystemException Thrown if the transaction manager
  64. * encounters an unexpected error condition
  65. *
  66. */
  67. void rollback() throws IllegalStateException, SecurityException,
  68. SystemException;
  69. /**
  70. * Modify the transaction associated with the current thread such that
  71. * the only possible outcome of the transaction is to roll back the
  72. * transaction.
  73. *
  74. * @exception IllegalStateException Thrown if the current thread is
  75. * not associated with a transaction.
  76. *
  77. * @exception SystemException Thrown if the transaction manager
  78. * encounters an unexpected error condition
  79. *
  80. */
  81. void setRollbackOnly() throws IllegalStateException, SystemException;
  82. /**
  83. * Obtain the status of the transaction associated with the current thread.
  84. *
  85. * @return The transaction status. If no transaction is associated with
  86. * the current thread, this method returns the Status.NoTransaction
  87. * value.
  88. *
  89. * @exception SystemException Thrown if the transaction manager
  90. * encounters an unexpected error condition
  91. *
  92. */
  93. int getStatus() throws SystemException;
  94. /**
  95. * Modify the value of the timeout value that is associated with the
  96. * transactions started by the current thread with the begin method.
  97. *
  98. * <p> If an application has not called this method, the transaction
  99. * service uses some default value for the transaction timeout.
  100. *
  101. * @param seconds The value of the timeout in seconds. If the value
  102. * is zero, the transaction service restores the default value.
  103. *
  104. * @exception SystemException Thrown if the transaction manager
  105. * encounters an unexpected error condition
  106. *
  107. */
  108. void setTransactionTimeout(int seconds) throws SystemException;
  109. }