Merge branch '6.0.x'

# Conflicts:
#	spring-context/spring-context.gradle
#	spring-context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java
#	spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java
#	spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringBeanContainer.java
#	spring-test/spring-test.gradle
#	spring-webmvc/spring-webmvc.gradle
This commit is contained in:
Juergen Hoeller
2023-08-02 00:16:55 +02:00
10 changed files with 61 additions and 44 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 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.
@@ -46,10 +46,10 @@ public abstract class TransactionContextManager {
* transactional context holder. Context retrieval fails with NoTransactionException
* if no context or context holder is registered.
* @return the current {@link TransactionContext}
* @throws NoTransactionException if no TransactionContext was found in the subscriber context
* or no context found in a holder
* @throws NoTransactionException if no TransactionContext was found in the
* subscriber context or no context found in a holder
*/
public static Mono<TransactionContext> currentContext() throws NoTransactionException {
public static Mono<TransactionContext> currentContext() {
return Mono.deferContextual(ctx -> {
if (ctx.hasKey(TransactionContext.class)) {
return Mono.just(ctx.get(TransactionContext.class));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 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.
@@ -32,8 +32,8 @@ import org.springframework.util.Assert;
/**
* Central delegate that manages resources and transaction synchronizations per
* subscriber context.
* To be used by resource management code but not by typical application code.
* subscriber context. To be used by resource management code but not by typical
* application code.
*
* <p>Supports one resource per key without overwriting, that is, a resource needs
* to be removed before a new one can be set for the same key.
@@ -73,6 +73,7 @@ public class TransactionSynchronizationManager {
public TransactionSynchronizationManager(TransactionContext transactionContext) {
Assert.notNull(transactionContext, "TransactionContext must not be null");
this.transactionContext = transactionContext;
}
@@ -88,10 +89,11 @@ public class TransactionSynchronizationManager {
return TransactionContextManager.currentContext().map(TransactionSynchronizationManager::new);
}
/**
* Check if there is a resource for the given key bound to the current thread.
* Check if there is a resource for the given key bound to the current context.
* @param key the key to check (usually the resource factory)
* @return if there is a value bound to the current thread
* @return if there is a value bound to the current context
*/
public boolean hasResource(Object key) {
Object actualKey = TransactionSynchronizationUtils.unwrapResourceIfNecessary(key);
@@ -100,9 +102,9 @@ public class TransactionSynchronizationManager {
}
/**
* Retrieve a resource for the given key that is bound to the current thread.
* Retrieve a resource for the given key that is bound to the current context.
* @param key the key to check (usually the resource factory)
* @return a value bound to the current thread (usually the active
* @return a value bound to the current context (usually the active
* resource object), or {@code null} if none
*/
@Nullable