KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > transaction > UserTransaction


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.transaction;
25
26 import java.lang.IllegalArgumentException JavaDoc;
27 import java.lang.IllegalStateException JavaDoc;
28 import java.lang.SecurityException JavaDoc;
29
30 /**
31  * The UserTransaction interface defines the methods that allow an
32  * application to explicitly manage transaction boundaries.
33  */

34 public interface UserTransaction {
35
36     /**
37      * Create a new transaction and associate it with the current thread.
38      *
39      * @exception NotSupportedException Thrown if the thread is already
40      * associated with a transaction and the Transaction Manager
41      * implementation does not support nested transactions.
42      *
43      * @exception SystemException Thrown if the transaction manager
44      * encounters an unexpected error condition.
45      *
46      */

47     void begin() throws NotSupportedException JavaDoc, SystemException JavaDoc;
48
49     /**
50      * Complete the transaction associated with the current thread. When this
51      * method completes, the thread is no longer associated with a transaction.
52      *
53      * @exception RollbackException Thrown to indicate that
54      * the transaction has been rolled back rather than committed.
55      *
56      * @exception HeuristicMixedException Thrown to indicate that a heuristic
57      * decision was made and that some relevant updates have been committed
58      * while others have been rolled back.
59      *
60      * @exception HeuristicRollbackException Thrown to indicate that a
61      * heuristic decision was made and that all relevant updates have been
62      * rolled back.
63      *
64      * @exception SecurityException Thrown to indicate that the thread is
65      * not allowed to commit the transaction.
66      *
67      * @exception IllegalStateException Thrown if the current thread is
68      * not associated with a transaction.
69      *
70      * @exception SystemException Thrown if the transaction manager
71      * encounters an unexpected error condition.
72     */

73     void commit() throws RollbackException JavaDoc,
74     HeuristicMixedException JavaDoc, HeuristicRollbackException JavaDoc, SecurityException JavaDoc,
75     IllegalStateException JavaDoc, SystemException JavaDoc;
76
77     /**
78      * Roll back the transaction associated with the current thread. When this
79      * method completes, the thread is no longer associated with a transaction.
80      *
81      * @exception SecurityException Thrown to indicate that the thread is
82      * not allowed to roll back the transaction.
83      *
84      * @exception IllegalStateException Thrown if the current thread is
85      * not associated with a transaction.
86      *
87      * @exception SystemException Thrown if the transaction manager
88      * encounters an unexpected error condition.
89      *
90      */

91     void rollback() throws IllegalStateException JavaDoc, SecurityException JavaDoc,
92         SystemException JavaDoc;
93
94     /**
95      * Modify the transaction associated with the current thread such that
96      * the only possible outcome of the transaction is to roll back the
97      * transaction.
98      *
99      * @exception IllegalStateException Thrown if the current thread is
100      * not associated with a transaction.
101      *
102      * @exception SystemException Thrown if the transaction manager
103      * encounters an unexpected error condition.
104      *
105      */

106     void setRollbackOnly() throws IllegalStateException JavaDoc, SystemException JavaDoc;
107
108     /**
109      * Obtain the status of the transaction associated with the current thread.
110      *
111      * @return The transaction status. If no transaction is associated with
112      * the current thread, this method returns the Status.NoTransaction
113      * value.
114      *
115      * @exception SystemException Thrown if the transaction manager
116      * encounters an unexpected error condition.
117      *
118      */

119     int getStatus() throws SystemException JavaDoc;
120
121     /**
122      * Modify the timeout value that is associated with transactions started
123      * by the current thread with the begin method.
124      *
125      * <p> If an application has not called this method, the transaction
126      * service uses some default value for the transaction timeout.
127      *
128      * @param seconds The value of the timeout in seconds. If the value is zero,
129      * the transaction service restores the default value. If the value
130      * is negative a SystemException is thrown.
131      *
132      * @exception SystemException Thrown if the transaction manager
133      * encounters an unexpected error condition.
134      *
135      */

136     void setTransactionTimeout(int seconds) throws SystemException JavaDoc;
137 }
138
Popular Tags