Java 类org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy 实例源码

项目:gorm-hibernate5    文件:HibernateDatastore.java   
@Override
public void addTenantForSchema(String schemaName) {
    addTenantForSchemaInternal(schemaName);
    registerAllEntitiesWithEnhancer();
    HibernateConnectionSource defaultConnectionSource = (HibernateConnectionSource) connectionSources.getDefaultConnectionSource();
    DataSource dataSource = defaultConnectionSource.getDataSource();
    if(dataSource instanceof TransactionAwareDataSourceProxy) {
        dataSource = ((TransactionAwareDataSourceProxy) dataSource).getTargetDataSource();
    }
    Object existing = TransactionSynchronizationManager.getResource(dataSource);
    if(existing instanceof ConnectionHolder) {
        ConnectionHolder connectionHolder = (ConnectionHolder) existing;
        Connection connection = connectionHolder.getConnection();
        try {
            if(!connection.isClosed() && !connection.isReadOnly()) {
                schemaHandler.useDefaultSchema(connection);
            }
        } catch (SQLException e) {
            throw new DatastoreConfigurationException("Failed to reset to default schema: " + e.getMessage(), e);
        }
    }

}
项目:gorm-hibernate5    文件:GrailsHibernateTemplate.java   
public GrailsHibernateTemplate(SessionFactory sessionFactory) {
    Assert.notNull(sessionFactory, "Property 'sessionFactory' is required");
    this.sessionFactory = sessionFactory;

    ConnectionProvider connectionProvider = ((SessionFactoryImplementor) sessionFactory).getServiceRegistry().getService(ConnectionProvider.class);
    if(connectionProvider instanceof DatasourceConnectionProviderImpl) {
        this.dataSource = ((DatasourceConnectionProviderImpl) connectionProvider).getDataSource();
        if(dataSource instanceof TransactionAwareDataSourceProxy) {
            this.dataSource = ((TransactionAwareDataSourceProxy) dataSource).getTargetDataSource();
        }
        jdbcExceptionTranslator = new SQLErrorCodeSQLExceptionTranslator(dataSource);
    }
    else {
        // must be in unit test mode, setup default translator
        SQLErrorCodeSQLExceptionTranslator sqlErrorCodeSQLExceptionTranslator = new SQLErrorCodeSQLExceptionTranslator();
        sqlErrorCodeSQLExceptionTranslator.setDatabaseProductName("H2");
        jdbcExceptionTranslator = sqlErrorCodeSQLExceptionTranslator;
    }
}
项目:kc-rice    文件:RiceDataSourceConnectionFactory.java   
/**
 * Return the DataSource to use for the given JCD alias.
 * <p>This implementation fetches looks for a bean with the
 * JCD alias name in the provided Spring BeanFactory.
 * @param jcdAlias the JCD alias to retrieve a DataSource for
 * @return the DataSource to use
 */

protected DataSource getDataSource(String jcdAlias) throws LookupException {
    DataSource dataSource = null;
    for (BeanFactory beanFactory : beanFactories) {
        if (beanFactory.containsBean(jcdAlias)) {
            dataSource = (DataSource) beanFactory.getBean(jcdAlias, DataSource.class);
            break;
        }
    }
    if (dataSource == null) {
        throw new LookupException("Could not lookup datasource with alias " + jcdAlias);
    } else if (dataSource instanceof TransactionAwareDataSourceProxy) {
        return dataSource;
    } else {
        return new TransactionAwareDataSourceProxy(dataSource);
    }
}
项目:rice    文件:RiceDataSourceConnectionFactory.java   
/**
 * Return the DataSource to use for the given JCD alias.
 * <p>This implementation fetches looks for a bean with the
 * JCD alias name in the provided Spring BeanFactory.
 * @param jcdAlias the JCD alias to retrieve a DataSource for
 * @return the DataSource to use
 */

protected DataSource getDataSource(String jcdAlias) throws LookupException {
    DataSource dataSource = null;
    for (BeanFactory beanFactory : beanFactories) {
        if (beanFactory.containsBean(jcdAlias)) {
            dataSource = (DataSource) beanFactory.getBean(jcdAlias, DataSource.class);
            break;
        }
    }
    if (dataSource == null) {
        throw new LookupException("Could not lookup datasource with alias " + jcdAlias);
    } else if (dataSource instanceof TransactionAwareDataSourceProxy) {
        return dataSource;
    } else {
        return new TransactionAwareDataSourceProxy(dataSource);
    }
}
项目:cobarclient    文件:DefaultConcurrentRequestProcessor.java   
private List<RequestDepository> fetchConnectionsAndDepositForLaterUse(
                                                                      List<ConcurrentRequest> requests) {
    List<RequestDepository> depos = new ArrayList<RequestDepository>();
    for (ConcurrentRequest request : requests) {
        DataSource dataSource = request.getDataSource();

        Connection springCon = null;
        boolean transactionAware = (dataSource instanceof TransactionAwareDataSourceProxy);
        try {
            springCon = (transactionAware ? dataSource.getConnection() : DataSourceUtils
                    .doGetConnection(dataSource));
        } catch (SQLException ex) {
            throw new CannotGetJdbcConnectionException("Could not get JDBC Connection", ex);
        }

        RequestDepository depo = new RequestDepository();
        depo.setOriginalRequest(request);
        depo.setConnectionToUse(springCon);
        depo.setTransactionAware(transactionAware);
        depos.add(depo);
    }

    return depos;
}
项目:kuali_rice    文件:RiceDataSourceConnectionFactory.java   
/**
 * Return the DataSource to use for the given JCD alias.
 * <p>This implementation fetches looks for a bean with the
 * JCD alias name in the provided Spring BeanFactory.
 * @param jcdAlias the JCD alias to retrieve a DataSource for
 * @return the DataSource to use
 */

protected DataSource getDataSource(String jcdAlias) throws LookupException {
    DataSource dataSource = null;
    for (BeanFactory beanFactory : beanFactories) {
        if (beanFactory.containsBean(jcdAlias)) {
            dataSource = (DataSource) beanFactory.getBean(jcdAlias, DataSource.class);
            break;
        }
    }
    if (dataSource == null) {
        throw new LookupException("Could not lookup datasource with alias " + jcdAlias);
    } else if (dataSource instanceof TransactionAwareDataSourceProxy) {
        return dataSource;
    } else {
        return new TransactionAwareDataSourceProxy(dataSource);
    }
}
项目:lams    文件:TransactionAwareDataSourceConnectionProvider.java   
/**
 * Return a TransactionAwareDataSourceProxy for the given DataSource,
 * provided that it isn't a TransactionAwareDataSourceProxy already.
 */
@Override
protected DataSource getDataSourceToUse(DataSource originalDataSource) {
    if (originalDataSource instanceof TransactionAwareDataSourceProxy) {
        return originalDataSource;
    }
    return new TransactionAwareDataSourceProxy(originalDataSource);
}
项目:mirage-integration    文件:SpringConnectionProvider.java   
public void setDataSource(DataSource dataSource) {
    if (dataSource instanceof TransactionAwareDataSourceProxy) {
        // If we got a TransactionAwareDataSourceProxy, we need to perform transactions
        // for its underlying target DataSource, else data access code won't see
        // properly exposed transactions (i.e. transactions for the target DataSource).
        this.dataSource = ((TransactionAwareDataSourceProxy) dataSource).getTargetDataSource();
    }
    else {
        this.dataSource = dataSource;
    }
}
项目:spring4-understanding    文件:TransactionAwareDataSourceConnectionProvider.java   
/**
 * Return a TransactionAwareDataSourceProxy for the given DataSource,
 * provided that it isn't a TransactionAwareDataSourceProxy already.
 */
@Override
protected DataSource getDataSourceToUse(DataSource originalDataSource) {
    if (originalDataSource instanceof TransactionAwareDataSourceProxy) {
        return originalDataSource;
    }
    return new TransactionAwareDataSourceProxy(originalDataSource);
}
项目:TJWmybatis    文件:MySQLSessionFactoryBean.java   
public void setDataSource(DataSource dataSource) {
    if (dataSource instanceof TransactionAwareDataSourceProxy) {
        this.dataSource = ((TransactionAwareDataSourceProxy) dataSource)
                .getTargetDataSource();
    } else {
        this.dataSource = dataSource;
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JooqAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(DataSourceConnectionProvider.class)
public DataSourceConnectionProvider dataSourceConnectionProvider(
        DataSource dataSource) {
    return new DataSourceConnectionProvider(
            new TransactionAwareDataSourceProxy(dataSource));
}
项目:java-persistence-frameworks-comparison    文件:DbTestsApplication.java   
@SuppressWarnings("SpringJavaAutowiringInspection")
@Bean
public DBI jdbiFactory(DataSource dataSource) {
    // note that for JDBI we have to wrap datasource with TransactionAwareDataSourceProxy otherwise JDBI won't respect
    // transactions created by spring
    TransactionAwareDataSourceProxy transactionAwareDataSourceProxy = new TransactionAwareDataSourceProxy(dataSource);
    DBI dbi = new DBI(transactionAwareDataSourceProxy);
    dbi.setSQLLog(new SLF4JLog());  // to enable SLF4J logging
    return dbi;
}
项目:flowable-engine    文件:SpringContentEngineConfiguration.java   
@Override
public ContentEngineConfiguration setDataSource(DataSource dataSource) {
    if (dataSource instanceof TransactionAwareDataSourceProxy) {
        return super.setDataSource(dataSource);
    } else {
        // Wrap datasource in Transaction-aware proxy
        DataSource proxiedDataSource = new TransactionAwareDataSourceProxy(dataSource);
        return super.setDataSource(proxiedDataSource);
    }
}
项目:flowable-engine    文件:SpringFormEngineConfiguration.java   
@Override
public FormEngineConfiguration setDataSource(DataSource dataSource) {
    if (dataSource instanceof TransactionAwareDataSourceProxy) {
        return (FormEngineConfiguration) super.setDataSource(dataSource);
    } else {
        // Wrap datasource in Transaction-aware proxy
        DataSource proxiedDataSource = new TransactionAwareDataSourceProxy(dataSource);
        return (FormEngineConfiguration) super.setDataSource(proxiedDataSource);
    }
}
项目:flowable-engine    文件:SpringDmnEngineConfiguration.java   
@Override
public DmnEngineConfiguration setDataSource(DataSource dataSource) {
    if (dataSource instanceof TransactionAwareDataSourceProxy) {
        return super.setDataSource(dataSource);
    } else {
        // Wrap datasource in Transaction-aware proxy
        DataSource proxiedDataSource = new TransactionAwareDataSourceProxy(dataSource);
        return super.setDataSource(proxiedDataSource);
    }
}
项目:flowable-engine    文件:SpringProcessEngineConfiguration.java   
@Override
public ProcessEngineConfiguration setDataSource(DataSource dataSource) {
    if (dataSource instanceof TransactionAwareDataSourceProxy) {
        return super.setDataSource(dataSource);
    } else {
        // Wrap datasource in Transaction-aware proxy
        DataSource proxiedDataSource = new TransactionAwareDataSourceProxy(dataSource);
        return super.setDataSource(proxiedDataSource);
    }
}
项目:flowable-engine    文件:SpringCmmnEngineConfiguration.java   
@Override
public CmmnEngineConfiguration setDataSource(DataSource dataSource) {
    if (dataSource instanceof TransactionAwareDataSourceProxy) {
        return super.setDataSource(dataSource);
    } else {
        // Wrap datasource in Transaction-aware proxy
        DataSource proxiedDataSource = new TransactionAwareDataSourceProxy(dataSource);
        return super.setDataSource(proxiedDataSource);
    }
}
项目:flowable-engine    文件:SpringProcessEngineConfiguration.java   
@Override
public ProcessEngineConfiguration setDataSource(DataSource dataSource) {
    if (dataSource instanceof TransactionAwareDataSourceProxy) {
        return super.setDataSource(dataSource);
    } else {
        // Wrap datasource in Transaction-aware proxy
        DataSource proxiedDataSource = new TransactionAwareDataSourceProxy(dataSource);
        return super.setDataSource(proxiedDataSource);
    }
}
项目:flowable-engine    文件:SpringIdmEngineConfiguration.java   
@Override
public IdmEngineConfiguration setDataSource(DataSource dataSource) {
    if (dataSource instanceof TransactionAwareDataSourceProxy) {
        return (IdmEngineConfiguration) super.setDataSource(dataSource);
    } else {
        // Wrap datasource in Transaction-aware proxy
        DataSource proxiedDataSource = new TransactionAwareDataSourceProxy(dataSource);
        return (IdmEngineConfiguration) super.setDataSource(proxiedDataSource);
    }
}
项目:spring-boot-concourse    文件:JooqAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(DataSourceConnectionProvider.class)
public DataSourceConnectionProvider dataSourceConnectionProvider(
        DataSource dataSource) {
    return new DataSourceConnectionProvider(
            new TransactionAwareDataSourceProxy(dataSource));
}
项目:contestparser    文件:JooqAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(DataSourceConnectionProvider.class)
public DataSourceConnectionProvider dataSourceConnectionProvider(
        DataSource dataSource) {
    return new DataSourceConnectionProvider(
            new TransactionAwareDataSourceProxy(dataSource));
}
项目:SecureBPMN    文件:SpringProcessEngineConfiguration.java   
@Override
public ProcessEngineConfigurationImpl setDataSource(DataSource dataSource) {
  if(dataSource instanceof TransactionAwareDataSourceProxy) {
    return super.setDataSource(dataSource);
  } else {
    // Wrap datasource in Transaction-aware proxy
    DataSource proxiedDataSource = new TransactionAwareDataSourceProxy(dataSource);
    return super.setDataSource(proxiedDataSource);
  }
}
项目:FoxBPM    文件:ProcessEngineConfigurationSpring.java   
public ProcessEngineConfiguration setDataSource(DataSource dataSource) {
  if (dataSource instanceof TransactionAwareDataSourceProxy) {
    return super.setDataSource(dataSource);
  } else {
    DataSource proxiedDataSource = new TransactionAwareDataSourceProxy(dataSource);
    return super.setDataSource(proxiedDataSource);
  }
}
项目:class-guard    文件:TransactionAwareDataSourceConnectionProvider.java   
/**
 * Return a TransactionAwareDataSourceProxy for the given DataSource,
 * provided that it isn't a TransactionAwareDataSourceProxy already.
 */
@Override
protected DataSource getDataSourceToUse(DataSource originalDataSource) {
    if (originalDataSource instanceof TransactionAwareDataSourceProxy) {
        return originalDataSource;
    }
    return new TransactionAwareDataSourceProxy(originalDataSource);
}
项目:spring-doma-junit4-dbunit-sample    文件:AppConfig.java   
@Bean
public Config domaConfig() {
    return new DomaAbstractConfig() {
        @Override
        public Dialect getDialect() {
            return dialect();
        }

        @Override
        public DataSource getDataSource() {
            return new TransactionAwareDataSourceProxy(dataSource());
        }
    };
}
项目:score    文件:PartitionTemplateWithEmfTest.java   
@Bean
DataSource dataSource() {
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName("org.h2.Driver");
    ds.setUrl("jdbc:h2:mem:test");
    ds.setUsername("sa");
    ds.setPassword("sa");
    ds.setDefaultAutoCommit(false);
    return new TransactionAwareDataSourceProxy(ds);
}
项目:score    文件:VersionRepositoryTest.java   
@Bean
DataSource dataSource() {
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName("org.h2.Driver");
    ds.setUrl("jdbc:h2:mem:test");
    ds.setUsername("sa");
    ds.setPassword("sa");
    ds.setDefaultAutoCommit(false);
    return new TransactionAwareDataSourceProxy(ds);
}
项目:score    文件:ExecutionQueueRepositoryTest.java   
@Bean
DataSource dataSource(){
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName("org.h2.Driver");
    ds.setUrl("jdbc:h2:mem:test");
    ds.setUsername("sa");
    ds.setPassword("sa");
    ds.setDefaultAutoCommit(false);
    return new TransactionAwareDataSourceProxy(ds);
}
项目:score    文件:WorkerNodeServiceTest.java   
@Bean
DataSource dataSource() {
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName("org.h2.Driver");
    ds.setUrl("jdbc:h2:mem:test");
    ds.setUsername("sa");
    ds.setPassword("sa");
    ds.setDefaultAutoCommit(false);
    return new TransactionAwareDataSourceProxy(ds);
}
项目:FiWare-Template-Handler    文件:SpringProcessEngineConfiguration.java   
@Override
public ProcessEngineConfigurationImpl setDataSource(DataSource dataSource) {
  if(dataSource instanceof TransactionAwareDataSourceProxy) {
    return super.setDataSource(dataSource);
  } else {
    // Wrap datasource in Transaction-aware proxy
    DataSource proxiedDataSource = new TransactionAwareDataSourceProxy(dataSource);
    return super.setDataSource(proxiedDataSource);
  }
}
项目:javaconfig-ftw    文件:SpringProcessEngineConfiguration.java   
@Override
public ProcessEngineConfiguration setDataSource(DataSource dataSource) {
  if(dataSource instanceof TransactionAwareDataSourceProxy) {
    return super.setDataSource(dataSource);
  } else {
    // Wrap datasource in Transaction-aware proxy
    DataSource proxiedDataSource = new TransactionAwareDataSourceProxy(dataSource);
    return super.setDataSource(proxiedDataSource);
  }
}
项目:javaconfig-ftw    文件:DefaultActivitiConfigurer.java   
private void setup(ApplicationContext context, DataSource d) {
    this.applicationContext = context;
    Assert.notNull(d, "the dataSource can't be null");
    if (d instanceof TransactionAwareDataSourceProxy) {
        this.dataSource = d;
    } else {
        TransactionAwareDataSourceProxy transactionAwareDataSourceProxy =
                new TransactionAwareDataSourceProxy(d);
        transactionAwareDataSourceProxy.afterPropertiesSet();
        this.dataSource = transactionAwareDataSourceProxy;
    }
    this.platformTransactionManager = new DataSourceTransactionManager(d);
}
项目:camunda-bpm-platform    文件:SpringTransactionsProcessEngineConfiguration.java   
@Override
public ProcessEngineConfigurationImpl setDataSource(DataSource dataSource) {
  if(dataSource instanceof TransactionAwareDataSourceProxy) {
    return super.setDataSource(dataSource);
  } else {
    // Wrap datasource in Transaction-aware proxy
    DataSource proxiedDataSource = new TransactionAwareDataSourceProxy(dataSource);
    return super.setDataSource(proxiedDataSource);
  }
}
项目:cmc-claim-store    文件:DbConfiguration.java   
@Bean
public TransactionAwareDataSourceProxy transactionAwareDataSourceProxy(DataSource dataSource) {
    return new TransactionAwareDataSourceProxy(dataSource);
}
项目:cmc-claim-store    文件:DbConfiguration.java   
@Bean
public PlatformTransactionManager transactionManager(TransactionAwareDataSourceProxy dataSource) {
    return new DataSourceTransactionManager(dataSource);
}
项目:unitils    文件:ProfilesModuleSpringApplicationContextIntegrationTest.java   
@Test
public void test() {
    Assert.assertTrue(dataSource instanceof TransactionAwareDataSourceProxy);
}
项目:kc-rice    文件:RoleDaoJdbc.java   
public void setDataSource(DataSource dataSource) {
    this.dataSource = new TransactionAwareDataSourceProxy(dataSource);
}
项目:kc-rice    文件:DocumentSearchDAOJdbcImpl.java   
public void setDataSource(DataSource dataSource) {
    this.dataSource = new TransactionAwareDataSourceProxy(dataSource);
}
项目:camunda-bpm-spring-boot-starter    文件:DefaultDatasourceConfigurationTest.java   
private DataSource getDataSourceFromConfiguration() {
  return ((TransactionAwareDataSourceProxy) configuration.getDataSource()).getTargetDataSource();
}
项目:rice    文件:RoleDaoJdbc.java   
public void setDataSource(DataSource dataSource) {
    this.dataSource = new TransactionAwareDataSourceProxy(dataSource);
}