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