    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 in a transaction managed
    027 * environment. The XAConnectionFactory operates like a normal ConnectionFactory except a TransactionRegistry is
    028 * provided from which the XAResource for a connection can be obtained. This allows the existing DBCP pool code to work
    029 * with XAConnections and gives a the ManagedConnection a way to enlist a connection in the the transaction.
    030 *
    031 * @since 2.0
    032 */
    033public interface XAConnectionFactory extends ConnectionFactory {
    034    /**
    035     * Gets the TransactionRegistry for this connection factory which contains a the XAResource for every connection
    036     * created by this factory.
    037     *
    038     * @return the transaction registry for this connection factory
    039     */
    040    TransactionRegistry getTransactionRegistry();
    041
    042    /**
    043     * Create a new {@link java.sql.Connection} in an implementation specific fashion.
    044     * <p>
    045     * An implementation can assume that the caller of this will wrap the connection in a proxy that protects access to
    046     * the setAutoCommit, commit and rollback when enrolled in a XA transaction.
    047     * </p>
    048     *
    049     * @return a new {@link java.sql.Connection}
    050     * @throws java.sql.SQLException
    051     *             if a database error occurs creating the connection
    052     */
    053    @Override
    054    Connection createConnection() throws SQLException;
    055}