KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > tools > profiler > XAResourceWrapper


1 /*
2  * Copyright (c) 1998-2005 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 Sam
27  */

28
29
30 package com.caucho.tools.profiler;
31
32 import javax.transaction.xa.XAException JavaDoc;
33 import javax.transaction.xa.XAResource JavaDoc;
34 import javax.transaction.xa.Xid JavaDoc;
35
36 public class XAResourceWrapper
37   implements XAResource JavaDoc
38 {
39   private final ProfilerPoint _profilerPoint;
40   private final XAResource JavaDoc _xaResource;
41
42   public XAResourceWrapper(ProfilerPoint profilerPoint, XAResource JavaDoc xaResource)
43   {
44     _profilerPoint = profilerPoint;
45     _xaResource = xaResource;
46   }
47
48   public void commit(Xid JavaDoc xid, boolean b)
49     throws XAException JavaDoc
50   {
51     Profiler profiler = _profilerPoint.start();
52
53     try {
54       _xaResource.commit(xid, b);
55     }
56     finally {
57       profiler.finish();
58     }
59   }
60
61   public void end(Xid JavaDoc xid, int i)
62     throws XAException JavaDoc
63   {
64     Profiler profiler = _profilerPoint.start();
65
66     try {
67       _xaResource.end(xid, i);
68     }
69     finally {
70       profiler.finish();
71     }
72   }
73
74   public void forget(Xid JavaDoc xid)
75     throws XAException JavaDoc
76   {
77     Profiler profiler = _profilerPoint.start();
78
79     try {
80       _xaResource.forget(xid);
81     }
82     finally {
83       profiler.finish();
84     }
85   }
86
87   public int getTransactionTimeout()
88     throws XAException JavaDoc
89   {
90     Profiler profiler = _profilerPoint.start();
91
92     try {
93       return _xaResource.getTransactionTimeout();
94     }
95     finally {
96       profiler.finish();
97     }
98   }
99
100   public boolean isSameRM(XAResource JavaDoc xaResource)
101     throws XAException JavaDoc
102   {
103     Profiler profiler = _profilerPoint.start();
104
105     try {
106       return _xaResource.isSameRM(xaResource);
107     }
108     finally {
109       profiler.finish();
110     }
111   }
112
113   public int prepare(Xid JavaDoc xid)
114     throws XAException JavaDoc
115   {
116     Profiler profiler = _profilerPoint.start();
117
118     try {
119       return _xaResource.prepare(xid);
120     }
121     finally {
122       profiler.finish();
123     }
124   }
125
126   public Xid JavaDoc[] recover(int i)
127     throws XAException JavaDoc
128   {
129     Profiler profiler = _profilerPoint.start();
130
131     try {
132       return _xaResource.recover(i);
133     }
134     finally {
135       profiler.finish();
136     }
137   }
138
139   public void rollback(Xid JavaDoc xid)
140     throws XAException JavaDoc
141   {
142     Profiler profiler = _profilerPoint.start();
143
144     try {
145       _xaResource.rollback(xid);
146     }
147     finally {
148       profiler.finish();
149     }
150   }
151
152   public boolean setTransactionTimeout(int i)
153     throws XAException JavaDoc
154   {
155     Profiler profiler = _profilerPoint.start();
156
157     try {
158       return _xaResource.setTransactionTimeout(i);
159     }
160     finally {
161       profiler.finish();
162     }
163   }
164
165   public void start(Xid JavaDoc xid, int i)
166     throws XAException JavaDoc
167   {
168     Profiler profiler = _profilerPoint.start();
169
170     try {
171       _xaResource.start(xid, i);
172     }
173     finally {
174       profiler.finish();
175     }
176   }
177
178   public String JavaDoc toString()
179   {
180     return "XAResourceWrapper[" + _profilerPoint.getName() + "]";
181   }
182 }
183
Popular Tags