use of org.apache.commons.dbcp2.managed.XAConnectionFactory in project tomee by apache.
the class DbcpManagedDataSource method createConnectionFactory.
@Override
protected ConnectionFactory createConnectionFactory() throws SQLException {
if (ds instanceof XADataSource) {
// Create the XAConectionFactory using the XA data source
final XADataSource xaDataSourceInstance = (XADataSource) ds;
final XAConnectionFactory xaConnectionFactory = new DataSourceXAConnectionFactory(getTransactionManager(), xaDataSourceInstance, getUsername(), getPassword());
setTransactionRegistry(xaConnectionFactory.getTransactionRegistry());
return xaConnectionFactory;
}
// If xa data source is not specified a DriverConnectionFactory is created and wrapped with a LocalXAConnectionFactory
final ConnectionFactory connectionFactory = new DataSourceConnectionFactory(DataSource.class.cast(ds), getUsername(), getPassword());
final XAConnectionFactory xaConnectionFactory = new LocalXAConnectionFactory(getTransactionManager(), connectionFactory);
setTransactionRegistry(xaConnectionFactory.getTransactionRegistry());
return xaConnectionFactory;
}
Aggregations