View Javadoc

1   /*
2    * $Id: XAResourceWrapper.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
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      {
26          this.xaResource = xaResource;
27          this.sessionInvocationHandler = sessionInvocationHandler;
28          this.sameRMOverrideValue = sameRMOverrideValue;
29      }
30  
31      public int getTransactionTimeout() throws XAException
32      {
33          return xaResource.getTransactionTimeout();
34      }
35  
36      public boolean setTransactionTimeout(int i) throws XAException
37      {
38          return xaResource.setTransactionTimeout(i);
39      }
40  
41      public boolean isSameRM(XAResource other) throws XAException
42      {
43          if (sameRMOverrideValue != null)
44          {
45              return sameRMOverrideValue;
46          }
47  
48          if (other instanceof XAResourceWrapper)
49          {
50              other = ((XAResourceWrapper) other).xaResource;
51          }
52          final boolean isSame = this.xaResource.isSameRM(other);
53  
54          System.out.println("\n\n\nisSame = " + isSame);
55  
56          return isSame;
57      }
58  
59      public Xid[] recover(int i) throws XAException
60      {
61          return xaResource.recover(i);
62      }
63  
64      public int prepare(Xid xid) throws XAException
65      {
66          return xaResource.prepare(xid);
67      }
68  
69      public void forget(Xid xid) throws XAException
70      {
71          xaResource.forget(xid);
72      }
73  
74      public void rollback(Xid xid) throws XAException
75      {
76          xaResource.rollback(xid);
77      }
78  
79      public void end(Xid xid, int i) throws XAException
80      {
81          xaResource.end(xid, i);
82          sessionInvocationHandler.setEnlisted(false);
83      }
84  
85      public void start(Xid xid, int i) throws XAException
86      {
87          xaResource.start(xid, i);
88      }
89  
90      public void commit(Xid xid, boolean b) throws XAException
91      {
92          xaResource.commit(xid, b);
93      }
94  
95      public String toString()
96      {
97          return xaResource.toString();
98      }
99  }