non-matching @Transactional qualifier value will lead to IllegalStateException (SPR-6810)

This commit is contained in:
Juergen Hoeller 2010-02-08 18:32:38 +00:00
parent 6c0d934b92
commit c5c38c6664
1 changed files with 8 additions and 4 deletions

View File

@ -247,7 +247,6 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
if (this.transactionManager != null || this.beanFactory == null) {
return this.transactionManager;
}
PlatformTransactionManager chosen = null;
String qualifier = txAttr.getQualifier();
if (StringUtils.hasLength(qualifier)) {
if (!(this.beanFactory instanceof ConfigurableListableBeanFactory)) {
@ -257,6 +256,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
ConfigurableListableBeanFactory bf = (ConfigurableListableBeanFactory) this.beanFactory;
Map<String, PlatformTransactionManager> tms =
BeanFactoryUtils.beansOfTypeIncludingAncestors(bf, PlatformTransactionManager.class);
PlatformTransactionManager chosen = null;
for (String beanName : tms.keySet()) {
if (bf.containsBeanDefinition(beanName)) {
BeanDefinition bd = bf.getBeanDefinition(beanName);
@ -274,10 +274,14 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
}
}
}
}
if (chosen != null) {
return chosen;
}
else {
throw new IllegalStateException(
"No matching PlatformTransactionManager bean found for qualifier '" + qualifier + "'");
}
}
else if (this.transactionManagerBeanName != null) {
return this.beanFactory.getBean(this.transactionManagerBeanName, PlatformTransactionManager.class);
}