1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.commons.dbcp2.managed;
18
19 import java.sql.Connection;
20 import java.sql.SQLException;
21
22 import org.apache.commons.dbcp2.ConnectionFactory;
23
24 /**
25 * XAConnectionFactory is an extension of ConnectionFactory used to create connections in a transaction managed
26 * environment. The XAConnectionFactory operates like a normal ConnectionFactory except a TransactionRegistry is
27 * provided from which the XAResource for a connection can be obtained. This allows the existing DBCP pool code to work
28 * with XAConnections and gives the ManagedConnection a way to enlist a connection in the transaction.
29 *
30 * @since 2.0
31 */
32 public interface XAConnectionFactory extends ConnectionFactory {
33
34 /**
35 * Creates a new {@link Connection} in an implementation specific fashion.
36 * <p>
37 * An implementation can assume that the caller of this will wrap the connection in a proxy that protects access to
38 * the setAutoCommit, commit and rollback when enrolled in a XA transaction.
39 * </p>
40 *
41 * @return a new {@link Connection}
42 * @throws SQLException if a database error occurs creating the connection
43 */
44 @Override
45 Connection createConnection() throws SQLException;
46
47 /**
48 * Gets the TransactionRegistry for this connection factory which contains the XAResource for every connection
49 * created by this factory.
50 *
51 * @return the transaction registry for this connection factory
52 */
53 TransactionRegistry getTransactionRegistry();
54 }