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