Polishing

This commit is contained in:
Sam Brannen 2020-05-11 12:26:13 +02:00
parent 2f80a085f5
commit 65acda8d3e
3 changed files with 10 additions and 6 deletions

View File

@ -85,14 +85,14 @@ import org.springframework.core.Ordered;
* In both of the scenarios above, {@code @EnableTransactionManagement} and {@code
* <tx:annotation-driven/>} are responsible for registering the necessary Spring
* components that power annotation-driven transaction management, such as the
* TransactionInterceptor and the proxy- or AspectJ-based advice that weave the
* TransactionInterceptor and the proxy- or AspectJ-based advice that weaves the
* interceptor into the call stack when {@code JdbcFooRepository}'s {@code @Transactional}
* methods are invoked.
*
* <p>A minor difference between the two examples lies in the naming of the {@code
* TransactionManager} bean: In the {@code @Bean} case, the name is
* <em>"txManager"</em> (per the name of the method); in the XML case, the name is
* <em>"transactionManager"</em>. The {@code <tx:annotation-driven/>} is hard-wired to
* <em>"transactionManager"</em>. {@code <tx:annotation-driven/>} is hard-wired to
* look for a bean named "transactionManager" by default, however
* {@code @EnableTransactionManagement} is more flexible; it will fall back to a by-type
* lookup for any {@code TransactionManager} bean in the container. Thus the name

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -192,7 +192,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
/**
* Specify the name of the default transaction manager bean.
* This can either point to a traditional {@link PlatformTransactionManager} or a
* <p>This can either point to a traditional {@link PlatformTransactionManager} or a
* {@link ReactiveTransactionManager} for reactive transaction management.
*/
public void setTransactionManagerBeanName(@Nullable String transactionManagerBeanName) {
@ -209,7 +209,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
/**
* Specify the <em>default</em> transaction manager to use to drive transactions.
* This can either be a traditional {@link PlatformTransactionManager} or a
* <p>This can either be a traditional {@link PlatformTransactionManager} or a
* {@link ReactiveTransactionManager} for reactive transaction management.
* <p>The default transaction manager will be used if a <em>qualifier</em>
* has not been declared for a given transaction or if an explicit name for the
@ -222,7 +222,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
/**
* Return the default transaction manager, or {@code null} if unknown.
* This can either be a traditional {@link PlatformTransactionManager} or a
* <p>This can either be a traditional {@link PlatformTransactionManager} or a
* {@link ReactiveTransactionManager} for reactive transaction management.
*/
@Nullable

View File

@ -35,6 +35,7 @@ import org.springframework.context.annotation.Primary;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.config.TransactionManagementConfigUtils;
import org.springframework.transaction.event.TransactionalEventListenerFactory;
import org.springframework.transaction.testfixture.CallCountingTransactionManager;
@ -106,6 +107,7 @@ public class EnableTransactionManagementTests {
public void txManagerIsResolvedCorrectlyWhenMultipleManagersArePresent() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
EnableTxConfig.class, MultiTxManagerConfig.class);
assertThat(ctx.getBeansOfType(TransactionManager.class)).hasSize(2);
TransactionalTestBean bean = ctx.getBean(TransactionalTestBean.class);
CallCountingTransactionManager txManager = ctx.getBean("txManager", CallCountingTransactionManager.class);
CallCountingTransactionManager txManager2 = ctx.getBean("txManager2", CallCountingTransactionManager.class);
@ -126,6 +128,7 @@ public class EnableTransactionManagementTests {
public void txManagerIsResolvedCorrectlyWhenMultipleManagersArePresentAndOneIsPrimary() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
EnableTxConfig.class, PrimaryMultiTxManagerConfig.class);
assertThat(ctx.getBeansOfType(TransactionManager.class)).hasSize(2);
TransactionalTestBean bean = ctx.getBean(TransactionalTestBean.class);
CallCountingTransactionManager primary = ctx.getBean("primary", CallCountingTransactionManager.class);
CallCountingTransactionManager txManager2 = ctx.getBean("txManager2", CallCountingTransactionManager.class);
@ -147,6 +150,7 @@ public class EnableTransactionManagementTests {
public void txManagerIsResolvedCorrectlyWithTxMgmtConfigurerAndPrimaryPresent() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
EnableTxConfig.class, PrimaryTxManagerAndTxMgmtConfigurerConfig.class);
assertThat(ctx.getBeansOfType(TransactionManager.class)).hasSize(2);
TransactionalTestBean bean = ctx.getBean(TransactionalTestBean.class);
CallCountingTransactionManager primary = ctx.getBean("primary", CallCountingTransactionManager.class);
CallCountingTransactionManager annotationDriven = ctx.getBean("annotationDrivenTransactionManager", CallCountingTransactionManager.class);