Merge pull request #24493 from chenqimiao-pr/AbstractPlatformTransactionManager
Closes gh-24493
This commit is contained in:
commit
8219d06ae1
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -370,12 +370,7 @@ public abstract class AbstractPlatformTransactionManager implements PlatformTran
|
||||||
logger.debug("Creating new transaction with name [" + def.getName() + "]: " + def);
|
logger.debug("Creating new transaction with name [" + def.getName() + "]: " + def);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
boolean newSynchronization = (getTransactionSynchronization() != SYNCHRONIZATION_NEVER);
|
return startTransaction(def, transaction, debugEnabled, suspendedResources);
|
||||||
DefaultTransactionStatus status = newTransactionStatus(
|
|
||||||
def, transaction, true, newSynchronization, debugEnabled, suspendedResources);
|
|
||||||
doBegin(transaction, def);
|
|
||||||
prepareSynchronization(status, def);
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
catch (RuntimeException | Error ex) {
|
catch (RuntimeException | Error ex) {
|
||||||
resume(null, suspendedResources);
|
resume(null, suspendedResources);
|
||||||
|
|
@ -393,6 +388,20 @@ public abstract class AbstractPlatformTransactionManager implements PlatformTran
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start a new transaction.
|
||||||
|
*/
|
||||||
|
private TransactionStatus startTransaction(TransactionDefinition definition, Object transaction,
|
||||||
|
boolean debugEnabled, @Nullable SuspendedResourcesHolder suspendedResources) {
|
||||||
|
|
||||||
|
boolean newSynchronization = (getTransactionSynchronization() != SYNCHRONIZATION_NEVER);
|
||||||
|
DefaultTransactionStatus status = newTransactionStatus(
|
||||||
|
definition, transaction, true, newSynchronization, debugEnabled, suspendedResources);
|
||||||
|
doBegin(transaction, definition);
|
||||||
|
prepareSynchronization(status, definition);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a TransactionStatus for an existing transaction.
|
* Create a TransactionStatus for an existing transaction.
|
||||||
*/
|
*/
|
||||||
|
|
@ -422,12 +431,7 @@ public abstract class AbstractPlatformTransactionManager implements PlatformTran
|
||||||
}
|
}
|
||||||
SuspendedResourcesHolder suspendedResources = suspend(transaction);
|
SuspendedResourcesHolder suspendedResources = suspend(transaction);
|
||||||
try {
|
try {
|
||||||
boolean newSynchronization = (getTransactionSynchronization() != SYNCHRONIZATION_NEVER);
|
return startTransaction(definition, transaction, debugEnabled, suspendedResources);
|
||||||
DefaultTransactionStatus status = newTransactionStatus(
|
|
||||||
definition, transaction, true, newSynchronization, debugEnabled, suspendedResources);
|
|
||||||
doBegin(transaction, definition);
|
|
||||||
prepareSynchronization(status, definition);
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
catch (RuntimeException | Error beginEx) {
|
catch (RuntimeException | Error beginEx) {
|
||||||
resumeAfterBeginException(transaction, suspendedResources, beginEx);
|
resumeAfterBeginException(transaction, suspendedResources, beginEx);
|
||||||
|
|
@ -457,12 +461,7 @@ public abstract class AbstractPlatformTransactionManager implements PlatformTran
|
||||||
// Nested transaction through nested begin and commit/rollback calls.
|
// Nested transaction through nested begin and commit/rollback calls.
|
||||||
// Usually only for JTA: Spring synchronization might get activated here
|
// Usually only for JTA: Spring synchronization might get activated here
|
||||||
// in case of a pre-existing JTA transaction.
|
// in case of a pre-existing JTA transaction.
|
||||||
boolean newSynchronization = (getTransactionSynchronization() != SYNCHRONIZATION_NEVER);
|
return startTransaction(definition, transaction, debugEnabled, null);
|
||||||
DefaultTransactionStatus status = newTransactionStatus(
|
|
||||||
definition, transaction, true, newSynchronization, debugEnabled, null);
|
|
||||||
doBegin(transaction, definition);
|
|
||||||
prepareSynchronization(status, definition);
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue