KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > exceptions > TransactionException


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
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
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 in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.exceptions;
23
24 import oracle.toplink.essentials.exceptions.i18n.ExceptionMessageGenerator;
25 import oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl;
26
27 public class TransactionException extends TopLinkException {
28     public static final int ERROR_DOING_JNDI_LOOKUP = 23001;
29     public static final int ERROR_GETTING_TRANSACTION_STATUS = 23002;
30     public static final int ERROR_GETTING_TRANSACTION = 23003;
31     public static final int ERROR_BINDING_TO_TRANSACTION = 23004;
32     public static final int ERROR_BEGINNING_TRANSACTION = 23005;
33     public static final int ERROR_COMMITTING_TRANSACTION = 23006;
34     public static final int ERROR_ROLLING_BACK_TRANSACTION = 23007;
35     public static final int ERROR_MARKING_TRANSACTION_FOR_ROLLBACK = 23008;
36     public static final int ERROR_NO_EXTERNAL_TRANSACTION_ACTIVE = 23009;
37     public static final int ERROR_INACTIVE_UOW = 23010;
38     public static final int ERROR_OBTAINING_TRANSACTION_MANAGER = 23011;
39     public static final int ERROR_NO_TRANSACTION_ACTIVE = 23012;
40     public static final int ERROR_TRANSACTION_IS_ACTIVE = 23013;
41     public static final int ENTITY_TRANSACTION_WITH_JTA_NOT_ALLOWED = 23014;
42     public static final int CANNOT_ENLIST_MULTIPLE_DATASOURCES = 23015;
43     public static final int EXCEPTION_IN_PROXY_EXECUTION= 23016;
44
45     public TransactionException(String JavaDoc message) {
46         super(message);
47     }
48
49     public TransactionException(String JavaDoc message, Exception JavaDoc internalException) {
50         super(message, internalException);
51     }
52
53     public static TransactionException jndiLookupException(String JavaDoc jndiName, Exception JavaDoc internalException) {
54         Object JavaDoc[] args = { jndiName };
55         TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_DOING_JNDI_LOOKUP, args));
56         ex.setErrorCode(ERROR_DOING_JNDI_LOOKUP);
57         ex.setInternalException(internalException);
58         return ex;
59     }
60
61     public static TransactionException errorGettingExternalTransactionStatus(Exception JavaDoc internalException) {
62         Object JavaDoc[] args = { };
63         TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_GETTING_TRANSACTION_STATUS, args));
64         ex.setErrorCode(ERROR_GETTING_TRANSACTION_STATUS);
65         ex.setInternalException(internalException);
66         return ex;
67     }
68
69     public static TransactionException errorGettingExternalTransaction(Exception JavaDoc internalException) {
70         Object JavaDoc[] args = { };
71         TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_GETTING_TRANSACTION, args));
72         ex.setErrorCode(ERROR_GETTING_TRANSACTION);
73         ex.setInternalException(internalException);
74         return ex;
75     }
76
77     public static TransactionException errorBindingToExternalTransaction(Exception JavaDoc internalException) {
78         Object JavaDoc[] args = { };
79         TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_BINDING_TO_TRANSACTION, args));
80         ex.setErrorCode(ERROR_BINDING_TO_TRANSACTION);
81         ex.setInternalException(internalException);
82         return ex;
83     }
84
85     public static TransactionException errorBeginningExternalTransaction(Exception JavaDoc internalException) {
86         Object JavaDoc[] args = { };
87         TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_BEGINNING_TRANSACTION, args));
88         ex.setErrorCode(ERROR_BEGINNING_TRANSACTION);
89         ex.setInternalException(internalException);
90         return ex;
91     }
92
93     public static TransactionException errorCommittingExternalTransaction(Exception JavaDoc internalException) {
94         Object JavaDoc[] args = { };
95         TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_COMMITTING_TRANSACTION, args));
96         ex.setErrorCode(ERROR_COMMITTING_TRANSACTION);
97         ex.setInternalException(internalException);
98         return ex;
99     }
100
101     public static TransactionException errorRollingBackExternalTransaction(Exception JavaDoc internalException) {
102         Object JavaDoc[] args = { };
103         TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_ROLLING_BACK_TRANSACTION, args));
104         ex.setErrorCode(ERROR_ROLLING_BACK_TRANSACTION);
105         ex.setInternalException(internalException);
106         return ex;
107     }
108
109     public static TransactionException errorMarkingTransactionForRollback(Exception JavaDoc internalException) {
110         Object JavaDoc[] args = { };
111         TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_MARKING_TRANSACTION_FOR_ROLLBACK, args));
112         ex.setErrorCode(ERROR_MARKING_TRANSACTION_FOR_ROLLBACK);
113         ex.setInternalException(internalException);
114         return ex;
115     }
116
117     public static TransactionException externalTransactionNotActive() {
118         Object JavaDoc[] args = { };
119         TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_NO_EXTERNAL_TRANSACTION_ACTIVE, args));
120         ex.setErrorCode(ERROR_NO_EXTERNAL_TRANSACTION_ACTIVE);
121         return ex;
122     }
123
124     public static TransactionException inactiveUnitOfWork(UnitOfWorkImpl unitOfWork) {
125         Object JavaDoc[] args = { unitOfWork };
126         TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_INACTIVE_UOW, args));
127         ex.setErrorCode(ERROR_INACTIVE_UOW);
128         return ex;
129     }
130
131     public static TransactionException errorObtainingTransactionManager(Exception JavaDoc internalException) {
132         Object JavaDoc[] args = { };
133         TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_OBTAINING_TRANSACTION_MANAGER, args));
134         ex.setErrorCode(ERROR_OBTAINING_TRANSACTION_MANAGER);
135         ex.setInternalException(internalException);
136         return ex;
137     }
138     
139     public static TransactionException transactionNotActive() {
140         Object JavaDoc[] args = { };
141         TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_NO_TRANSACTION_ACTIVE, args));
142         ex.setErrorCode(ERROR_NO_TRANSACTION_ACTIVE);
143         return ex;
144     }
145     public static TransactionException transactionIsActive() {
146         Object JavaDoc[] args = { };
147         TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ERROR_TRANSACTION_IS_ACTIVE, args));
148         ex.setErrorCode(ERROR_TRANSACTION_IS_ACTIVE);
149         return ex;
150     }
151
152     public static TransactionException entityTransactionWithJTANotAllowed() {
153         Object JavaDoc[] args = { };
154         TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, ENTITY_TRANSACTION_WITH_JTA_NOT_ALLOWED, args));
155         ex.setErrorCode(ENTITY_TRANSACTION_WITH_JTA_NOT_ALLOWED);
156         return ex;
157     }
158
159     public static TransactionException multipleResourceException() {
160         Object JavaDoc[] args = { };
161         TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, CANNOT_ENLIST_MULTIPLE_DATASOURCES, args));
162         ex.setErrorCode(CANNOT_ENLIST_MULTIPLE_DATASOURCES);
163         return ex;
164     }
165
166     public static TransactionException internalProxyException(Exception JavaDoc ex1) {
167         Object JavaDoc[] args = { };
168         TransactionException ex = new TransactionException(ExceptionMessageGenerator.buildMessage(TransactionException.class, EXCEPTION_IN_PROXY_EXECUTION, args), ex1);
169         ex.setErrorCode(EXCEPTION_IN_PROXY_EXECUTION);
170         return ex;
171     }
172 }
173
Popular Tags