Search in sources :

Example 1 with ManagedXADataSource

use of org.apache.openejb.resource.jdbc.managed.xa.ManagedXADataSource in project tomee by apache.

the class JTADataSourceWrapperFactory method create.

public CommonDataSource create() {
    final TransactionManager transactionManager = OpenEJB.getTransactionManager();
    CommonDataSource cds = findDelegate();
    if (cds instanceof XADataSource) {
        cds = new ManagedXADataSource(cds, transactionManager, SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class));
    } else {
        cds = new ManagedDataSource(DataSource.class.cast(cds), transactionManager, SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class));
    }
    if (logSql) {
        cds = DataSourceFactory.makeItLogging(cds, logPackages);
    }
    return cds;
}
Also used : XADataSource(javax.sql.XADataSource) ManagedXADataSource(org.apache.openejb.resource.jdbc.managed.xa.ManagedXADataSource) TransactionManager(javax.transaction.TransactionManager) ManagedXADataSource(org.apache.openejb.resource.jdbc.managed.xa.ManagedXADataSource) CommonDataSource(javax.sql.CommonDataSource) ManagedDataSource(org.apache.openejb.resource.jdbc.managed.local.ManagedDataSource)

Example 2 with ManagedXADataSource

use of org.apache.openejb.resource.jdbc.managed.xa.ManagedXADataSource in project tomee by apache.

the class PoolDataSourceCreator method poolManagedWithRecovery.

@Override
public DataSource poolManagedWithRecovery(final String name, final XAResourceWrapper xaResourceWrapper, final String driver, final Properties properties) {
    final TransactionManager transactionManager = new TransactionManagerWrapper(OpenEJB.getTransactionManager(), name, xaResourceWrapper);
    final CommonDataSource ds = pool(name, driver, properties);
    if (ds instanceof XADataSource) {
        return new ManagedXADataSource(ds, transactionManager, SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class));
    }
    return new ManagedDataSource(DataSource.class.cast(ds), transactionManager, SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class));
}
Also used : XADataSource(javax.sql.XADataSource) ManagedXADataSource(org.apache.openejb.resource.jdbc.managed.xa.ManagedXADataSource) TransactionManager(javax.transaction.TransactionManager) TransactionManagerWrapper(org.apache.openejb.resource.TransactionManagerWrapper) ManagedXADataSource(org.apache.openejb.resource.jdbc.managed.xa.ManagedXADataSource) TransactionSynchronizationRegistry(javax.transaction.TransactionSynchronizationRegistry) CommonDataSource(javax.sql.CommonDataSource) ManagedDataSource(org.apache.openejb.resource.jdbc.managed.local.ManagedDataSource) ManagedDataSource(org.apache.openejb.resource.jdbc.managed.local.ManagedDataSource) XADataSource(javax.sql.XADataSource) CommonDataSource(javax.sql.CommonDataSource) DataSource(javax.sql.DataSource) ManagedXADataSource(org.apache.openejb.resource.jdbc.managed.xa.ManagedXADataSource)

Example 3 with ManagedXADataSource

use of org.apache.openejb.resource.jdbc.managed.xa.ManagedXADataSource 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;
}
Also used : XADataSource(javax.sql.XADataSource) ManagedXADataSource(org.apache.openejb.resource.jdbc.managed.xa.ManagedXADataSource) ManagedXADataSource(org.apache.openejb.resource.jdbc.managed.xa.ManagedXADataSource) BoneCPDataSource(com.jolbox.bonecp.BoneCPDataSource)

Aggregations

XADataSource (javax.sql.XADataSource)3 ManagedXADataSource (org.apache.openejb.resource.jdbc.managed.xa.ManagedXADataSource)3 CommonDataSource (javax.sql.CommonDataSource)2 TransactionManager (javax.transaction.TransactionManager)2 ManagedDataSource (org.apache.openejb.resource.jdbc.managed.local.ManagedDataSource)2 BoneCPDataSource (com.jolbox.bonecp.BoneCPDataSource)1 DataSource (javax.sql.DataSource)1 TransactionSynchronizationRegistry (javax.transaction.TransactionSynchronizationRegistry)1 TransactionManagerWrapper (org.apache.openejb.resource.TransactionManagerWrapper)1