use of javax.sql.XADataSource in project aries by apache.
the class JDBCConnectionProviderFactoryImpl method getProviderFor.
@Override
public AbstractJDBCConnectionProvider getProviderFor(XADataSource ds, Map<String, Object> resourceProviderProperties) {
boolean xaEnabled = toBoolean(resourceProviderProperties, XA_ENLISTMENT_ENABLED, true);
boolean localEnabled = toBoolean(resourceProviderProperties, LOCAL_ENLISTMENT_ENABLED, true);
checkEnlistment(xaEnabled, localEnabled, true);
DataSource unpooled = new XADataSourceMapper(ds);
return new JDBCConnectionProviderImpl(poolIfNecessary(resourceProviderProperties, unpooled), xaEnabled, localEnabled, getRecoveryId(resourceProviderProperties, xaEnabled));
}
use of javax.sql.XADataSource in project aries by apache.
the class JDBCConnectionProviderFactoryImpl method getProviderFor.
@Override
public AbstractJDBCConnectionProvider getProviderFor(XADataSource ds, Map<String, Object> resourceProviderProperties) {
checkEnlistment(resourceProviderProperties);
DataSource unpooled;
if (ds instanceof DataSource) {
unpooled = (DataSource) ds;
} else {
throw new TransactionException("This resource Provider does not support XA transactions, and the supplied XADataSource is not a DataSource");
}
return new JDBCConnectionProviderImpl(poolIfNecessary(resourceProviderProperties, unpooled));
}
use of javax.sql.XADataSource in project tomee by apache.
the class BoneCPDataSourceCreator method pool.
@Override
public CommonDataSource pool(final String name, final String driver, final Properties properties) {
final BoneCPDataSource pool = createPool(properties);
if (pool.getDriverClass() == null) {
pool.setDriverClass(driver);
}
if (pool.getPoolName() == null) {
pool.setPoolName(name);
}
final String xa = String.class.cast(properties.remove("XaDataSource"));
if (xa != null) {
final XADataSource xaDs = XADataSourceResource.proxy(Thread.currentThread().getContextClassLoader(), xa);
pool.setDatasourceBean(new ManagedXADataSource(xaDs, OpenEJB.getTransactionManager(), SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class)));
}
return pool;
}
use of javax.sql.XADataSource 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