Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -25,7 +25,7 @@ import java.io.Flushable;
|
||||
* and to programmatically request a rollback (instead of throwing
|
||||
* an exception that causes an implicit rollback).
|
||||
*
|
||||
* <p>Derives from the SavepointManager interface to provide access
|
||||
* <p>Includes the {@link SavepointManager} interface to provide access
|
||||
* to savepoint management facilities. Note that savepoint management
|
||||
* is only available if supported by the underlying transaction manager.
|
||||
*
|
||||
@@ -39,9 +39,9 @@ import java.io.Flushable;
|
||||
public interface TransactionStatus extends SavepointManager, Flushable {
|
||||
|
||||
/**
|
||||
* Return whether the present transaction is new (else participating
|
||||
* in an existing transaction, or potentially not running in an
|
||||
* actual transaction in the first place).
|
||||
* Return whether the present transaction is new; otherwise participating
|
||||
* in an existing transaction, or potentially not running in an actual
|
||||
* transaction in the first place.
|
||||
*/
|
||||
boolean isNewTransaction();
|
||||
|
||||
@@ -50,9 +50,9 @@ public interface TransactionStatus extends SavepointManager, Flushable {
|
||||
* that is, has been created as nested transaction based on a savepoint.
|
||||
* <p>This method is mainly here for diagnostic purposes, alongside
|
||||
* {@link #isNewTransaction()}. For programmatic handling of custom
|
||||
* savepoints, use SavepointManager's operations.
|
||||
* savepoints, use the operations provided by {@link SavepointManager}.
|
||||
* @see #isNewTransaction()
|
||||
* @see #createSavepoint
|
||||
* @see #createSavepoint()
|
||||
* @see #rollbackToSavepoint(Object)
|
||||
* @see #releaseSavepoint(Object)
|
||||
*/
|
||||
|
||||
@@ -66,14 +66,14 @@ public class DefaultTransactionStatus extends AbstractTransactionStatus {
|
||||
|
||||
|
||||
/**
|
||||
* Create a new DefaultTransactionStatus instance.
|
||||
* @param transaction underlying transaction object that can hold
|
||||
* state for the internal transaction implementation
|
||||
* @param newTransaction if the transaction is new,
|
||||
* else participating in an existing transaction
|
||||
* @param newSynchronization if a new transaction synchronization
|
||||
* has been opened for the given transaction
|
||||
* @param readOnly whether the transaction is read-only
|
||||
* Create a new {@code DefaultTransactionStatus} instance.
|
||||
* @param transaction underlying transaction object that can hold state
|
||||
* for the internal transaction implementation
|
||||
* @param newTransaction if the transaction is new, otherwise participating
|
||||
* in an existing transaction
|
||||
* @param newSynchronization if a new transaction synchronization has been
|
||||
* opened for the given transaction
|
||||
* @param readOnly whether the transaction is marked as read-only
|
||||
* @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
|
||||
* 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
|
||||
* by AbstractPlatformTransactionManager as an optimization, to prevent repeated
|
||||
* calls to {@code logger.isDebug()}. Not really intended for client code.
|
||||
* Return whether the progress of this transaction is debugged. This is used by
|
||||
* {@link AbstractPlatformTransactionManager} as an optimization, to prevent repeated
|
||||
* calls to {@code logger.isDebugEnabled()}. Not really intended for client code.
|
||||
*/
|
||||
public boolean isDebug() {
|
||||
return this.debug;
|
||||
@@ -153,11 +153,11 @@ public class DefaultTransactionStatus extends AbstractTransactionStatus {
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Determine the rollback-only flag via checking both the transaction object,
|
||||
* provided that the latter implements the {@link SmartTransactionObject} interface.
|
||||
* <p>Will return "true" if the transaction itself has been marked rollback-only
|
||||
* by the transaction coordinator, for example in case of a timeout.
|
||||
* @see SmartTransactionObject#isRollbackOnly
|
||||
* Determine the rollback-only flag via checking the transaction object, provided
|
||||
* that the latter implements the {@link SmartTransactionObject} interface.
|
||||
* <p>Will return {@code true} if the global transaction itself has been marked
|
||||
* rollback-only by the transaction coordinator, for example in case of a timeout.
|
||||
* @see SmartTransactionObject#isRollbackOnly()
|
||||
*/
|
||||
@Override
|
||||
public boolean isGlobalRollbackOnly() {
|
||||
@@ -166,8 +166,9 @@ public class DefaultTransactionStatus extends AbstractTransactionStatus {
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegate the flushing to the transaction object,
|
||||
* provided that the latter implements the {@link SmartTransactionObject} interface.
|
||||
* Delegate the flushing to the transaction object, provided that the latter
|
||||
* implements the {@link SmartTransactionObject} interface.
|
||||
* @see SmartTransactionObject#flush()
|
||||
*/
|
||||
@Override
|
||||
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.
|
||||
* @throws NestedTransactionNotSupportedException if savepoints are not supported
|
||||
* @see #isTransactionSavepointManager()
|
||||
*/
|
||||
@Override
|
||||
protected SavepointManager getSavepointManager() {
|
||||
Object transaction = this.transaction;
|
||||
if (!(transaction instanceof SavepointManager)) {
|
||||
throw new NestedTransactionNotSupportedException(
|
||||
"Transaction object [" + this.transaction + "] does not support savepoints");
|
||||
"Transaction object [" + this.transaction + "] does not support savepoints");
|
||||
}
|
||||
return (SavepointManager) transaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the underlying transaction implements the
|
||||
* SavepointManager interface.
|
||||
* @see #getTransaction
|
||||
* @see org.springframework.transaction.SavepointManager
|
||||
* Return whether the underlying transaction implements the {@link SavepointManager}
|
||||
* interface and therefore supports savepoints.
|
||||
* @see #getTransaction()
|
||||
* @see #getSavepointManager()
|
||||
*/
|
||||
public boolean isTransactionSavepointManager() {
|
||||
return (this.transaction instanceof SavepointManager);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -18,10 +18,8 @@ package org.springframework.transaction.support;
|
||||
|
||||
/**
|
||||
* A simple {@link org.springframework.transaction.TransactionStatus}
|
||||
* implementation.
|
||||
*
|
||||
* <p>Derives from {@link AbstractTransactionStatus} and adds an explicit
|
||||
* {@link #isNewTransaction() "newTransaction"} flag.
|
||||
* implementation. Derives from {@link AbstractTransactionStatus} and
|
||||
* adds an explicit {@link #isNewTransaction() "newTransaction"} flag.
|
||||
*
|
||||
* <p>This class is not used by any of Spring's pre-built
|
||||
* {@link org.springframework.transaction.PlatformTransactionManager}
|
||||
@@ -32,8 +30,7 @@ package org.springframework.transaction.support;
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 1.2.3
|
||||
* @see #SimpleTransactionStatus(boolean)
|
||||
* @see TransactionCallback
|
||||
* @see TransactionCallback#doInTransaction
|
||||
*/
|
||||
public class SimpleTransactionStatus extends AbstractTransactionStatus {
|
||||
|
||||
@@ -41,7 +38,7 @@ public class SimpleTransactionStatus extends AbstractTransactionStatus {
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@link SimpleTransactionStatus} class,
|
||||
* Create a new {@code SimpleTransactionStatus} instance,
|
||||
* indicating a new transaction.
|
||||
*/
|
||||
public SimpleTransactionStatus() {
|
||||
@@ -49,7 +46,7 @@ public class SimpleTransactionStatus extends AbstractTransactionStatus {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of the {@link SimpleTransactionStatus} class.
|
||||
* Create a new {@code SimpleTransactionStatus} instance.
|
||||
* @param newTransaction whether to indicate a new transaction
|
||||
*/
|
||||
public SimpleTransactionStatus(boolean newTransaction) {
|
||||
|
||||
Reference in New Issue
Block a user