View Javadoc

1   /*
2    * $Id: XAResourceWrapper.java 10590 2008-01-29 01:39:47Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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  /**
17   * Arjuna can't serialize proxy
18   */
19  public class XAResourceWrapper implements XAResource
20  {
21  
22      private XAResource xaResource;
23      private SessionInvocationHandler sessionInvocationHandler;
24  
25      public XAResourceWrapper(XAResource xaResource, SessionInvocationHandler sessionInvocationHandler)
26      {
27          this.xaResource = xaResource;
28          this.sessionInvocationHandler = sessionInvocationHandler;
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 xaResource) throws XAException
42      {
43          if (xaResource instanceof XAResourceWrapper)
44          {
45              xaResource = ((XAResourceWrapper) xaResource).xaResource;
46          }
47          return this.xaResource.isSameRM(xaResource);
48      }
49  
50      public Xid[] recover(int i) throws XAException
51      {
52          return xaResource.recover(i);
53      }
54  
55      public int prepare(Xid xid) throws XAException
56      {
57          return xaResource.prepare(xid);
58      }
59  
60      public void forget(Xid xid) throws XAException
61      {
62          xaResource.forget(xid);
63      }
64  
65      public void rollback(Xid xid) throws XAException
66      {
67          xaResource.rollback(xid);
68      }
69  
70      public void end(Xid xid, int i) throws XAException
71      {
72          xaResource.end(xid, i);
73          sessionInvocationHandler.setEnlisted(false);
74      }
75  
76      public void start(Xid xid, int i) throws XAException
77      {
78          xaResource.start(xid, i);
79      }
80  
81      public void commit(Xid xid, boolean b) throws XAException
82      {
83          xaResource.commit(xid, b);
84      }
85  
86      public String toString()
87      {
88          return xaResource.toString();
89      }
90  }