Coverage Report - org.mule.providers.jdbc.xa.DataSourceWrapper
 
Classes in this File Line Coverage Branch Coverage Complexity
DataSourceWrapper
0%
0/20
N/A
1
 
 1  
 /*
 2  
  * $Id: DataSourceWrapper.java 8583 2007-09-25 17:00:14Z akuzmin $
 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  
  * Using for unification XADataSource and DataSource
 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  
     /*
 40  
      * (non-Javadoc)
 41  
      * 
 42  
      * @see javax.sql.DataSource#getLoginTimeout()
 43  
      */
 44  
     public int getLoginTimeout() throws SQLException
 45  
     {
 46  0
         return xaDataSource.getLoginTimeout();
 47  
     }
 48  
 
 49  
     /*
 50  
      * (non-Javadoc)
 51  
      * 
 52  
      * @see javax.sql.DataSource#setLoginTimeout(int)
 53  
      */
 54  
     public void setLoginTimeout(int seconds) throws SQLException
 55  
     {
 56  0
         xaDataSource.setLoginTimeout(seconds);
 57  0
     }
 58  
 
 59  
     /*
 60  
      * (non-Javadoc)
 61  
      * 
 62  
      * @see javax.sql.DataSource#getLogWriter()
 63  
      */
 64  
     public PrintWriter getLogWriter() throws SQLException
 65  
     {
 66  0
         return xaDataSource.getLogWriter();
 67  
     }
 68  
 
 69  
     /*
 70  
      * (non-Javadoc)
 71  
      * 
 72  
      * @see javax.sql.DataSource#setLogWriter(java.io.PrintWriter)
 73  
      */
 74  
     public void setLogWriter(PrintWriter out) throws SQLException
 75  
     {
 76  0
         xaDataSource.setLogWriter(out);
 77  0
     }
 78  
 
 79  
     /*
 80  
      * (non-Javadoc)
 81  
      * 
 82  
      * @see javax.sql.DataSource#getConnection()
 83  
      */
 84  
     public Connection getConnection() throws SQLException
 85  
     {
 86  0
         final Connection connWrapper = new ConnectionWrapper(xaDataSource.getXAConnection());
 87  0
         connWrapper.setAutoCommit(false);
 88  0
         return connWrapper;
 89  
     }
 90  
 
 91  
     /*
 92  
      * (non-Javadoc)
 93  
      * 
 94  
      * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String)
 95  
      */
 96  
     public Connection getConnection(String username, String password) throws SQLException
 97  
     {
 98  0
         final Connection connWrapper = new ConnectionWrapper(xaDataSource.getXAConnection(username, password));
 99  0
         connWrapper.setAutoCommit(false);
 100  0
         return connWrapper;
 101  
     }
 102  
 
 103  
     /**
 104  
      * @return Returns the underlying XADataSource.
 105  
      */
 106  
     public XADataSource getXaDataSource()
 107  
     {
 108  0
         return xaDataSource;
 109  
     }
 110  
 
 111  
     /**
 112  
      * @param xads The XADataSource to set.
 113  
      */
 114  
     public void setXaDataSource(XADataSource xads)
 115  
     {
 116  0
         this.xaDataSource = xads;
 117  0
     }
 118  
 }