本文整理汇总了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);
}
}
}
示例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;
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}