KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > transaction > HeuristicCompletionException


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.transaction;
18
19 /**
20  * Exception that represents a transaction failure caused by a heuristic
21  * decision on the side of the transaction coordinator.
22  *
23  * @author Rod Johnson
24  * @author Juergen Hoeller
25  * @since 17.03.2003
26  */

27 public class HeuristicCompletionException extends TransactionException {
28
29     /**
30      * Values for the outcome state of a heuristically completed transaction.
31      */

32     public static final int STATE_UNKNOWN = 0;
33     public static final int STATE_COMMITTED = 1;
34     public static final int STATE_ROLLED_BACK = 2;
35     public static final int STATE_MIXED = 3;
36
37
38     public static String JavaDoc getStateString(int state) {
39         switch (state) {
40             case STATE_COMMITTED:
41                 return "committed";
42             case STATE_ROLLED_BACK:
43                 return "rolled back";
44             case STATE_MIXED:
45                 return "mixed";
46             default:
47                 return "unknown";
48         }
49     }
50
51
52     /**
53      * The outcome state of the transaction: have some or all resources been committed?
54      */

55     private int outcomeState = STATE_UNKNOWN;
56
57
58     /**
59      * Constructor for HeuristicCompletionException.
60      * @param outcomeState the outcome state of the transaction
61      * @param cause the root cause from the transaction API in use
62      */

63     public HeuristicCompletionException(int outcomeState, Throwable JavaDoc cause) {
64         super("Heuristic completion: outcome state is " + getStateString(outcomeState), cause);
65         this.outcomeState = outcomeState;
66     }
67
68     /**
69      * Return the outcome state of the transaction state,
70      * as one of the constants in this class.
71      * @see #STATE_UNKNOWN
72      * @see #STATE_COMMITTED
73      * @see #STATE_ROLLED_BACK
74      * @see #STATE_MIXED
75      */

76     public int getOutcomeState() {
77         return outcomeState;
78     }
79
80 }
81
Popular Tags