|
|
|
@ -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. |
|
|
|
@ -192,7 +192,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
@@ -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
@@ -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
@@ -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 |
|
|
|
@ -375,7 +375,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
@@ -375,7 +375,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
|
|
|
|
|
cleanupTransactionInfo(txInfo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (vavrPresent && VavrDelegate.isVavrTry(retVal)) { |
|
|
|
|
if (retVal != null && vavrPresent && VavrDelegate.isVavrTry(retVal)) { |
|
|
|
|
// Set rollback-only in case of Vavr failure matching our rollback rules...
|
|
|
|
|
TransactionStatus status = txInfo.getTransactionStatus(); |
|
|
|
|
if (status != null && txAttr != null) { |
|
|
|
@ -388,15 +388,16 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
@@ -388,15 +388,16 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
else { |
|
|
|
|
Object result; |
|
|
|
|
final ThrowableHolder throwableHolder = new ThrowableHolder(); |
|
|
|
|
|
|
|
|
|
// It's a CallbackPreferringPlatformTransactionManager: pass a TransactionCallback in.
|
|
|
|
|
try { |
|
|
|
|
Object result = ((CallbackPreferringPlatformTransactionManager) ptm).execute(txAttr, status -> { |
|
|
|
|
result = ((CallbackPreferringPlatformTransactionManager) ptm).execute(txAttr, status -> { |
|
|
|
|
TransactionInfo txInfo = prepareTransactionInfo(ptm, txAttr, joinpointIdentification, status); |
|
|
|
|
try { |
|
|
|
|
Object retVal = invocation.proceedWithInvocation(); |
|
|
|
|
if (vavrPresent && VavrDelegate.isVavrTry(retVal)) { |
|
|
|
|
if (retVal != null && vavrPresent && VavrDelegate.isVavrTry(retVal)) { |
|
|
|
|
// Set rollback-only in case of Vavr failure matching our rollback rules...
|
|
|
|
|
retVal = VavrDelegate.evaluateTryFailure(retVal, txAttr, status); |
|
|
|
|
} |
|
|
|
@ -422,12 +423,6 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
@@ -422,12 +423,6 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
|
|
|
|
|
cleanupTransactionInfo(txInfo); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Check result state: It might indicate a Throwable to rethrow.
|
|
|
|
|
if (throwableHolder.throwable != null) { |
|
|
|
|
throw throwableHolder.throwable; |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
catch (ThrowableHolderException ex) { |
|
|
|
|
throw ex.getCause(); |
|
|
|
@ -445,11 +440,17 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
@@ -445,11 +440,17 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
|
|
|
|
|
} |
|
|
|
|
throw ex2; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Check result state: It might indicate a Throwable to rethrow.
|
|
|
|
|
if (throwableHolder.throwable != null) { |
|
|
|
|
throw throwableHolder.throwable; |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Clear the cache. |
|
|
|
|
* Clear the transaction manager cache. |
|
|
|
|
*/ |
|
|
|
|
protected void clearTransactionManagerCache() { |
|
|
|
|
this.transactionManagerCache.clear(); |
|
|
|
@ -780,6 +781,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
@@ -780,6 +781,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
|
|
|
|
|
@FunctionalInterface |
|
|
|
|
protected interface InvocationCallback { |
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
|
Object proceedWithInvocation() throws Throwable; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|