001/**
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one or more
004 * contributor license agreements.  See the NOTICE file distributed with
005 * this work for additional information regarding copyright ownership.
006 * The ASF licenses this file to You under the Apache License, Version 2.0
007 * (the "License"); you may not use this file except in compliance with
008 * the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *  Unless required by applicable law or agreed to in writing, software
013 *  distributed under the License is distributed on an "AS IS" BASIS,
014 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 *  See the License for the specific language governing permissions and
016 *  limitations under the License.
017 */
018package org.apache.commons.dbcp2.managed;
019
020import java.sql.Connection;
021import java.sql.SQLException;
022
023import org.apache.commons.dbcp2.ConnectionFactory;
024
025/**
026 * XAConnectionFactory is an extension of ConnectionFactory used to create connections
027 * in a transaction managed environment.  The XAConnectionFactory operates like a normal
028 * ConnectionFactory except an TransactionRegistry is provided from which the XAResource
029 * for a connection can be obtained.  This allows the existing DBCP pool code to work with
030 * XAConnections and gives a the ManagedConnection a way to enlist a connection in the
031 * the transaction.
032 *
033 * @author Dain Sundstrom
034 * @author Rodney Waldhoff
035 * @version $Id: XAConnectionFactory.java 1660791 2015-02-19 04:13:10Z psteitz $
036 * @since 2.0
037 */
038public interface XAConnectionFactory extends ConnectionFactory {
039    /**
040     * Gets the TransactionRegistry for this connection factory which contains a the
041     * XAResource for every connection created by this factory.
042     *
043     * @return the transaction registry for this connection factory
044     */
045    TransactionRegistry getTransactionRegistry();
046
047    /**
048     * Create a new {@link java.sql.Connection} in an implementation specific fashion.
049     * <p>
050     * An implementation can assume that the caller of this will wrap the connection in
051     * a proxy that protects access to the setAutoCommit, commit and rollback when
052     * enrolled in a XA transaction.
053     * </p>
054     *
055     * @return a new {@link java.sql.Connection}
056     * @throws java.sql.SQLException if a database error occurs creating the connection
057     */
058    @Override
059    Connection createConnection() throws SQLException;
060}