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 transaction. 030 * 031 * @since 2.0 032 */ 033public interface XAConnectionFactory extends ConnectionFactory { 034 /** 035 * Create a new {@link java.sql.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 java.sql.Connection} 042 * @throws java.sql.SQLException 043 * if a database error occurs creating the connection 044 */ 045 @Override 046 Connection createConnection() throws SQLException; 047 048 /** 049 * Gets the TransactionRegistry for this connection factory which contains a the XAResource for every connection 050 * created by this factory. 051 * 052 * @return the transaction registry for this connection factory 053 */ 054 TransactionRegistry getTransactionRegistry(); 055}