Coverage Report - org.mule.providers.jdbc.xa.DataSourceWrapper
 
Classes in this File Line Coverage Branch Coverage Complexity
DataSourceWrapper
0%
0/24
N/A
1
 
 1  
 /*
 2  
  * $Id: DataSourceWrapper.java 7976 2007-08-21 14:26:13Z dirk.olmes $
 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 CPAL v1.0
 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 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  
  * TODO
 23  
  */
 24  
 public class DataSourceWrapper implements DataSource
 25  
 {
 26  
 
 27  
     private XADataSource xads;
 28  
     private TransactionManager tm;
 29  
 
 30  
     public DataSourceWrapper()
 31  
     {
 32  0
         super();
 33  0
     }
 34  
 
 35  
     public DataSourceWrapper(XADataSource xads, TransactionManager tm)
 36  0
     {
 37  0
         this.xads = xads;
 38  0
         this.tm = tm;
 39  0
     }
 40  
 
 41  
     /*
 42  
      * (non-Javadoc)
 43  
      * 
 44  
      * @see javax.sql.DataSource#getLoginTimeout()
 45  
      */
 46  
     public int getLoginTimeout() throws SQLException
 47  
     {
 48  0
         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
 57  
     {
 58  0
         xads.setLoginTimeout(seconds);
 59  0
     }
 60  
 
 61  
     /*
 62  
      * (non-Javadoc)
 63  
      * 
 64  
      * @see javax.sql.DataSource#getLogWriter()
 65  
      */
 66  
     public PrintWriter getLogWriter() throws SQLException
 67  
     {
 68  0
         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 out) throws SQLException
 77  
     {
 78  0
         xads.setLogWriter(out);
 79  0
     }
 80  
 
 81  
     /*
 82  
      * (non-Javadoc)
 83  
      * 
 84  
      * @see javax.sql.DataSource#getConnection()
 85  
      */
 86  
     public Connection getConnection() throws SQLException
 87  
     {
 88  0
         final ConnectionWrapper connWrapper = new ConnectionWrapper(xads.getXAConnection(), tm);
 89  0
         connWrapper.setAutoCommit(false);
 90  0
         return connWrapper;
 91  
     }
 92  
 
 93  
     /*
 94  
      * (non-Javadoc)
 95  
      * 
 96  
      * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String)
 97  
      */
 98  
     public Connection getConnection(String username, String password) throws SQLException
 99  
     {
 100  0
         final ConnectionWrapper connWrapper = new ConnectionWrapper(xads.getXAConnection(username, password), tm);
 101  0
         connWrapper.setAutoCommit(false);
 102  0
         return connWrapper;
 103  
     }
 104  
 
 105  
     /**
 106  
      * @return Returns the transaction manager.
 107  
      */
 108  
     public TransactionManager getTransactionManager()
 109  
     {
 110  0
         return tm;
 111  
     }
 112  
 
 113  
     /**
 114  
      * @param tm The transaction manager to set.
 115  
      */
 116  
     public void setTransactionManager(TransactionManager tm)
 117  
     {
 118  0
         this.tm = tm;
 119  0
     }
 120  
 
 121  
     /**
 122  
      * @return Returns the underlying XADataSource.
 123  
      */
 124  
     public XADataSource getXaDataSource()
 125  
     {
 126  0
         return xads;
 127  
     }
 128  
 
 129  
     /**
 130  
      * @param xads The XADataSource to set.
 131  
      */
 132  
     public void setXaDataSource(XADataSource xads)
 133  
     {
 134  0
         this.xads = xads;
 135  0
     }
 136  
 }