Class SpringLobCreatorSynchronization
- java.lang.Object
- org.springframework.transaction.support.TransactionSynchronizationAdapter
- org.springframework.jdbc.support.lob.SpringLobCreatorSynchronization
- All Implemented Interfaces:
Flushable
,Ordered
,TransactionSynchronization
public class SpringLobCreatorSynchronization extends TransactionSynchronizationAdapter
Callback for resource cleanup at the end of a Spring transaction. InvokesLobCreator.close()
to clean up temporary LOBs that might have been created.- Since:
- 2.0
- Author:
- Juergen Hoeller
- See Also:
LobCreator.close()
Field Summary
Fields Modifier and Type Field Description static int
LOB_CREATOR_SYNCHRONIZATION_ORDER
Order value for TransactionSynchronization objects that clean up LobCreators.Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Fields inherited from interface org.springframework.transaction.support.TransactionSynchronization
STATUS_COMMITTED, STATUS_ROLLED_BACK, STATUS_UNKNOWN
Constructor Summary
Constructors Constructor Description SpringLobCreatorSynchronization(LobCreator lobCreator)
Create a SpringLobCreatorSynchronization for the given LobCreator.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterCompletion(int status)
Invoked after transaction commit/rollback.void
beforeCompletion()
Invoked before transaction commit/rollback.int
getOrder()
Get the order value of this object.Methods inherited from class org.springframework.transaction.support.TransactionSynchronizationAdapter
afterCommit, beforeCommit, flush, resume, suspend
Field Detail
LOB_CREATOR_SYNCHRONIZATION_ORDER
public static final int LOB_CREATOR_SYNCHRONIZATION_ORDER
Order value for TransactionSynchronization objects that clean up LobCreators. Return CONNECTION_SYNCHRONIZATION_ORDER - 200 to execute LobCreator cleanup before Hibernate Session (- 100) and JDBC Connection cleanup, if any.
Constructor Detail
SpringLobCreatorSynchronization
public SpringLobCreatorSynchronization(LobCreator lobCreator)
Create a SpringLobCreatorSynchronization for the given LobCreator.- Parameters:
lobCreator
- the LobCreator to close after transaction completion
Method Detail
getOrder
public int getOrder()
Description copied from interface:Ordered
Get the order value of this object.Higher values are interpreted as lower priority. As a consequence, the object with the lowest value has the highest priority (somewhat analogous to Servlet
load-on-startup
values).Same order values will result in arbitrary sort positions for the affected objects.
- Specified by:
getOrder
in interfaceOrdered
- Overrides:
getOrder
in classTransactionSynchronizationAdapter
- Returns:
- the order value
- See Also:
Ordered.HIGHEST_PRECEDENCE
,Ordered.LOWEST_PRECEDENCE
beforeCompletion
public void beforeCompletion()
Description copied from interface:TransactionSynchronization
Invoked before transaction commit/rollback. Can perform resource cleanup before transaction completion.This method will be invoked after
beforeCommit
, even whenbeforeCommit
threw an exception. This callback allows for closing resources before transaction completion, for any outcome.- Specified by:
beforeCompletion
in interfaceTransactionSynchronization
- Overrides:
beforeCompletion
in classTransactionSynchronizationAdapter
- See Also:
TransactionSynchronization.beforeCommit(boolean)
,TransactionSynchronization.afterCompletion(int)
afterCompletion
public void afterCompletion(int status)
Description copied from interface:TransactionSynchronization
Invoked after transaction commit/rollback. Can perform resource cleanup after transaction completion.NOTE: The transaction will have been committed or rolled back already, but the transactional resources might still be active and accessible. As a consequence, any data access code triggered at this point will still "participate" in the original transaction, allowing to perform some cleanup (with no commit following anymore!), unless it explicitly declares that it needs to run in a separate transaction. Hence: Use
PROPAGATION_REQUIRES_NEW
for any transactional operation that is called from here.- Specified by:
afterCompletion
in interfaceTransactionSynchronization
- Overrides:
afterCompletion
in classTransactionSynchronizationAdapter
- Parameters:
status
- completion status according to theSTATUS_*
constants- See Also:
TransactionSynchronization.STATUS_COMMITTED
,TransactionSynchronization.STATUS_ROLLED_BACK
,TransactionSynchronization.STATUS_UNKNOWN
,TransactionSynchronization.beforeCompletion()