Search in sources :

Example 1 with DriverDataSource

use of org.apache.aries.tx.control.jdbc.common.impl.DriverDataSource in project aries by apache.

the class JDBCConnectionProviderFactoryImpl method getProviderFor.

@Override
public AbstractJDBCConnectionProvider getProviderFor(Driver driver, Properties jdbcProperties, Map<String, Object> resourceProviderProperties) {
    boolean xaEnabled = toBoolean(resourceProviderProperties, XA_ENLISTMENT_ENABLED, false);
    boolean localEnabled = toBoolean(resourceProviderProperties, LOCAL_ENLISTMENT_ENABLED, true);
    checkEnlistment(xaEnabled, localEnabled, false);
    DataSource toUse = poolIfNecessary(resourceProviderProperties, new DriverDataSource(driver, jdbcProperties.getProperty(JDBC_URL), jdbcProperties));
    return new JDBCConnectionProviderImpl(toUse, xaEnabled, localEnabled, getRecoveryId(resourceProviderProperties, xaEnabled));
}
Also used : DriverDataSource(org.apache.aries.tx.control.jdbc.common.impl.DriverDataSource) XADataSource(javax.sql.XADataSource) DriverDataSource(org.apache.aries.tx.control.jdbc.common.impl.DriverDataSource) DataSource(javax.sql.DataSource)

Example 2 with DriverDataSource

use of org.apache.aries.tx.control.jdbc.common.impl.DriverDataSource 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));
}
Also used : TransactionException(org.osgi.service.transaction.control.TransactionException) DriverDataSource(org.apache.aries.tx.control.jdbc.common.impl.DriverDataSource) SQLException(java.sql.SQLException) XADataSourceMapper(org.apache.aries.tx.control.jdbc.xa.connection.impl.XADataSourceMapper) XADataSource(javax.sql.XADataSource) DriverDataSource(org.apache.aries.tx.control.jdbc.common.impl.DriverDataSource) DataSource(javax.sql.DataSource)

Example 3 with DriverDataSource

use of org.apache.aries.tx.control.jdbc.common.impl.DriverDataSource in project aries by apache.

the class JDBCConnectionProviderFactoryImpl method getProviderFor.

@Override
public AbstractJDBCConnectionProvider getProviderFor(Driver driver, Properties jdbcProperties, Map<String, Object> resourceProviderProperties) {
    checkEnlistment(resourceProviderProperties);
    DataSource toUse = poolIfNecessary(resourceProviderProperties, new DriverDataSource(driver, jdbcProperties.getProperty(JDBC_URL), jdbcProperties));
    return new JDBCConnectionProviderImpl(toUse);
}
Also used : DriverDataSource(org.apache.aries.tx.control.jdbc.common.impl.DriverDataSource) XADataSource(javax.sql.XADataSource) DriverDataSource(org.apache.aries.tx.control.jdbc.common.impl.DriverDataSource) DataSource(javax.sql.DataSource)

Example 4 with DriverDataSource

use of org.apache.aries.tx.control.jdbc.common.impl.DriverDataSource in project aries by apache.

the class JDBCConnectionProviderFactoryImpl method getProviderFor.

@Override
public AbstractJDBCConnectionProvider getProviderFor(DataSourceFactory dsf, Properties jdbcProperties, Map<String, Object> resourceProviderProperties) {
    checkEnlistment(resourceProviderProperties);
    DataSource unpooled;
    try {
        if (toBoolean(resourceProviderProperties, USE_DRIVER, false)) {
            unpooled = new DriverDataSource(dsf.createDriver(null), jdbcProperties.getProperty(JDBC_URL), 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);
}
Also used : TransactionException(org.osgi.service.transaction.control.TransactionException) DriverDataSource(org.apache.aries.tx.control.jdbc.common.impl.DriverDataSource) SQLException(java.sql.SQLException) XADataSource(javax.sql.XADataSource) DriverDataSource(org.apache.aries.tx.control.jdbc.common.impl.DriverDataSource) DataSource(javax.sql.DataSource)

Aggregations

DataSource (javax.sql.DataSource)4 XADataSource (javax.sql.XADataSource)4 DriverDataSource (org.apache.aries.tx.control.jdbc.common.impl.DriverDataSource)4 SQLException (java.sql.SQLException)2 TransactionException (org.osgi.service.transaction.control.TransactionException)2 XADataSourceMapper (org.apache.aries.tx.control.jdbc.xa.connection.impl.XADataSourceMapper)1