use of org.apache.aries.tx.control.jdbc.xa.connection.impl.XADataSourceMapper in project aries by apache.
the class JDBCConnectionProviderFactoryImpl method getProviderFor.
@Override
public AbstractJDBCConnectionProvider getProviderFor(DataSource ds, Map<String, Object> resourceProviderProperties) {
boolean xaEnabled = toBoolean(resourceProviderProperties, XA_ENLISTMENT_ENABLED, true);
boolean localEnabled = toBoolean(resourceProviderProperties, LOCAL_ENLISTMENT_ENABLED, true);
try {
checkEnlistment(xaEnabled, localEnabled, ds.isWrapperFor(XADataSource.class));
DataSource toUse = poolIfNecessary(resourceProviderProperties, xaEnabled ? new XADataSourceMapper(ds.unwrap(XADataSource.class)) : ds);
return new JDBCConnectionProviderImpl(toUse, xaEnabled, localEnabled, getRecoveryId(resourceProviderProperties, xaEnabled));
} catch (SQLException sqle) {
throw new TransactionException("Unable to create the JDBC resource provider", sqle);
}
}
use of org.apache.aries.tx.control.jdbc.xa.connection.impl.XADataSourceMapper in project aries by apache.
the class JDBCConnectionProviderFactoryImpl method getProviderFor.
@Override
public JDBCConnectionProviderImpl getProviderFor(DataSourceFactory dsf, Properties jdbcProperties, Map<String, Object> resourceProviderProperties) {
boolean xaEnabled = toBoolean(resourceProviderProperties, XA_ENLISTMENT_ENABLED, true);
boolean localEnabled = toBoolean(resourceProviderProperties, LOCAL_ENLISTMENT_ENABLED, true);
boolean useDriver = toBoolean(resourceProviderProperties, USE_DRIVER, false);
checkEnlistment(xaEnabled, localEnabled, !useDriver);
DataSource unpooled;
try {
if (useDriver) {
unpooled = new DriverDataSource(dsf.createDriver(null), jdbcProperties.getProperty(JDBC_URL), jdbcProperties);
} else if (xaEnabled) {
unpooled = new XADataSourceMapper(dsf.createXADataSource(jdbcProperties));
} else {
unpooled = dsf.createDataSource(jdbcProperties);
}
} catch (SQLException sqle) {
throw new TransactionException("Unable to create the JDBC resource provider", sqle);
}
DataSource toUse = poolIfNecessary(resourceProviderProperties, unpooled);
return new JDBCConnectionProviderImpl(toUse, xaEnabled, localEnabled, getRecoveryId(resourceProviderProperties, xaEnabled));
}
use of org.apache.aries.tx.control.jdbc.xa.connection.impl.XADataSourceMapper in project aries by apache.
the class XAJPADataSourceSetup method decorateJPAProperties.
@Override
protected Map<String, Object> decorateJPAProperties(DataSourceFactory dsf, Map<String, Object> providerProperties, Properties jdbcProperties, Map<String, Object> jpaProperties) throws Exception {
DataSource unpooled;
try {
if (toBoolean(providerProperties, USE_DRIVER, false)) {
throw new TransactionException("The Database must use an XA connection");
} else {
unpooled = new XADataSourceMapper(dsf.createXADataSource(jdbcProperties));
}
} catch (SQLException sqle) {
throw new TransactionException("Unable to create the JDBC resource provider", sqle);
}
DataSource toUse = poolIfNecessary(providerProperties, unpooled);
jpaProperties.put("javax.persistence.jtaDataSource", toUse);
return jpaProperties;
}
use of org.apache.aries.tx.control.jdbc.xa.connection.impl.XADataSourceMapper 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));
}
Aggregations