Examples of IsolationLevelDataSourceRouter


Examples of org.springframework.jdbc.datasource.lookup.IsolationLevelDataSourceRouter

    con2.close();
    con2Control.setVoidCallable(1);
    con2Control.replay();
    ds2Control.replay();

    final IsolationLevelDataSourceRouter dsToUse = new IsolationLevelDataSourceRouter();
    Map targetDataSources = new HashMap();
    if (dataSourceLookup) {
      targetDataSources.put("ISOLATION_REPEATABLE_READ", "ds2");
      dsToUse.setDefaultTargetDataSource("ds1");
      StaticListableBeanFactory beanFactory = new StaticListableBeanFactory();
      beanFactory.addBean("ds1", ds1);
      beanFactory.addBean("ds2", ds2);
      dsToUse.setDataSourceLookup(new BeanFactoryDataSourceLookup(beanFactory));
    }
    else {
      targetDataSources.put("ISOLATION_REPEATABLE_READ", ds2);
      dsToUse.setDefaultTargetDataSource(ds1);
    }
    dsToUse.setTargetDataSources(targetDataSources);
    dsToUse.afterPropertiesSet();

    JtaTransactionManager ptm = new JtaTransactionManager(ut);
    ptm.setAllowCustomIsolationLevels(true);

    TransactionTemplate tt = new TransactionTemplate(ptm);
View Full Code Here

Examples of org.springframework.jdbc.datasource.lookup.IsolationLevelDataSourceRouter

    final DataSource dataSource2 = mock(DataSource.class);
    final Connection connection2 = mock(Connection.class);
    given(dataSource2.getConnection()).willReturn(connection2);

    final IsolationLevelDataSourceRouter dsToUse = new IsolationLevelDataSourceRouter();
    Map<Object, Object> targetDataSources = new HashMap<Object, Object>();
    if (dataSourceLookup) {
      targetDataSources.put("ISOLATION_REPEATABLE_READ", "ds2");
      dsToUse.setDefaultTargetDataSource("ds1");
      StaticListableBeanFactory beanFactory = new StaticListableBeanFactory();
      beanFactory.addBean("ds1", dataSource1);
      beanFactory.addBean("ds2", dataSource2);
      dsToUse.setDataSourceLookup(new BeanFactoryDataSourceLookup(beanFactory));
    }
    else {
      targetDataSources.put("ISOLATION_REPEATABLE_READ", dataSource2);
      dsToUse.setDefaultTargetDataSource(dataSource1);
    }
    dsToUse.setTargetDataSources(targetDataSources);
    dsToUse.afterPropertiesSet();

    JtaTransactionManager ptm = new JtaTransactionManager(userTransaction);
    ptm.setAllowCustomIsolationLevels(true);

    TransactionTemplate tt = new TransactionTemplate(ptm);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.