Package org.springframework.jdbc.datasource

Examples of org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler


      SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
      Configuration conf = sqlSessionFactory.getConfiguration();
      if(dataSource != null) {
        DataSource dataSourceToUse = this.dataSource;
        if (this.useTransactionAwareDataSource  && !(this.dataSource instanceof TransactionAwareDataSourceProxy)) { 
                dataSourceToUse = new TransactionAwareDataSourceProxy(this.dataSource)
            }
       
        conf.setEnvironment(new Environment("development",new ManagedTransactionFactory(),dataSourceToUse));
        sqlSessionFactory = new SqlSessionFactoryBuilder().build(conf);
      }
View Full Code Here


      // Tell the SqlMapClient to use the given DataSource, if any.
      if (this.dataSource != null) {
        TransactionConfig transactionConfig = (TransactionConfig) this.transactionConfigClass.newInstance();
        DataSource dataSourceToUse = this.dataSource;
        if (this.useTransactionAwareDataSource && !(this.dataSource instanceof TransactionAwareDataSourceProxy)) {
          dataSourceToUse = new TransactionAwareDataSourceProxy(this.dataSource);
        }
        transactionConfig.setDataSource(dataSourceToUse);
        transactionConfig.initialize(this.transactionConfigProperties);
        applyTransactionConfig(this.sqlMapClient, transactionConfig);
      }
View Full Code Here

      // Tell the SqlMapClient to use the given DataSource, if any.
      if (this.dataSource != null) {
        TransactionConfig transactionConfig = (TransactionConfig) this.transactionConfigClass.newInstance();
        DataSource dataSourceToUse = this.dataSource;
        if (this.useTransactionAwareDataSource && !(this.dataSource instanceof TransactionAwareDataSourceProxy)) {
          dataSourceToUse = new TransactionAwareDataSourceProxy(this.dataSource);
        }
        transactionConfig.setDataSource(dataSourceToUse);
        transactionConfig.initialize(this.transactionConfigProperties);
        applyTransactionConfig(this.sqlMapClient, transactionConfig);
      }
View Full Code Here

  }

  public DataSource getDataSource(boolean withTransactionManager) {
    this.dataSourceProxy = this.jtesterDataSource;
    if (withTransactionManager) {
      this.dataSourceProxy = new TransactionAwareDataSourceProxy(jtesterDataSource);
    }
    return this.dataSourceProxy;
  }
View Full Code Here

    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);
        }
    }
View Full Code Here

  private DataSource makeTransactionAware(DataSource dataSource) {
    if ((dataSource instanceof TransactionAwareDataSourceProxy) || !this.transactionAware) {
      return dataSource;
    }
    return new TransactionAwareDataSourceProxy(dataSource);
  }
View Full Code Here

        connection.toString().startsWith("Transaction-aware proxy"));
  }

  @Test
  public void shouldNotWrapCreateTransactionAwareConnection() throws Exception {
    DataSource dataSource = new TransactionAwareDataSourceProxy(mock(DataSource.class));
    this.factoryBean.setDataSource(dataSource);
    DatabaseDataSourceConnection dataSourceConnection = this.factoryBean.getObject();
    Connection connection = dataSourceConnection.getConnection();
    assertTrue(
        connection.toString() + " is not transaction aware",
View Full Code Here

  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);
    }
  }
View Full Code Here

  @Override
  protected DataSource getDataSourceToUse(DataSource originalDataSource) {
    if (originalDataSource instanceof TransactionAwareDataSourceProxy) {
      return originalDataSource;
    }
    return new TransactionAwareDataSourceProxy(originalDataSource);
  }
View Full Code Here

     * within the database, the Compass connection string should also be set to <code>jdbc://</code>.
     */
    public void setDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
        if (!(dataSource instanceof TransactionAwareDataSourceProxy)) {
            this.dataSource = new TransactionAwareDataSourceProxy(dataSource);
        }
    }
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.