View Javadoc

1   package org.csc.phynixx.xa;
2   
3   /*
4    * #%L
5    * phynixx-xa
6    * %%
7    * Copyright (C) 2014 csc
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  
24  import javax.transaction.Status;
25  import javax.transaction.xa.XAException;
26  import javax.transaction.xa.XAResource;
27  import java.util.HashMap;
28  import java.util.Map;
29  
30  public abstract class ConstantsPrinter {
31  
32      private static Map stati = new HashMap();
33      private static Map xaresourceFlags = new HashMap();
34      private static Map errorcodes = new HashMap();
35  
36      static {
37          stati.put(new Integer(Status.STATUS_ACTIVE), "STATUS_ACTIVE");
38          stati.put(new Integer(Status.STATUS_NO_TRANSACTION), "STATUS_NO_TRANSACTION");
39          stati.put(new Integer(Status.STATUS_MARKED_ROLLBACK), "STATUS_MARKED_ROLLBACK");
40          stati.put(new Integer(Status.STATUS_UNKNOWN), "STATUS_UNKNOWN");
41          stati.put(new Integer(Status.STATUS_COMMITTED), "STATUS_COMMITTED");
42          stati.put(new Integer(Status.STATUS_COMMITTING), "STATUS_COMMITTING");
43          stati.put(new Integer(Status.STATUS_PREPARED), "STATUS_PREPARED");
44          stati.put(new Integer(Status.STATUS_PREPARING), "STATUS_PREPARING");
45          stati.put(new Integer(Status.STATUS_ROLLEDBACK), "STATUS_ROLLEDBACK");
46          stati.put(new Integer(Status.STATUS_ROLLING_BACK), "STATUS_ROLLING_BACK");
47  
48          xaresourceFlags.put(new Integer(XAResource.TMFAIL), "TMFAIL");
49          xaresourceFlags.put(new Integer(XAResource.TMSTARTRSCAN), "TMSTARTRSCAN");
50          xaresourceFlags.put(new Integer(XAResource.TMENDRSCAN), "TMENDRSCAN");
51          xaresourceFlags.put(new Integer(XAResource.TMJOIN), "TMJOIN");
52          xaresourceFlags.put(new Integer(XAResource.TMNOFLAGS), "TMNOFLAGS");
53          xaresourceFlags.put(new Integer(XAResource.TMONEPHASE), "TMONEPHASE");
54          xaresourceFlags.put(new Integer(XAResource.TMRESUME), "TMRESUME");
55          xaresourceFlags.put(new Integer(XAResource.TMSUCCESS), "TMSUCCESS");
56          xaresourceFlags.put(new Integer(XAResource.TMSUSPEND), "TMSUSPEND");
57          xaresourceFlags.put(new Integer(XAResource.XA_OK), "XA_OK");
58          xaresourceFlags.put(new Integer(XAResource.XA_RDONLY), "XA_RDONLY");
59  
60  
61          errorcodes.put(new Integer(XAException.XA_HEURCOM), "XA_HEURCOM");
62          errorcodes.put(new Integer(XAException.XA_HEURHAZ), "XA_HEURHAZ");
63          errorcodes.put(new Integer(XAException.XA_HEURMIX), "XA_HEURMIX");
64          errorcodes.put(new Integer(XAException.XA_HEURRB), "XA_HEURRB");
65          errorcodes.put(new Integer(XAException.XA_NOMIGRATE), "XA_NOMIGRATE");
66          errorcodes.put(new Integer(XAException.XA_RBBASE), "XA_RBBASE");
67          errorcodes.put(new Integer(XAException.XA_RBCOMMFAIL), "XA_RBCOMMFAIL");
68          errorcodes.put(new Integer(XAException.XA_RBDEADLOCK), "XA_RBDEADLOCK");
69          errorcodes.put(new Integer(XAException.XA_RBEND), "XA_RBEND");
70          errorcodes.put(new Integer(XAException.XA_RBINTEGRITY), "XA_RBINTEGRITY");
71          errorcodes.put(new Integer(XAException.XA_RBOTHER), "XA_RBOTHER");
72          errorcodes.put(new Integer(XAException.XA_RBPROTO), "XA_RBPROTO");
73          errorcodes.put(new Integer(XAException.XA_RBROLLBACK), "XA_RBROLLBACK");
74          errorcodes.put(new Integer(XAException.XA_RBTIMEOUT), "XA_RBTIMEOUT");
75          errorcodes.put(new Integer(XAException.XA_RBTRANSIENT), "XA_RBTRANSIENT");
76          errorcodes.put(new Integer(XAException.XA_RDONLY), "XA_RDONLY");
77          errorcodes.put(new Integer(XAException.XA_RETRY), "XA_RETRY");
78          errorcodes.put(new Integer(XAException.XAER_ASYNC), "XAER_ASYNC");
79          errorcodes.put(new Integer(XAException.XAER_DUPID), "XAER_DUPID");
80          errorcodes.put(new Integer(XAException.XAER_INVAL), "XAER_INVAL");
81          errorcodes.put(new Integer(XAException.XAER_NOTA), "XAER_NOTA");
82          errorcodes.put(new Integer(XAException.XAER_OUTSIDE), "XAER_OUTSIDE");
83          errorcodes.put(new Integer(XAException.XAER_PROTO), "XAER_PROTO");
84          errorcodes.put(new Integer(XAException.XAER_RMERR), "XAER_RMERR");
85          errorcodes.put(new Integer(XAException.XAER_RMFAIL), "XAER_RMFAIL");
86  
87      }
88  
89      public static String getStatusMessage(XAResourceProgressState status) {
90          return status.toString();
91  
92      }
93  
94      public static String getStatusMessage(XAResourceActivationState status) {
95          return status.toString();
96      }
97  
98      public static String getXAResourceMessage(int flags) {
99          return (String) xaresourceFlags.get(new Integer(flags));
100     }
101 
102 
103     public static String getXAErrorCode(int errorCode) {
104         return (String) errorcodes.get(new Integer(errorCode));
105     }
106 
107 }