|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2017 the original author or authors. |
|
|
|
* Copyright 2002-2018 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. |
|
|
|
@ -66,14 +66,14 @@ public class DefaultTransactionStatus extends AbstractTransactionStatus { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new DefaultTransactionStatus instance. |
|
|
|
* Create a new {@code DefaultTransactionStatus} instance. |
|
|
|
* @param transaction underlying transaction object that can hold |
|
|
|
* @param transaction underlying transaction object that can hold state |
|
|
|
* state for the internal transaction implementation |
|
|
|
* for the internal transaction implementation |
|
|
|
* @param newTransaction if the transaction is new, |
|
|
|
* @param newTransaction if the transaction is new, otherwise participating |
|
|
|
* else participating in an existing transaction |
|
|
|
* in an existing transaction |
|
|
|
* @param newSynchronization if a new transaction synchronization |
|
|
|
* @param newSynchronization if a new transaction synchronization has been |
|
|
|
* has been opened for the given transaction |
|
|
|
* opened for the given transaction |
|
|
|
* @param readOnly whether the transaction is read-only |
|
|
|
* @param readOnly whether the transaction is marked as read-only |
|
|
|
* @param debug should debug logging be enabled for the handling of this transaction? |
|
|
|
* @param debug should debug logging be enabled for the handling of this transaction? |
|
|
|
* Caching it in here can prevent repeated calls to ask the logging system whether |
|
|
|
* Caching it in here can prevent repeated calls to ask the logging system whether |
|
|
|
* debug logging should be enabled. |
|
|
|
* debug logging should be enabled. |
|
|
|
@ -130,9 +130,9 @@ public class DefaultTransactionStatus extends AbstractTransactionStatus { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return whether the progress of this transaction is debugged. This is used |
|
|
|
* Return whether the progress of this transaction is debugged. This is used by |
|
|
|
* by AbstractPlatformTransactionManager as an optimization, to prevent repeated |
|
|
|
* {@link AbstractPlatformTransactionManager} as an optimization, to prevent repeated |
|
|
|
* calls to logger.isDebug(). Not really intended for client code. |
|
|
|
* calls to {@code logger.isDebugEnabled()}. Not really intended for client code. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean isDebug() { |
|
|
|
public boolean isDebug() { |
|
|
|
return this.debug; |
|
|
|
return this.debug; |
|
|
|
@ -153,11 +153,11 @@ public class DefaultTransactionStatus extends AbstractTransactionStatus { |
|
|
|
//---------------------------------------------------------------------
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Determine the rollback-only flag via checking both the transaction object, |
|
|
|
* Determine the rollback-only flag via checking the transaction object, provided |
|
|
|
* provided that the latter implements the {@link SmartTransactionObject} interface. |
|
|
|
* that the latter implements the {@link SmartTransactionObject} interface. |
|
|
|
* <p>Will return "true" if the transaction itself has been marked rollback-only |
|
|
|
* <p>Will return {@code true} if the global transaction itself has been marked |
|
|
|
* by the transaction coordinator, for example in case of a timeout. |
|
|
|
* rollback-only by the transaction coordinator, for example in case of a timeout. |
|
|
|
* @see SmartTransactionObject#isRollbackOnly |
|
|
|
* @see SmartTransactionObject#isRollbackOnly() |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean isGlobalRollbackOnly() { |
|
|
|
public boolean isGlobalRollbackOnly() { |
|
|
|
@ -166,8 +166,9 @@ public class DefaultTransactionStatus extends AbstractTransactionStatus { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Delegate the flushing to the transaction object, |
|
|
|
* Delegate the flushing to the transaction object, provided that the latter |
|
|
|
* provided that the latter implements the {@link SmartTransactionObject} interface. |
|
|
|
* implements the {@link SmartTransactionObject} interface. |
|
|
|
|
|
|
|
* @see SmartTransactionObject#flush() |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void flush() { |
|
|
|
public void flush() { |
|
|
|
@ -177,24 +178,26 @@ public class DefaultTransactionStatus extends AbstractTransactionStatus { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* This implementation exposes the SavepointManager interface
|
|
|
|
* This implementation exposes the {@link SavepointManager} interface
|
|
|
|
* of the underlying transaction object, if any. |
|
|
|
* of the underlying transaction object, if any. |
|
|
|
|
|
|
|
* @throws NestedTransactionNotSupportedException if savepoints are not supported |
|
|
|
|
|
|
|
* @see #isTransactionSavepointManager() |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected SavepointManager getSavepointManager() { |
|
|
|
protected SavepointManager getSavepointManager() { |
|
|
|
Object transaction = this.transaction; |
|
|
|
Object transaction = this.transaction; |
|
|
|
if (!(transaction instanceof SavepointManager)) { |
|
|
|
if (!(transaction instanceof SavepointManager)) { |
|
|
|
throw new NestedTransactionNotSupportedException( |
|
|
|
throw new NestedTransactionNotSupportedException( |
|
|
|
"Transaction object [" + this.transaction + "] does not support savepoints"); |
|
|
|
"Transaction object [" + this.transaction + "] does not support savepoints"); |
|
|
|
} |
|
|
|
} |
|
|
|
return (SavepointManager) transaction; |
|
|
|
return (SavepointManager) transaction; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return whether the underlying transaction implements the |
|
|
|
* Return whether the underlying transaction implements the {@link SavepointManager} |
|
|
|
* SavepointManager interface. |
|
|
|
* interface and therefore supports savepoints. |
|
|
|
* @see #getTransaction |
|
|
|
* @see #getTransaction() |
|
|
|
* @see org.springframework.transaction.SavepointManager |
|
|
|
* @see #getSavepointManager() |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean isTransactionSavepointManager() { |
|
|
|
public boolean isTransactionSavepointManager() { |
|
|
|
return (this.transaction instanceof SavepointManager); |
|
|
|
return (this.transaction instanceof SavepointManager); |
|
|
|
|