1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
package org.mule.transport.jms.xa; |
11 | |
|
12 | |
import javax.transaction.xa.XAException; |
13 | |
import javax.transaction.xa.XAResource; |
14 | |
import javax.transaction.xa.Xid; |
15 | |
|
16 | |
public class XAResourceWrapper implements XAResource |
17 | |
{ |
18 | |
|
19 | |
private XAResource xaResource; |
20 | |
private SessionInvocationHandler sessionInvocationHandler; |
21 | |
private Boolean sameRMOverrideValue; |
22 | |
|
23 | |
|
24 | |
public XAResourceWrapper(XAResource xaResource, SessionInvocationHandler sessionInvocationHandler, Boolean sameRMOverrideValue) |
25 | 0 | { |
26 | 0 | this.xaResource = xaResource; |
27 | 0 | this.sessionInvocationHandler = sessionInvocationHandler; |
28 | 0 | this.sameRMOverrideValue = sameRMOverrideValue; |
29 | 0 | } |
30 | |
|
31 | |
public int getTransactionTimeout() throws XAException |
32 | |
{ |
33 | 0 | return xaResource.getTransactionTimeout(); |
34 | |
} |
35 | |
|
36 | |
public boolean setTransactionTimeout(int i) throws XAException |
37 | |
{ |
38 | 0 | return xaResource.setTransactionTimeout(i); |
39 | |
} |
40 | |
|
41 | |
public boolean isSameRM(XAResource other) throws XAException |
42 | |
{ |
43 | 0 | if (sameRMOverrideValue != null) |
44 | |
{ |
45 | 0 | return sameRMOverrideValue; |
46 | |
} |
47 | |
|
48 | 0 | if (other instanceof XAResourceWrapper) |
49 | |
{ |
50 | 0 | other = ((XAResourceWrapper) other).xaResource; |
51 | |
} |
52 | 0 | final boolean isSame = this.xaResource.isSameRM(other); |
53 | |
|
54 | 0 | System.out.println("\n\n\nisSame = " + isSame); |
55 | |
|
56 | 0 | return isSame; |
57 | |
} |
58 | |
|
59 | |
public Xid[] recover(int i) throws XAException |
60 | |
{ |
61 | 0 | return xaResource.recover(i); |
62 | |
} |
63 | |
|
64 | |
public int prepare(Xid xid) throws XAException |
65 | |
{ |
66 | 0 | return xaResource.prepare(xid); |
67 | |
} |
68 | |
|
69 | |
public void forget(Xid xid) throws XAException |
70 | |
{ |
71 | 0 | xaResource.forget(xid); |
72 | 0 | } |
73 | |
|
74 | |
public void rollback(Xid xid) throws XAException |
75 | |
{ |
76 | 0 | xaResource.rollback(xid); |
77 | 0 | } |
78 | |
|
79 | |
public void end(Xid xid, int i) throws XAException |
80 | |
{ |
81 | 0 | xaResource.end(xid, i); |
82 | 0 | sessionInvocationHandler.setEnlisted(false); |
83 | 0 | } |
84 | |
|
85 | |
public void start(Xid xid, int i) throws XAException |
86 | |
{ |
87 | 0 | xaResource.start(xid, i); |
88 | 0 | } |
89 | |
|
90 | |
public void commit(Xid xid, boolean b) throws XAException |
91 | |
{ |
92 | 0 | xaResource.commit(xid, b); |
93 | 0 | } |
94 | |
|
95 | |
public String toString() |
96 | |
{ |
97 | 0 | return xaResource.toString(); |
98 | |
} |
99 | |
} |