Browse Source

Update Javadoc regarding reactive tx mgmt support

See gh-25030
pull/25038/head
Sam Brannen 5 years ago
parent
commit
0f22a5e409
  1. 7
      spring-tx/src/main/java/org/springframework/transaction/PlatformTransactionManager.java
  2. 5
      spring-tx/src/main/java/org/springframework/transaction/ReactiveTransactionManager.java
  3. 19
      spring-tx/src/main/java/org/springframework/transaction/annotation/EnableTransactionManagement.java
  4. 10
      spring-tx/src/main/java/org/springframework/transaction/annotation/Transactional.java
  5. 11
      spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java
  6. 6
      src/docs/asciidoc/data-access.adoc

7
spring-tx/src/main/java/org/springframework/transaction/PlatformTransactionManager.java

@ -1,5 +1,5 @@ @@ -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.
@ -19,8 +19,8 @@ package org.springframework.transaction; @@ -19,8 +19,8 @@ package org.springframework.transaction;
import org.springframework.lang.Nullable;
/**
* This is the central interface in Spring's transaction infrastructure.
* Applications can use this directly, but it is not primarily meant as API:
* This is the central interface in Spring's imperative transaction infrastructure.
* Applications can use this directly, but it is not primarily meant as an API:
* Typically, applications will work with either TransactionTemplate or
* declarative transaction demarcation through AOP.
*
@ -41,6 +41,7 @@ import org.springframework.lang.Nullable; @@ -41,6 +41,7 @@ import org.springframework.lang.Nullable;
* @since 16.05.2003
* @see org.springframework.transaction.support.TransactionTemplate
* @see org.springframework.transaction.interceptor.TransactionInterceptor
* @see org.springframework.transaction.ReactiveTransactionManager
*/
public interface PlatformTransactionManager extends TransactionManager {

5
spring-tx/src/main/java/org/springframework/transaction/ReactiveTransactionManager.java

@ -1,5 +1,5 @@ @@ -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.
@ -22,7 +22,7 @@ import org.springframework.lang.Nullable; @@ -22,7 +22,7 @@ import org.springframework.lang.Nullable;
/**
* This is the central interface in Spring's reactive transaction infrastructure.
* Applications can use this directly, but it is not primarily meant as API:
* Applications can use this directly, but it is not primarily meant as an API:
* Typically, applications will work with either transactional operators or
* declarative transaction demarcation through AOP.
*
@ -31,6 +31,7 @@ import org.springframework.lang.Nullable; @@ -31,6 +31,7 @@ import org.springframework.lang.Nullable;
* @since 5.2
* @see org.springframework.transaction.reactive.TransactionalOperator
* @see org.springframework.transaction.interceptor.TransactionInterceptor
* @see org.springframework.transaction.PlatformTransactionManager
*/
public interface ReactiveTransactionManager extends TransactionManager {

19
spring-tx/src/main/java/org/springframework/transaction/annotation/EnableTransactionManagement.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 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.
@ -30,7 +30,14 @@ import org.springframework.core.Ordered; @@ -30,7 +30,14 @@ import org.springframework.core.Ordered;
* Enables Spring's annotation-driven transaction management capability, similar to
* the support found in Spring's {@code <tx:*>} XML namespace. To be used on
* {@link org.springframework.context.annotation.Configuration @Configuration}
* classes as follows:
* classes to configure traditional, imperative transaction management or
* reactive transaction management.
*
* <p>The following example demonstrates imperative transaction management
* using a {@link org.springframework.transaction.PlatformTransactionManager
* PlatformTransactionManager}. For reactive transaction management, configure a
* {@link org.springframework.transaction.ReactiveTransactionManager
* ReactiveTransactionManager} instead.
*
* <pre class="code">
* &#064;Configuration
@ -83,12 +90,12 @@ import org.springframework.core.Ordered; @@ -83,12 +90,12 @@ import org.springframework.core.Ordered;
* methods are invoked.
*
* <p>A minor difference between the two examples lies in the naming of the {@code
* PlatformTransactionManager} bean: In the {@code @Bean} case, the name is
* 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
* 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 PlatformTransactionManager} bean in the container. Thus the name
* lookup for any {@code TransactionManager} bean in the container. Thus the name
* can be "txManager", "transactionManager", or "tm": it simply does not matter.
*
* <p>For those that wish to establish a more direct relationship between
@ -123,8 +130,8 @@ import org.springframework.core.Ordered; @@ -123,8 +130,8 @@ import org.springframework.core.Ordered;
* }
* }</pre>
*
* This approach may be desirable simply because it is more explicit, or it may be
* necessary in order to distinguish between two {@code PlatformTransactionManager} beans
* <p>This approach may be desirable simply because it is more explicit, or it may be
* necessary in order to distinguish between two {@code TransactionManager} beans
* present in the same container. As the name suggests, the
* {@code annotationDrivenTransactionManager()} will be the one used for processing
* {@code @Transactional} methods. See {@link TransactionManagementConfigurer} Javadoc

10
spring-tx/src/main/java/org/springframework/transaction/annotation/Transactional.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 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.
@ -71,12 +71,14 @@ public @interface Transactional { @@ -71,12 +71,14 @@ public @interface Transactional {
/**
* A <em>qualifier</em> value for the specified transaction.
* <p>May be used to determine the target transaction manager,
* matching the qualifier value (or the bean name) of a specific
* {@link org.springframework.transaction.PlatformTransactionManager}
* <p>May be used to determine the target transaction manager, matching the
* qualifier value (or the bean name) of a specific
* {@link org.springframework.transaction.TransactionManager TransactionManager}
* bean definition.
* @since 4.2
* @see #value
* @see org.springframework.transaction.PlatformTransactionManager
* @see org.springframework.transaction.ReactiveTransactionManager
*/
@AliasFor("value")
String transactionManager() default "";

11
spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java

@ -70,8 +70,8 @@ import org.springframework.util.StringUtils; @@ -70,8 +70,8 @@ import org.springframework.util.StringUtils;
* management, and a {@link TransactionAttributeSource} (e.g. annotation-based) is used
* for determining transaction definitions for a particular class or method.
*
* <p>A transaction aspect is serializable if its {@code PlatformTransactionManager}
* and {@code TransactionAttributeSource} are serializable.
* <p>A transaction aspect is serializable if its {@code TransactionManager} and
* {@code TransactionAttributeSource} are serializable.
*
* @author Rod Johnson
* @author Juergen Hoeller
@ -282,7 +282,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init @@ -282,7 +282,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
}
/**
* Set the BeanFactory to use for retrieving PlatformTransactionManager beans.
* Set the BeanFactory to use for retrieving {@code TransactionManager} beans.
*/
@Override
public void setBeanFactory(@Nullable BeanFactory beanFactory) {
@ -290,7 +290,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init @@ -290,7 +290,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
}
/**
* Return the BeanFactory to use for retrieving PlatformTransactionManager beans.
* Return the BeanFactory to use for retrieving {@code TransactionManager} beans.
*/
@Nullable
protected final BeanFactory getBeanFactory() {
@ -318,7 +318,8 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init @@ -318,7 +318,8 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
/**
* General delegate for around-advice-based subclasses, delegating to several other template
* methods on this class. Able to handle {@link CallbackPreferringPlatformTransactionManager}
* as well as regular {@link PlatformTransactionManager} implementations.
* as well as regular {@link PlatformTransactionManager} implementations and
* {@link ReactiveTransactionManager} implementations for reactive return types.
* @param method the Method being invoked
* @param targetClass the target class that we're invoking the method on
* @param invocation the callback to use for proceeding with the target invocation

6
src/docs/asciidoc/data-access.adoc

@ -1160,7 +1160,7 @@ the default transactional configuration, you could write the following: @@ -1160,7 +1160,7 @@ the default transactional configuration, you could write the following:
</tx:attributes>
</tx:advice>
<!-- other transaction infrastructure beans such as a PlatformTransactionManager omitted... -->
<!-- other transaction infrastructure beans such as a TransactionManager omitted... -->
</beans>
----
@ -1216,7 +1216,7 @@ transactional settings: @@ -1216,7 +1216,7 @@ transactional settings:
</tx:attributes>
</tx:advice>
<!-- other transaction infrastructure beans such as a PlatformTransactionManager omitted... -->
<!-- other transaction infrastructure beans such as a TransactionManager omitted... -->
</beans>
----
@ -1385,7 +1385,7 @@ In XML configuration, the `<tx:annotation-driven/>` tag provides similar conveni @@ -1385,7 +1385,7 @@ In XML configuration, the `<tx:annotation-driven/>` tag provides similar conveni
<bean id="fooService" class="x.y.service.DefaultFooService"/>
<!-- enable the configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="txManager"/><!-- a PlatformTransactionManager is still required --> <1>
<tx:annotation-driven transaction-manager="txManager"/><!-- a TransactionManager is still required --> <1>
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!-- (this dependency is defined somewhere else) -->

Loading…
Cancel
Save