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     */
018    package org.apache.commons.dbcp.managed;
019    
020    import org.apache.commons.dbcp.ConnectionFactory;
021    
022    import java.sql.Connection;
023    import java.sql.SQLException;
024    
025    /**
026     * XAConnectionFactory is an extension of ConnectionFactory used to create connections
027     * in a transaction managed environment.  The XAConnectionFactory opperates 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 $Revision: 892307 $
036     */
037    public interface XAConnectionFactory extends ConnectionFactory {
038        /**
039         * Gets the TransactionRegistry for this connection factory which contains a the
040         * XAResource for every connection created by this factory.
041         *
042         * @return the transaction registry for this connection factory
043         */
044        TransactionRegistry getTransactionRegistry();
045    
046        /**
047         * Create a new {@link java.sql.Connection} in an implementation specific fashion.
048         * </p>
049         * An implementation can assume that the caller of this will wrap the connection in
050         * a proxy that protects access to the setAutoCommit, commit and rollback when
051         * enrolled in a XA transaction.
052         *
053         * @return a new {@link java.sql.Connection}
054         * @throws java.sql.SQLException if a database error occurs creating the connection
055         */
056        Connection createConnection() throws SQLException;
057    }