KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > sql > DisjointXAResource


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.sql;
30
31 import javax.transaction.xa.XAException JavaDoc;
32 import javax.transaction.xa.XAResource JavaDoc;
33 import javax.transaction.xa.Xid JavaDoc;
34
35 /**
36  * Represents an XA resource which should have isSameRM return false.
37  */

38 public class DisjointXAResource implements XAResource JavaDoc {
39   // The underlying resource
40
private XAResource JavaDoc _xaResource;
41
42   /**
43    * Creates a new DisjointXAResource
44    */

45   public DisjointXAResource(XAResource JavaDoc resource)
46   {
47     _xaResource = resource;
48   }
49
50   /**
51    * Returns the underlying resource.
52    */

53   public XAResource JavaDoc getXAResource()
54   {
55     return _xaResource;
56   }
57
58   /**
59    * Sets the transaction timeout.
60    */

61   public boolean setTransactionTimeout(int seconds)
62     throws XAException JavaDoc
63   {
64     return _xaResource.setTransactionTimeout(seconds);
65   }
66
67   /**
68    * Gets the transaction timeout.
69    */

70   public int getTransactionTimeout()
71     throws XAException JavaDoc
72   {
73     return _xaResource.getTransactionTimeout();
74   }
75
76   /**
77    * Returns true if the underlying RM is the same.
78    */

79   public boolean isSameRM(XAResource JavaDoc resource)
80     throws XAException JavaDoc
81   {
82     return false;
83   }
84
85   /**
86    * Starts the resource.
87    */

88   public void start(Xid JavaDoc xid, int flags)
89     throws XAException JavaDoc
90   {
91     _xaResource.start(xid, flags);
92   }
93
94   /**
95    * Starts the resource.
96    */

97   public void end(Xid JavaDoc xid, int flags)
98     throws XAException JavaDoc
99   {
100     _xaResource.end(xid, flags);
101   }
102
103   /**
104    * Rolls the resource back
105    */

106   public int prepare(Xid JavaDoc xid)
107     throws XAException JavaDoc
108   {
109     return _xaResource.prepare(xid);
110   }
111
112   /**
113    * Commits the resource
114    */

115   public void commit(Xid JavaDoc xid, boolean onePhase)
116     throws XAException JavaDoc
117   {
118     _xaResource.commit(xid, onePhase);
119   }
120
121   /**
122    * Rolls the resource back
123    */

124   public void rollback(Xid JavaDoc xid)
125     throws XAException JavaDoc
126   {
127     _xaResource.rollback(xid);
128   }
129
130   /**
131    * Rolls the resource back
132    */

133   public Xid JavaDoc []recover(int flags)
134     throws XAException JavaDoc
135   {
136     return _xaResource.recover(flags);
137   }
138
139   /**
140    * Forgets the transaction
141    */

142   public void forget(Xid JavaDoc xid)
143     throws XAException JavaDoc
144   {
145     _xaResource.forget(xid);
146   }
147
148   public String JavaDoc toString()
149   {
150     return "DisjointXAResource[" + _xaResource.getClass().getName() + "]";
151   }
152 }
153
Popular Tags