1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.jdbc.xa;
12
13 import java.io.PrintWriter;
14 import java.sql.Connection;
15 import java.sql.SQLException;
16
17 import javax.sql.DataSource;
18 import javax.sql.XADataSource;
19
20
21
22
23 public class DataSourceWrapper implements DataSource
24 {
25
26 private XADataSource xaDataSource;
27
28 public DataSourceWrapper()
29 {
30 super();
31 }
32
33 public DataSourceWrapper(XADataSource xaDataSource)
34 {
35 this.xaDataSource = xaDataSource;
36 }
37
38 @Override
39 public int getLoginTimeout() throws SQLException
40 {
41 return xaDataSource.getLoginTimeout();
42 }
43
44 @Override
45 public void setLoginTimeout(int seconds) throws SQLException
46 {
47 xaDataSource.setLoginTimeout(seconds);
48 }
49
50 @Override
51 public PrintWriter getLogWriter() throws SQLException
52 {
53 return xaDataSource.getLogWriter();
54 }
55
56 @Override
57 public void setLogWriter(PrintWriter out) throws SQLException
58 {
59 xaDataSource.setLogWriter(out);
60 }
61
62 @Override
63 public Connection getConnection() throws SQLException
64 {
65 return new ConnectionWrapper(xaDataSource.getXAConnection());
66 }
67
68 @Override
69 public Connection getConnection(String username, String password) throws SQLException
70 {
71 return new ConnectionWrapper(xaDataSource.getXAConnection(username, password));
72 }
73
74
75
76
77 public XADataSource getXaDataSource()
78 {
79 return xaDataSource;
80 }
81
82
83
84
85 public void setXaDataSource(XADataSource xads)
86 {
87 this.xaDataSource = xads;
88 }
89
90 @Override
91 public boolean isWrapperFor(Class<?> iface) throws SQLException
92 {
93 return false;
94 }
95
96 @Override
97 public <T> T unwrap(Class<T> iface) throws SQLException
98 {
99 return null;
100 }
101
102 }