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 | |
import javax.transaction.TransactionManager; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
public class DataSourceWrapper implements DataSource |
25 | |
{ |
26 | |
|
27 | |
private XADataSource xaDataSource; |
28 | |
|
29 | |
public DataSourceWrapper() |
30 | |
{ |
31 | 0 | super(); |
32 | 0 | } |
33 | |
|
34 | |
public DataSourceWrapper(XADataSource xaDataSource, TransactionManager tm) |
35 | 0 | { |
36 | 0 | this.xaDataSource = xaDataSource; |
37 | 0 | } |
38 | |
|
39 | |
public int getLoginTimeout() throws SQLException |
40 | |
{ |
41 | 0 | return xaDataSource.getLoginTimeout(); |
42 | |
} |
43 | |
|
44 | |
public void setLoginTimeout(int seconds) throws SQLException |
45 | |
{ |
46 | 0 | xaDataSource.setLoginTimeout(seconds); |
47 | 0 | } |
48 | |
|
49 | |
public PrintWriter getLogWriter() throws SQLException |
50 | |
{ |
51 | 0 | return xaDataSource.getLogWriter(); |
52 | |
} |
53 | |
|
54 | |
public void setLogWriter(PrintWriter out) throws SQLException |
55 | |
{ |
56 | 0 | xaDataSource.setLogWriter(out); |
57 | 0 | } |
58 | |
|
59 | |
public Connection getConnection() throws SQLException |
60 | |
{ |
61 | 0 | return new ConnectionWrapper(xaDataSource.getXAConnection()); |
62 | |
} |
63 | |
|
64 | |
public Connection getConnection(String username, String password) throws SQLException |
65 | |
{ |
66 | 0 | return new ConnectionWrapper(xaDataSource.getXAConnection(username, password)); |
67 | |
} |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
public XADataSource getXaDataSource() |
73 | |
{ |
74 | 0 | return xaDataSource; |
75 | |
} |
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
public void setXaDataSource(XADataSource xads) |
81 | |
{ |
82 | 0 | this.xaDataSource = xads; |
83 | 0 | } |
84 | |
|
85 | |
} |