1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.jms;
  6. import javax.transaction.xa.XAResource;
  7. /** The <CODE>XASession</CODE> interface extends the capability of
  8. * <CODE>Session</CODE> by adding access to a JMS provider's support for the
  9. * Java Transaction API (JTA) (optional). This support takes the form of a
  10. * <CODE>javax.transaction.xa.XAResource</CODE> object. The functionality of
  11. * this object closely resembles that defined by the standard X/Open XA
  12. * Resource interface.
  13. *
  14. * <P>An application server controls the transactional assignment of an
  15. * <CODE>XASession</CODE> by obtaining its <CODE>XAResource</CODE>. It uses
  16. * the <CODE>XAResource</CODE> to assign the session to a transaction, prepare
  17. * and commit work on the transaction, and so on.
  18. *
  19. * <P>An <CODE>XAResource</CODE> provides some fairly sophisticated facilities
  20. * for interleaving work on multiple transactions, recovering a list of
  21. * transactions in progress, and so on. A JTA aware JMS provider must fully
  22. * implement this functionality. This could be done by using the services
  23. * of a database that supports XA, or a JMS provider may choose to implement
  24. * this functionality from scratch.
  25. *
  26. * <P>A client of the application server is given what it thinks is a
  27. * regular JMS <CODE>Session</CODE>. Behind the scenes, the application server
  28. * controls the transaction management of the underlying
  29. * <CODE>XASession</CODE>.
  30. *
  31. * @version 1.0 - 13 August 1998
  32. * @author Mark Hapner
  33. * @author Rich Burridge
  34. *
  35. * @see javax.jms.Session
  36. */
  37. public interface XASession extends Session {
  38. /** Returns an XA resource to the caller.
  39. *
  40. * @return an XA resource to the caller
  41. */
  42. XAResource
  43. getXAResource();
  44. /** Indicates whether the session is in transacted mode.
  45. *
  46. * @return true
  47. *
  48. * @exception JMSException if the JMS provider fails to return the
  49. * transaction mode due to some internal error.
  50. */
  51. boolean
  52. getTransacted() throws JMSException;
  53. /** Throws a <CODE>TransactionInProgressException</CODE>, since it should
  54. * not be called for an <CODE>XASession</CODE> object.
  55. *
  56. * @exception TransactionInProgressException if the method is called on
  57. * an <CODE>XASession</CODE>.
  58. *
  59. */
  60. void
  61. commit() throws JMSException;
  62. /** Throws a <CODE>TransactionInProgressException</CODE>, since it should
  63. * not be called for an <CODE>XASession</CODE> object.
  64. *
  65. * @exception TransactionInProgressException if the method is called on
  66. * an <CODE>XASession</CODE>.
  67. *
  68. */
  69. void
  70. rollback() throws JMSException;
  71. }