1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 2000-2007 Sun Microsystems, Inc. All rights reserved.
5 *
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common Development
8 * and Distribution License ("CDDL") (collectively, the "License"). You may
9 * not use this file except in compliance with the License. You can obtain
10 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
11 * or mq/legal/LICENSE.txt. See the License for the specific language
12 * governing permissions and limitations under the License.
13 *
14 * When distributing the software, include this License Header Notice in each
15 * file and include the License file at mq/legal/LICENSE.txt. Sun designates
16 * this particular file as subject to the "Classpath" exception as provided by
17 * Sun in the GPL Version 2 section of the License file that accompanied this
18 * code. If applicable, add the following below the License Header, with the
19 * fields enclosed by brackets [] replaced by your own identifying information:
20 * "Portions Copyrighted [year] [name of copyright owner]"
21 *
22 * Contributor(s):
23 *
24 * If you wish your version of this file to be governed by only the CDDL or
25 * only the GPL Version 2, indicate your decision by adding "[Contributor]
26 * elects to include this software in this distribution under the [CDDL or GPL
27 * Version 2] license." If you don't indicate a single choice of license, a
28 * recipient has the option to distribute your version of this file under
29 * either the CDDL, the GPL Version 2 or to extend the choice of license to
30 * its licensees as provided above. However, if you add GPL Version 2 code
31 * and therefore, elected the GPL Version 2 license, then the option applies
32 * only if the new code is made subject to such option by the copyright holder.
33 */
34
35 /*
36 * @(#)XASession.java 1.20 07/02/07
37 */
38
39 package javax.jms;
40
41 import javax.transaction.xa.XAResource;
42
43 /** The <CODE>XASession</CODE> interface extends the capability of
44 * <CODE>Session</CODE> by adding access to a JMS provider's support for the
45 * Java Transaction API (JTA) (optional). This support takes the form of a
46 * <CODE>javax.transaction.xa.XAResource</CODE> object. The functionality of
47 * this object closely resembles that defined by the standard X/Open XA
48 * Resource interface.
49 *
50 * <P>An application server controls the transactional assignment of an
51 * <CODE>XASession</CODE> by obtaining its <CODE>XAResource</CODE>. It uses
52 * the <CODE>XAResource</CODE> to assign the session to a transaction, prepare
53 * and commit work on the transaction, and so on.
54 *
55 * <P>An <CODE>XAResource</CODE> provides some fairly sophisticated facilities
56 * for interleaving work on multiple transactions, recovering a list of
57 * transactions in progress, and so on. A JTA aware JMS provider must fully
58 * implement this functionality. This could be done by using the services
59 * of a database that supports XA, or a JMS provider may choose to implement
60 * this functionality from scratch.
61 *
62 * <P>A client of the application server is given what it thinks is a
63 * regular JMS <CODE>Session</CODE>. Behind the scenes, the application server
64 * controls the transaction management of the underlying
65 * <CODE>XASession</CODE>.
66 *
67 * <P>The <CODE>XASession</CODE> interface is optional. JMS providers
68 * are not required to support this interface. This interface is for
69 * use by JMS providers to support transactional environments.
70 * Client programs are strongly encouraged to use the transactional support
71 * available in their environment, rather than use these XA
72 * interfaces directly.
73 *
74 * @see javax.jms.Session
75 */
76
77 public interface XASession extends Session {
78
79 /** Gets the session associated with this <CODE>XASession</CODE>.
80 *
81 * @return the session object
82 *
83 * @exception JMSException if an internal error occurs.
84 *
85 * @since 1.1
86 */
87
88 Session
89 getSession() throws JMSException;
90
91 /** Returns an XA resource to the caller.
92 *
93 * @return an XA resource to the caller
94 */
95
96 XAResource
97 getXAResource();
98
99 /** Indicates whether the session is in transacted mode.
100 *
101 * @return true
102 *
103 * @exception JMSException if the JMS provider fails to return the
104 * transaction mode due to some internal error.
105 */
106
107 boolean
108 getTransacted() throws JMSException;
109
110
111 /** Throws a <CODE>TransactionInProgressException</CODE>, since it should
112 * not be called for an <CODE>XASession</CODE> object.
113 *
114 * @exception TransactionInProgressException if the method is called on
115 * an <CODE>XASession</CODE>.
116 *
117 */
118
119 void
120 commit() throws JMSException;
121
122
123 /** Throws a <CODE>TransactionInProgressException</CODE>, since it should
124 * not be called for an <CODE>XASession</CODE> object.
125 *
126 * @exception TransactionInProgressException if the method is called on
127 * an <CODE>XASession</CODE>.
128 *
129 */
130
131 void
132 rollback() throws JMSException;
133 }