001: /*
002: * Copyright (c) 1998-2005 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 Sam
027: */
028:
029: package com.caucho.tools.profiler;
030:
031: import javax.transaction.xa.XAException;
032: import javax.transaction.xa.XAResource;
033: import javax.transaction.xa.Xid;
034:
035: public class XAResourceWrapper implements XAResource {
036: private final ProfilerPoint _profilerPoint;
037: private final XAResource _xaResource;
038:
039: public XAResourceWrapper(ProfilerPoint profilerPoint,
040: XAResource xaResource) {
041: _profilerPoint = profilerPoint;
042: _xaResource = xaResource;
043: }
044:
045: public void commit(Xid xid, boolean b) throws XAException {
046: Profiler profiler = _profilerPoint.start();
047:
048: try {
049: _xaResource.commit(xid, b);
050: } finally {
051: profiler.finish();
052: }
053: }
054:
055: public void end(Xid xid, int i) throws XAException {
056: Profiler profiler = _profilerPoint.start();
057:
058: try {
059: _xaResource.end(xid, i);
060: } finally {
061: profiler.finish();
062: }
063: }
064:
065: public void forget(Xid xid) throws XAException {
066: Profiler profiler = _profilerPoint.start();
067:
068: try {
069: _xaResource.forget(xid);
070: } finally {
071: profiler.finish();
072: }
073: }
074:
075: public int getTransactionTimeout() throws XAException {
076: Profiler profiler = _profilerPoint.start();
077:
078: try {
079: return _xaResource.getTransactionTimeout();
080: } finally {
081: profiler.finish();
082: }
083: }
084:
085: public boolean isSameRM(XAResource xaResource) throws XAException {
086: Profiler profiler = _profilerPoint.start();
087:
088: try {
089: return _xaResource.isSameRM(xaResource);
090: } finally {
091: profiler.finish();
092: }
093: }
094:
095: public int prepare(Xid xid) throws XAException {
096: Profiler profiler = _profilerPoint.start();
097:
098: try {
099: return _xaResource.prepare(xid);
100: } finally {
101: profiler.finish();
102: }
103: }
104:
105: public Xid[] recover(int i) throws XAException {
106: Profiler profiler = _profilerPoint.start();
107:
108: try {
109: return _xaResource.recover(i);
110: } finally {
111: profiler.finish();
112: }
113: }
114:
115: public void rollback(Xid xid) throws XAException {
116: Profiler profiler = _profilerPoint.start();
117:
118: try {
119: _xaResource.rollback(xid);
120: } finally {
121: profiler.finish();
122: }
123: }
124:
125: public boolean setTransactionTimeout(int i) throws XAException {
126: Profiler profiler = _profilerPoint.start();
127:
128: try {
129: return _xaResource.setTransactionTimeout(i);
130: } finally {
131: profiler.finish();
132: }
133: }
134:
135: public void start(Xid xid, int i) throws XAException {
136: Profiler profiler = _profilerPoint.start();
137:
138: try {
139: _xaResource.start(xid, i);
140: } finally {
141: profiler.finish();
142: }
143: }
144:
145: public String toString() {
146: return "XAResourceWrapper[" + _profilerPoint.getName() + "]";
147: }
148: }
|