1 28 29 30 package com.caucho.tools.profiler; 31 32 import javax.sql.ConnectionEventListener ; 33 import javax.sql.XAConnection ; 34 import javax.transaction.xa.XAResource ; 35 import java.sql.Connection ; 36 import java.sql.SQLException ; 37 38 public final class XAConnectionWrapper 39 implements XAConnection 40 { 41 private final XAConnection _connection; 42 private final ProfilerPoint _profilerPoint; 43 44 private XAResource _xaResource; 45 46 public XAConnectionWrapper(ProfilerPoint profilerPoint, 47 XAConnection connection) 48 { 49 _profilerPoint = profilerPoint; 50 _connection = connection; 51 } 52 53 private ConnectionWrapper wrap(Connection connection) 54 { 55 return new ConnectionWrapper(_profilerPoint, connection); 56 } 57 58 private XAResourceWrapper wrap(XAResource xaResource) 59 { 60 return new XAResourceWrapper(_profilerPoint, xaResource); 61 } 62 63 public XAResource getXAResource() 64 throws SQLException 65 { 66 return wrap(_connection.getXAResource()); 67 } 68 69 public Connection getConnection() 70 throws SQLException 71 { 72 return wrap(_connection.getConnection()); 73 } 74 75 public void close() 76 throws SQLException 77 { 78 _connection.close(); 79 } 80 81 public void addConnectionEventListener(ConnectionEventListener listener) 82 { 83 _connection.addConnectionEventListener(listener); 84 } 85 86 public void removeConnectionEventListener(ConnectionEventListener listener) 87 { 88 _connection.removeConnectionEventListener(listener); 89 } 90 91 public String toString() 92 { 93 return "XAConnectionWrapper[" + _profilerPoint.getName() + "]"; 94 } 95 } 96 | Popular Tags |