当前位置: 首页>>代码示例>>Java>>正文


Java TransactionAwareDataSourceProxy类代码示例

本文整理汇总了Java中org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy的典型用法代码示例。如果您正苦于以下问题:Java TransactionAwareDataSourceProxy类的具体用法?Java TransactionAwareDataSourceProxy怎么用?Java TransactionAwareDataSourceProxy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TransactionAwareDataSourceProxy类属于org.springframework.jdbc.datasource包,在下文中一共展示了TransactionAwareDataSourceProxy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addTenantForSchema

import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; //导入依赖的package包/类
@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);
        }
    }

}
 
开发者ID:grails,项目名称:gorm-hibernate5,代码行数:24,代码来源:HibernateDatastore.java

示例2: GrailsHibernateTemplate

import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; //导入依赖的package包/类
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;
    }
}
 
开发者ID:grails,项目名称:gorm-hibernate5,代码行数:20,代码来源:GrailsHibernateTemplate.java

示例3: getDataSource

import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; //导入依赖的package包/类
/**
 * 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);
	}
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:25,代码来源:RiceDataSourceConnectionFactory.java

示例4: fetchConnectionsAndDepositForLaterUse

import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; //导入依赖的package包/类
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;
}
 
开发者ID:alibaba,项目名称:cobarclient,代码行数:25,代码来源:DefaultConcurrentRequestProcessor.java

示例5: getDataSourceToUse

import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:TransactionAwareDataSourceConnectionProvider.java

示例6: setDataSource

import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; //导入依赖的package包/类
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;
    }
}
 
开发者ID:mirage-sql,项目名称:mirage-integration,代码行数:12,代码来源:SpringConnectionProvider.java

示例7: setDataSource

import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; //导入依赖的package包/类
public void setDataSource(DataSource dataSource) {
	if (dataSource instanceof TransactionAwareDataSourceProxy) {
		this.dataSource = ((TransactionAwareDataSourceProxy) dataSource)
				.getTargetDataSource();
	} else {
		this.dataSource = dataSource;
	}
}
 
开发者ID:IAMTJW,项目名称:TJWmybatis,代码行数:9,代码来源:MySQLSessionFactoryBean.java

示例8: dataSourceConnectionProvider

import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(DataSourceConnectionProvider.class)
public DataSourceConnectionProvider dataSourceConnectionProvider(
		DataSource dataSource) {
	return new DataSourceConnectionProvider(
			new TransactionAwareDataSourceProxy(dataSource));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:JooqAutoConfiguration.java

示例9: jdbiFactory

import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; //导入依赖的package包/类
@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;
}
 
开发者ID:bwajtr,项目名称:java-persistence-frameworks-comparison,代码行数:11,代码来源:DbTestsApplication.java

示例10: setDataSource

import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:11,代码来源:SpringContentEngineConfiguration.java

示例11: setDataSource

import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:11,代码来源:SpringFormEngineConfiguration.java

示例12: setDataSource

import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:11,代码来源:SpringDmnEngineConfiguration.java

示例13: setDataSource

import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:11,代码来源:SpringProcessEngineConfiguration.java

示例14: setDataSource

import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:11,代码来源:SpringCmmnEngineConfiguration.java

示例15: setDataSource

import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:11,代码来源:SpringIdmEngineConfiguration.java


注:本文中的org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。