|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.transaction.support.DefaultTransactionStatus
public class DefaultTransactionStatus
Default implementation of the TransactionStatus interface, used by AbstractPlatformTransactionManager.
Holds all status information that AbstractPlatformTransactionManager needs internally, including a generic transaction object determined by the concrete transaction manager implementation.
Supports delegating savepoint-related methods to a transaction object that implements the SavepointManager interface.
AbstractPlatformTransactionManager
,
SavepointManager
,
createSavepoint()
,
rollbackToSavepoint(java.lang.Object)
,
releaseSavepoint(java.lang.Object)
,
getTransaction()
Constructor Summary | |
---|---|
DefaultTransactionStatus(Object transaction,
boolean newTransaction,
boolean newSynchronization,
boolean readOnly,
boolean debug,
Object suspendedResources)
Create a new TransactionStatus instance. |
Method Summary | |
---|---|
void |
createAndHoldSavepoint()
Create a savepoint and hold it for the transaction. |
Object |
createSavepoint()
This implementation delegates to the transaction object if it implements the SavepointManager interface. |
Object |
getSavepoint()
Get the savepoint for this transaction, if any. |
protected SavepointManager |
getSavepointManager()
Return the underlying transaction as SavepointManager, if possible. |
Object |
getSuspendedResources()
Return the holder for resources that have been suspended for this transaction, if any. |
Object |
getTransaction()
Return the underlying transaction object. |
boolean |
hasSavepoint()
Return whether this transaction internally carries a savepoint, i.e. has been created as nested transaction based on a savepoint. |
boolean |
hasTransaction()
Return whether there is actual transaction active. |
boolean |
isCompleted()
Return whether this transaction is completed, that is, has already been committed or rolled back. |
boolean |
isDebug()
Return whether the progress of this transaction is debugged. |
boolean |
isGlobalRollbackOnly()
Determine the rollback-only flag via checking both the transaction object, provided that the latter implements the SmartTransactionObject interface. |
boolean |
isLocalRollbackOnly()
Determine the rollback-only flag via checking this TransactionStatus. |
boolean |
isNewSynchronization()
Return if a new transaction synchronization has been opened for this transaction. |
boolean |
isNewTransaction()
Return if the transaction is new, else participating in an existing transaction. |
boolean |
isReadOnly()
Return if this transaction is defined as read-only transaction. |
boolean |
isRollbackOnly()
Determine the rollback-only flag via checking both this TransactionStatus and the transaction object, provided that the latter implements the SmartTransactionObject interface. |
boolean |
isTransactionSavepointManager()
Return whether the underlying transaction implements the SavepointManager interface. |
void |
releaseHeldSavepoint()
Release the savepoint that is held for the transaction. |
void |
releaseSavepoint(Object savepoint)
This implementation delegates to the transaction object if it implements the SavepointManager interface. |
void |
rollbackToHeldSavepoint()
Roll back to the savepoint that is held for the transaction. |
void |
rollbackToSavepoint(Object savepoint)
This implementation delegates to the transaction object if it implements the SavepointManager interface. |
void |
setCompleted()
Mark this transaction as completed, that is, committed or rolled back. |
void |
setRollbackOnly()
Set the transaction rollback-only. |
protected void |
setSavepoint(Object savepoint)
Set a savepoint for this transaction. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultTransactionStatus(Object transaction, boolean newTransaction, boolean newSynchronization, boolean readOnly, boolean debug, Object suspendedResources)
transaction
- underlying transaction object that can hold
state for the internal transaction implementationnewTransaction
- if the transaction is new,
else participating in an existing transactionnewSynchronization
- if a new transaction synchronization
has been opened for the given transactionreadOnly
- whether the transaction is read-onlydebug
- 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.suspendedResources
- a holder for resources that have been suspended
for this transaction, if anyMethod Detail |
---|
public Object getTransaction()
public boolean hasTransaction()
public boolean isNewTransaction()
TransactionStatus
isNewTransaction
in interface TransactionStatus
public boolean isNewSynchronization()
public boolean isReadOnly()
public boolean isDebug()
public Object getSuspendedResources()
protected void setSavepoint(Object savepoint)
TransactionDefinition.PROPAGATION_NESTED
public Object getSavepoint()
public boolean hasSavepoint()
TransactionStatus
This method is mainly here for diagnostic purposes, alongside
isNewTransaction
. For programmatic handling of custom
savepoints, use SavepointManager's operations.
hasSavepoint
in interface TransactionStatus
TransactionStatus.isNewTransaction()
,
SavepointManager.createSavepoint()
,
SavepointManager.rollbackToSavepoint(Object)
,
SavepointManager.releaseSavepoint(Object)
public void setRollbackOnly()
TransactionStatus
For transactions managed by TransactionTemplate or TransactionInterceptor. An alternative way to trigger a rollback is throwing an application exception.
setRollbackOnly
in interface TransactionStatus
TransactionCallback.doInTransaction(org.springframework.transaction.TransactionStatus)
,
TransactionAttribute.rollbackOn(java.lang.Throwable)
public boolean isRollbackOnly()
isRollbackOnly
in interface TransactionStatus
SmartTransactionObject.isRollbackOnly()
public boolean isLocalRollbackOnly()
Will only return "true" if the application called setRollbackOnly
on this TransactionStatus object.
public boolean isGlobalRollbackOnly()
Will return "true" if the transaction itself has been marked rollback-only by the transaction coordinator, for example in case of a timeout.
SmartTransactionObject.isRollbackOnly()
public void setCompleted()
public boolean isCompleted()
TransactionStatus
isCompleted
in interface TransactionStatus
public Object createSavepoint() throws TransactionException
createSavepoint
in interface SavepointManager
NestedTransactionNotSupportedException
- if the underlying transaction does not support savepoints
TransactionException
- if the savepoint could not be created,
either because the backend does not support it or because the
transaction is not in an appropriate stategetTransaction()
,
SavepointManager
public void rollbackToSavepoint(Object savepoint) throws TransactionException
rollbackToSavepoint
in interface SavepointManager
savepoint
- the savepoint to roll back to
TransactionException
- if the rollback failedgetTransaction()
,
SavepointManager
public void releaseSavepoint(Object savepoint) throws TransactionException
releaseSavepoint
in interface SavepointManager
savepoint
- the savepoint to release
TransactionException
- if the release failedgetTransaction()
,
SavepointManager
public void createAndHoldSavepoint() throws TransactionException
NestedTransactionNotSupportedException
- if the underlying transaction does not support savepoints
TransactionException
public void rollbackToHeldSavepoint() throws TransactionException
TransactionException
public void releaseHeldSavepoint() throws TransactionException
TransactionException
protected SavepointManager getSavepointManager()
NestedTransactionNotSupportedException
- if the underlying transaction does not support savepointspublic boolean isTransactionSavepointManager()
getTransaction()
,
SavepointManager
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |