KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > resource > spi > XATerminator


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package javax.resource.spi;
25
26 import javax.transaction.xa.Xid JavaDoc;
27 import javax.transaction.xa.XAException JavaDoc;
28
29 /**
30  * <p>The XATerminator interface is used for transaction completion and
31  * crash recovery flows.
32  *
33  * @version 1.0
34  * @author Ram Jeyaraman
35  *
36  */

37 public interface XATerminator {
38
39     /**
40      * Commits the global transaction specified by xid.
41      *
42      * @param xid A global transaction identifier
43      *
44      * @param onePhase If true, the resource manager should use a one-phase
45      * commit protocol to commit the work done on behalf of xid.
46      *
47      * @exception XAException An error has occurred. Possible XAExceptions
48      * are XA_HEURHAZ, XA_HEURCOM, XA_HEURRB, XA_HEURMIX, XAER_RMERR,
49      * XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or XAER_PROTO.
50      *
51      * <P>If the resource manager did not commit the transaction and the
52      * parameter onePhase is set to true, the resource manager may throw
53      * one of the XA_RB* exceptions. Upon return, the resource manager has
54      * rolled back the branch's work and has released all held resources.
55      */

56     void commit(Xid JavaDoc xid, boolean onePhase) throws XAException JavaDoc;
57
58     /**
59      * Tells the resource manager to forget about a heuristically
60      * completed transaction branch.
61      *
62      * @param xid A global transaction identifier.
63      *
64      * @exception XAException An error has occurred. Possible exception
65      * values are XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or
66      * XAER_PROTO.
67      */

68     void forget(Xid JavaDoc xid) throws XAException JavaDoc;
69
70     /**
71      * Ask the resource manager to prepare for a transaction commit
72      * of the transaction specified in xid.
73      *
74      * @param xid A global transaction identifier.
75      *
76      * @exception XAException An error has occurred. Possible exception
77      * values are: XA_RB*, XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL,
78      * or XAER_PROTO.
79      *
80      * @return A value indicating the resource manager's vote on the
81      * outcome of the transaction. The possible values are: XA_RDONLY
82      * or XA_OK. These constants are defined in
83      * <code> javax.transaction.xa.XAResource</code> interface.
84      * If the resource manager wants to roll back the
85      * transaction, it should do so by raising an appropriate XAException
86      * in the prepare method.
87      */

88     int prepare(Xid JavaDoc xid) throws XAException JavaDoc;
89
90     /**
91      * Obtains a list of prepared transaction branches from a resource
92      * manager. The transaction manager calls this method during recovery
93      * to obtain the list of transaction branches that are currently in
94      * prepared or heuristically completed states.
95      *
96      * @param flag One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS
97      * must be used when no other flags are set in the parameter. These
98      * constants are defined in <code>javax.transaction.xa.XAResource</code>
99      * interface.
100      *
101      * @exception XAException An error has occurred. Possible values are
102      * XAER_RMERR, XAER_RMFAIL, XAER_INVAL, and XAER_PROTO.
103      *
104      * @return The resource manager returns zero or more XIDs of the
105      * transaction branches that are currently in a prepared or
106      * heuristically completed state. If an error occurs during the
107      * operation, the resource manager should throw the appropriate
108      * XAException.
109      */

110     Xid JavaDoc[] recover(int flag) throws XAException JavaDoc;
111
112     /**
113      * Informs the resource manager to roll back work done on behalf
114      * of a transaction branch.
115      *
116      * @param xid A global transaction identifier.
117      *
118      * @exception XAException An error has occurred. Possible XAExceptions are
119      * XA_HEURHAZ, XA_HEURCOM, XA_HEURRB, XA_HEURMIX, XAER_RMERR, XAER_RMFAIL,
120      * XAER_NOTA, XAER_INVAL, or XAER_PROTO.
121      *
122      * <p>If the transaction branch is already marked rollback-only the
123      * resource manager may throw one of the XA_RB* exceptions. Upon return,
124      * the resource manager has rolled back the branch's work and has released
125      * all held resources.
126      */

127     void rollback(Xid JavaDoc xid) throws XAException JavaDoc;
128 }
129
130
131
Popular Tags