001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: * Free SoftwareFoundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028:
029: package com.caucho.sql;
030:
031: import javax.transaction.xa.XAException;
032: import javax.transaction.xa.XAResource;
033: import javax.transaction.xa.Xid;
034:
035: /**
036: * Represents an XA resource which should have isSameRM return false.
037: */
038: public class DisjointXAResource implements XAResource {
039: // The underlying resource
040: private XAResource _xaResource;
041:
042: /**
043: * Creates a new DisjointXAResource
044: */
045: public DisjointXAResource(XAResource resource) {
046: _xaResource = resource;
047: }
048:
049: /**
050: * Returns the underlying resource.
051: */
052: public XAResource getXAResource() {
053: return _xaResource;
054: }
055:
056: /**
057: * Sets the transaction timeout.
058: */
059: public boolean setTransactionTimeout(int seconds)
060: throws XAException {
061: return _xaResource.setTransactionTimeout(seconds);
062: }
063:
064: /**
065: * Gets the transaction timeout.
066: */
067: public int getTransactionTimeout() throws XAException {
068: return _xaResource.getTransactionTimeout();
069: }
070:
071: /**
072: * Returns true if the underlying RM is the same.
073: */
074: public boolean isSameRM(XAResource resource) throws XAException {
075: return false;
076: }
077:
078: /**
079: * Starts the resource.
080: */
081: public void start(Xid xid, int flags) throws XAException {
082: _xaResource.start(xid, flags);
083: }
084:
085: /**
086: * Starts the resource.
087: */
088: public void end(Xid xid, int flags) throws XAException {
089: _xaResource.end(xid, flags);
090: }
091:
092: /**
093: * Rolls the resource back
094: */
095: public int prepare(Xid xid) throws XAException {
096: return _xaResource.prepare(xid);
097: }
098:
099: /**
100: * Commits the resource
101: */
102: public void commit(Xid xid, boolean onePhase) throws XAException {
103: _xaResource.commit(xid, onePhase);
104: }
105:
106: /**
107: * Rolls the resource back
108: */
109: public void rollback(Xid xid) throws XAException {
110: _xaResource.rollback(xid);
111: }
112:
113: /**
114: * Rolls the resource back
115: */
116: public Xid[] recover(int flags) throws XAException {
117: return _xaResource.recover(flags);
118: }
119:
120: /**
121: * Forgets the transaction
122: */
123: public void forget(Xid xid) throws XAException {
124: _xaResource.forget(xid);
125: }
126:
127: public String toString() {
128: return "DisjointXAResource[" + _xaResource.getClass().getName()
129: + "]";
130: }
131: }
|