KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > jdbc > xa > DataSourceWrapper


1 /*
2  * $Id: DataSourceWrapper.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.providers.jdbc.xa;
12
13 import javax.sql.DataSource JavaDoc;
14 import javax.sql.XADataSource JavaDoc;
15 import javax.transaction.TransactionManager JavaDoc;
16
17 import java.io.PrintWriter JavaDoc;
18 import java.sql.Connection JavaDoc;
19 import java.sql.SQLException JavaDoc;
20
21 /**
22  * TODO
23  */

24 public class DataSourceWrapper implements DataSource JavaDoc
25 {
26
27     private XADataSource JavaDoc xads;
28     private TransactionManager JavaDoc tm;
29
30     public DataSourceWrapper()
31     {
32         super();
33     }
34
35     public DataSourceWrapper(XADataSource JavaDoc xads, TransactionManager JavaDoc tm)
36     {
37         this.xads = xads;
38         this.tm = tm;
39     }
40
41     /*
42      * (non-Javadoc)
43      *
44      * @see javax.sql.DataSource#getLoginTimeout()
45      */

46     public int getLoginTimeout() throws SQLException JavaDoc
47     {
48         return xads.getLoginTimeout();
49     }
50
51     /*
52      * (non-Javadoc)
53      *
54      * @see javax.sql.DataSource#setLoginTimeout(int)
55      */

56     public void setLoginTimeout(int seconds) throws SQLException JavaDoc
57     {
58         xads.setLoginTimeout(seconds);
59     }
60
61     /*
62      * (non-Javadoc)
63      *
64      * @see javax.sql.DataSource#getLogWriter()
65      */

66     public PrintWriter JavaDoc getLogWriter() throws SQLException JavaDoc
67     {
68         return xads.getLogWriter();
69     }
70
71     /*
72      * (non-Javadoc)
73      *
74      * @see javax.sql.DataSource#setLogWriter(java.io.PrintWriter)
75      */

76     public void setLogWriter(PrintWriter JavaDoc out) throws SQLException JavaDoc
77     {
78         xads.setLogWriter(out);
79     }
80
81     /*
82      * (non-Javadoc)
83      *
84      * @see javax.sql.DataSource#getConnection()
85      */

86     public Connection JavaDoc getConnection() throws SQLException JavaDoc
87     {
88         return new ConnectionWrapper(xads.getXAConnection(), tm);
89     }
90
91     /*
92      * (non-Javadoc)
93      *
94      * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String)
95      */

96     public Connection JavaDoc getConnection(String JavaDoc username, String JavaDoc password) throws SQLException JavaDoc
97     {
98         return new ConnectionWrapper(xads.getXAConnection(username, password), tm);
99     }
100
101     /**
102      * @return Returns the transaction manager.
103      */

104     public TransactionManager JavaDoc getTransactionManager()
105     {
106         return tm;
107     }
108
109     /**
110      * @param tm The transaction manager to set.
111      */

112     public void setTransactionManager(TransactionManager JavaDoc tm)
113     {
114         this.tm = tm;
115     }
116
117     /**
118      * @return Returns the underlying XADataSource.
119      */

120     public XADataSource JavaDoc getXaDataSource()
121     {
122         return xads;
123     }
124
125     /**
126      * @param xads The XADataSource to set.
127      */

128     public void setXaDataSource(XADataSource JavaDoc xads)
129     {
130         this.xads = xads;
131     }
132 }
133
Popular Tags