From 65acda8d3e1b2355b7e693981d9c8d4aea6aef69 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 11 May 2020 12:26:13 +0200 Subject: [PATCH] Polishing --- .../annotation/EnableTransactionManagement.java | 4 ++-- .../transaction/interceptor/TransactionAspectSupport.java | 8 ++++---- .../annotation/EnableTransactionManagementTests.java | 4 ++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/spring-tx/src/main/java/org/springframework/transaction/annotation/EnableTransactionManagement.java b/spring-tx/src/main/java/org/springframework/transaction/annotation/EnableTransactionManagement.java index e5e23cd7d49..1f4a2db53ea 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/annotation/EnableTransactionManagement.java +++ b/spring-tx/src/main/java/org/springframework/transaction/annotation/EnableTransactionManagement.java @@ -85,14 +85,14 @@ import org.springframework.core.Ordered; * In both of the scenarios above, {@code @EnableTransactionManagement} and {@code * } 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. * *

A minor difference between the two examples lies in the naming of the {@code * TransactionManager} bean: In the {@code @Bean} case, the name is * "txManager" (per the name of the method); in the XML case, the name is - * "transactionManager". The {@code } is hard-wired to + * "transactionManager". {@code } 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 diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java index ebc56af8f10..8304e61f870 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java @@ -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 + *

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 default transaction manager to use to drive transactions. - * This can either be a traditional {@link PlatformTransactionManager} or a + *

This can either be a traditional {@link PlatformTransactionManager} or a * {@link ReactiveTransactionManager} for reactive transaction management. *

The default transaction manager will be used if a qualifier * 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 + *

This can either be a traditional {@link PlatformTransactionManager} or a * {@link ReactiveTransactionManager} for reactive transaction management. */ @Nullable diff --git a/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java b/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java index fd445526674..ddc6e0713c7 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java @@ -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);