001/*
002 * HA-JDBC: High-Availability JDBC
003 * Copyright (c) 2004-2008 Paul Ferraro
004 * 
005 * This library is free software; you can redistribute it and/or modify it 
006 * under the terms of the GNU Lesser General Public License as published by the 
007 * Free Software Foundation; either version 2.1 of the License, or (at your 
008 * option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful, but WITHOUT
011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 
013 * for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public License
016 * along with this library; if not, write to the Free Software Foundation, 
017 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018 * 
019 * Contact: ferraro@users.sourceforge.net
020 */
021package net.sf.hajdbc.sql.xa;
022
023import java.io.PrintWriter;
024import java.sql.SQLException;
025import java.sql.SQLFeatureNotSupportedException;
026import java.util.logging.Logger;
027
028import javax.naming.NamingException;
029import javax.naming.Reference;
030import javax.sql.XAConnection;
031
032import net.sf.hajdbc.sql.CommonDataSourceProxy;
033
034/**
035 * @author Paul Ferraro
036 */
037public class XADataSource extends CommonDataSourceProxy<javax.sql.XADataSource> implements javax.sql.XADataSource
038{
039        /**
040         * Constructs a new XADataSource
041         */
042        public XADataSource()
043        {
044                super(new XADataSourceFactory());
045        }
046
047        /**
048         * @see javax.sql.XADataSource#getXAConnection()
049         */
050        @Override
051        public XAConnection getXAConnection() throws SQLException
052        {
053                return this.getProxy().getXAConnection();
054        }
055
056        /**
057         * @see javax.sql.XADataSource#getXAConnection(java.lang.String, java.lang.String)
058         */
059        @Override
060        public XAConnection getXAConnection(String user, String password) throws SQLException
061        {
062                return this.getProxy().getXAConnection(user, password);
063        }
064
065        /**
066         * @see javax.sql.CommonDataSource#getLoginTimeout()
067         */
068        @Override
069        public int getLoginTimeout() throws SQLException
070        {
071                return this.getProxy().getLoginTimeout();
072        }
073
074        /**
075         * @see javax.sql.CommonDataSource#getLogWriter()
076         */
077        @Override
078        public PrintWriter getLogWriter() throws SQLException
079        {
080                return this.getProxy().getLogWriter();
081        }
082
083        /**
084         * @see javax.sql.CommonDataSource#setLoginTimeout(int)
085         */
086        @Override
087        public void setLoginTimeout(int timeout) throws SQLException
088        {
089                this.getProxy().setLoginTimeout(timeout);
090        }
091
092        /**
093         * @see javax.sql.CommonDataSource#setLogWriter(java.io.PrintWriter)
094         */
095        @Override
096        public void setLogWriter(PrintWriter writer) throws SQLException
097        {
098                this.getProxy().setLogWriter(writer);
099        }
100
101        /**
102         * @see javax.naming.Referenceable#getReference()
103         */
104        @Override
105        public Reference getReference() throws NamingException
106        {
107                return new XADataSourceReference(this.getCluster(), this.getConfig());
108        }
109
110        public Logger getParentLogger() throws SQLFeatureNotSupportedException {
111            throw new SQLFeatureNotSupportedException();
112        }
113
114}