Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -41,7 +41,6 @@ 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.interceptor.TransactionProxyFactoryBean
|
||||
*/
|
||||
public interface PlatformTransactionManager {
|
||||
|
||||
@@ -56,7 +55,7 @@ public interface PlatformTransactionManager {
|
||||
* <p>An exception to the above rule is the read-only flag, which should be
|
||||
* ignored if no explicit read-only mode is supported. Essentially, the
|
||||
* read-only flag is just a hint for potential optimization.
|
||||
* @param definition TransactionDefinition instance (can be {@code null} for defaults),
|
||||
* @param definition the TransactionDefinition instance (can be {@code null} for defaults),
|
||||
* describing propagation behavior, isolation level, timeout etc.
|
||||
* @return transaction status object representing the new or current transaction
|
||||
* @throws TransactionException in case of lookup, creation, or system errors
|
||||
@@ -68,7 +67,8 @@ public interface PlatformTransactionManager {
|
||||
* @see TransactionDefinition#getTimeout
|
||||
* @see TransactionDefinition#isReadOnly
|
||||
*/
|
||||
TransactionStatus getTransaction(@Nullable TransactionDefinition definition) throws TransactionException;
|
||||
TransactionStatus getTransaction(@Nullable TransactionDefinition definition)
|
||||
throws TransactionException;
|
||||
|
||||
/**
|
||||
* Commit the given transaction, with regard to its status. If the transaction
|
||||
|
||||
@@ -87,11 +87,11 @@ public enum Propagation {
|
||||
|
||||
/**
|
||||
* Execute within a nested transaction if a current transaction exists,
|
||||
* behave like {@code REQUIRED} else. There is no analogous feature in EJB.
|
||||
* behave like {@code REQUIRED} otherwise. There is no analogous feature in EJB.
|
||||
* <p>Note: Actual creation of a nested transaction will only work on specific
|
||||
* transaction managers. Out of the box, this only applies to the JDBC
|
||||
* DataSourceTransactionManager when working on a JDBC 3.0 driver.
|
||||
* Some JTA providers might support nested transactions as well.
|
||||
* DataSourceTransactionManager. Some JTA providers might support nested
|
||||
* transactions as well.
|
||||
* @see org.springframework.jdbc.datasource.DataSourceTransactionManager
|
||||
*/
|
||||
NESTED(TransactionDefinition.PROPAGATION_NESTED);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -101,7 +101,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
|
||||
* <p>To find out about specific transaction characteristics, consider using
|
||||
* TransactionSynchronizationManager's {@code isSynchronizationActive()}
|
||||
* and/or {@code isActualTransactionActive()} methods.
|
||||
* @return TransactionInfo bound to this thread, or {@code null} if none
|
||||
* @return the TransactionInfo bound to this thread, or {@code null} if none
|
||||
* @see TransactionInfo#hasTransaction()
|
||||
* @see org.springframework.transaction.support.TransactionSynchronizationManager#isSynchronizationActive()
|
||||
* @see org.springframework.transaction.support.TransactionSynchronizationManager#isActualTransactionActive()
|
||||
@@ -287,7 +287,8 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
|
||||
if (txAttr == null || !(tm instanceof CallbackPreferringPlatformTransactionManager)) {
|
||||
// Standard transaction demarcation with getTransaction and commit/rollback calls.
|
||||
TransactionInfo txInfo = createTransactionIfNecessary(tm, txAttr, joinpointIdentification);
|
||||
Object retVal = null;
|
||||
|
||||
Object retVal;
|
||||
try {
|
||||
// This is an around advice: Invoke the next interceptor in the chain.
|
||||
// This will normally result in a target object being invoked.
|
||||
@@ -507,9 +508,10 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
|
||||
else {
|
||||
// The TransactionInfo.hasTransaction() method will return false. We created it only
|
||||
// to preserve the integrity of the ThreadLocal stack maintained in this class.
|
||||
if (logger.isTraceEnabled())
|
||||
logger.trace("Don't need to create transaction for [" + joinpointIdentification +
|
||||
"]: This method isn't transactional.");
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("No need to create transaction for [" + joinpointIdentification +
|
||||
"]: This method is not transactional.");
|
||||
}
|
||||
}
|
||||
|
||||
// We always bind the TransactionInfo to the thread, even if we didn't create
|
||||
@@ -591,7 +593,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
|
||||
|
||||
|
||||
/**
|
||||
* Opaque object used to hold Transaction information. Subclasses
|
||||
* Opaque object used to hold transaction information. Subclasses
|
||||
* must pass it back to methods on this class, but not see its internals.
|
||||
*/
|
||||
protected final class TransactionInfo {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -553,7 +553,7 @@ public abstract class AbstractPlatformTransactionManager implements PlatformTran
|
||||
if (definition.getTimeout() != TransactionDefinition.TIMEOUT_DEFAULT) {
|
||||
return definition.getTimeout();
|
||||
}
|
||||
return this.defaultTimeout;
|
||||
return getDefaultTimeout();
|
||||
}
|
||||
|
||||
|
||||
@@ -667,7 +667,7 @@ public abstract class AbstractPlatformTransactionManager implements PlatformTran
|
||||
/**
|
||||
* Reactivate transaction synchronization for the current thread
|
||||
* and resume all given synchronizations.
|
||||
* @param suspendedSynchronizations List of TransactionSynchronization objects
|
||||
* @param suspendedSynchronizations a List of TransactionSynchronization objects
|
||||
*/
|
||||
private void doResumeSynchronization(List<TransactionSynchronization> suspendedSynchronizations) {
|
||||
TransactionSynchronizationManager.initSynchronization();
|
||||
@@ -980,7 +980,7 @@ public abstract class AbstractPlatformTransactionManager implements PlatformTran
|
||||
* given Spring TransactionSynchronization objects.
|
||||
* <p>To be called by this abstract manager itself, or by special implementations
|
||||
* of the {@code registerAfterCompletionWithExistingTransaction} callback.
|
||||
* @param synchronizations List of TransactionSynchronization objects
|
||||
* @param synchronizations a List of TransactionSynchronization objects
|
||||
* @param completionStatus the completion status according to the
|
||||
* constants in the TransactionSynchronization interface
|
||||
* @see #registerAfterCompletionWithExistingTransaction(Object, java.util.List)
|
||||
@@ -1096,9 +1096,11 @@ public abstract class AbstractPlatformTransactionManager implements PlatformTran
|
||||
* there will be an active transaction: The implementation of this method has
|
||||
* to detect this and start an appropriate nested transaction.
|
||||
* @param transaction transaction object returned by {@code doGetTransaction}
|
||||
* @param definition TransactionDefinition instance, describing propagation
|
||||
* @param definition a TransactionDefinition instance, describing propagation
|
||||
* behavior, isolation level, read-only flag, timeout, and transaction name
|
||||
* @throws TransactionException in case of creation or system errors
|
||||
* @throws org.springframework.transaction.NestedTransactionNotSupportedException
|
||||
* if the underlying transaction does not support nesting
|
||||
*/
|
||||
protected abstract void doBegin(Object transaction, TransactionDefinition definition)
|
||||
throws TransactionException;
|
||||
@@ -1231,7 +1233,7 @@ public abstract class AbstractPlatformTransactionManager implements PlatformTran
|
||||
* immediately, passing in "STATUS_UNKNOWN". This is the best we can do if there's no
|
||||
* chance to determine the actual outcome of the outer transaction.
|
||||
* @param transaction transaction object returned by {@code doGetTransaction}
|
||||
* @param synchronizations List of TransactionSynchronization objects
|
||||
* @param synchronizations a List of TransactionSynchronization objects
|
||||
* @throws TransactionException in case of system errors
|
||||
* @see #invokeAfterCompletion(java.util.List, int)
|
||||
* @see TransactionSynchronization#afterCompletion(int)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -292,10 +292,11 @@ public abstract class TransactionSynchronizationManager {
|
||||
throws IllegalStateException {
|
||||
|
||||
Assert.notNull(synchronization, "TransactionSynchronization must not be null");
|
||||
if (!isSynchronizationActive()) {
|
||||
Set<TransactionSynchronization> synchs = synchronizations.get();
|
||||
if (synchs == null) {
|
||||
throw new IllegalStateException("Transaction synchronization is not active");
|
||||
}
|
||||
synchronizations.get().add(synchronization);
|
||||
synchs.add(synchronization);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user