View Javadoc

1   /***
2    *  Copyright 2003-2010 Terracotta, Inc.
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 net.sf.ehcache.transaction.xa.processor;
18  
19  import javax.transaction.xa.Xid;
20  
21  /***
22   * 
23   * @author Nabib El-Rahman
24   *
25   */
26  public class XARequest {
27  
28      private final RequestType requestType;
29  
30      private final Xid xid;
31      private final boolean onePhase;
32   
33      /***
34       * Constructor
35       * 
36       * @param requestType what request is this representing
37       * @param xid the Xid of the transaction this request is being executed for
38       */
39      public XARequest(RequestType requestType, Xid xid) {
40          this(requestType, xid, false);
41      }
42      
43      /***
44       * Constructor
45       * 
46       * @param requestType what request is this representing
47       * @param xid the Xid of the transaction this request is being executed for
48       * @param onePhase whether this is a single phase commit
49       */
50      public XARequest(RequestType requestType, Xid xid, boolean onePhase) {
51          this.requestType = requestType;
52          this.xid = xid;
53          this.onePhase = onePhase;
54      }
55      
56      /***
57       * XA Requests types
58       * 
59       * @author Nabib El-Rahman
60       *
61       */
62      public static enum RequestType {
63          
64          /***
65           * prepare
66           */
67          PREPARE,
68          
69          /***
70           * commit
71           */
72          COMMIT,
73          
74          /***
75           * forget
76           */
77          FORGET,
78          
79          /***
80           * rollback
81           */
82          ROLLBACK;
83      }
84  
85      /***
86       * 
87       * @return the type of request
88       */
89      public RequestType getRequestType() {
90          return requestType;
91      }
92  
93      /***
94       * 
95       * @return the Xid of the Transaction
96       */
97      public Xid getXid() {
98          return xid;
99      }
100 
101     /***
102      * 
103      * @return true is one phase commit requested, otherwise false
104      */
105     public boolean isOnePhase() {
106         return onePhase;
107     }
108 
109 }