Class ResourceHolderSupport
java.lang.Object
org.springframework.transaction.support.ResourceHolderSupport
- All Implemented Interfaces:
- ResourceHolder
- Direct Known Subclasses:
- ConnectionHolder,- ConnectionHolder,- EntityManagerHolder,- JmsResourceHolder
Convenient base class for resource holders.
 
Features rollback-only support for participating transactions. Can expire after a certain number of seconds or milliseconds in order to determine a transactional timeout.
- Since:
- 02.02.2004
- Author:
- Juergen Hoeller
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidclear()Clear the transactional state of this resource holder.Return the expiration deadline of this object.longReturn the time to live for this object in milliseconds.intReturn the time to live for this object in seconds.booleanReturn whether this object has an associated timeout.booleanisOpen()Return whether there are still open references to this holder.booleanReturn whether the resource transaction is marked as rollback-only.booleanReturn whether the resource is synchronized with a transaction.booleanisVoid()Determine whether this holder is considered as 'void', i.e.voidreleased()Decrease the reference count by one because the holder has been released (i.e.voidIncrease the reference count by one because the holder has been requested (i.e.voidreset()Reset this resource holder - transactional state as well as reference count.voidReset the rollback-only status for this resource transaction.voidMark the resource transaction as rollback-only.voidsetSynchronizedWithTransaction(boolean synchronizedWithTransaction) Mark the resource as synchronized with a transaction.voidsetTimeoutInMillis(long millis) Set the timeout for this object in milliseconds.voidsetTimeoutInSeconds(int seconds) Set the timeout for this object in seconds.voidunbound()Notify this holder that it has been unbound from transaction synchronization.
- 
Constructor Details- 
ResourceHolderSupportpublic ResourceHolderSupport()
 
- 
- 
Method Details- 
setSynchronizedWithTransactionpublic void setSynchronizedWithTransaction(boolean synchronizedWithTransaction) Mark the resource as synchronized with a transaction.
- 
isSynchronizedWithTransactionpublic boolean isSynchronizedWithTransaction()Return whether the resource is synchronized with a transaction.
- 
setRollbackOnlypublic void setRollbackOnly()Mark the resource transaction as rollback-only.
- 
resetRollbackOnlypublic void resetRollbackOnly()Reset the rollback-only status for this resource transaction.Only really intended to be called after custom rollback steps which keep the original resource in action, e.g. in case of a savepoint. - Since:
- 5.0
- See Also:
 
- 
isRollbackOnlypublic boolean isRollbackOnly()Return whether the resource transaction is marked as rollback-only.
- 
setTimeoutInSecondspublic void setTimeoutInSeconds(int seconds) Set the timeout for this object in seconds.- Parameters:
- seconds- number of seconds until expiration
 
- 
setTimeoutInMillispublic void setTimeoutInMillis(long millis) Set the timeout for this object in milliseconds.- Parameters:
- millis- number of milliseconds until expiration
 
- 
hasTimeoutpublic boolean hasTimeout()Return whether this object has an associated timeout.
- 
getDeadlineReturn the expiration deadline of this object.- Returns:
- the deadline as Date object
 
- 
getTimeToLiveInSecondspublic int getTimeToLiveInSeconds()Return the time to live for this object in seconds. Rounds up eagerly, e.g. 9.00001 still to 10.- Returns:
- number of seconds until expiration
- Throws:
- TransactionTimedOutException- if the deadline has already been reached
 
- 
getTimeToLiveInMillisReturn the time to live for this object in milliseconds.- Returns:
- number of milliseconds until expiration
- Throws:
- TransactionTimedOutException- if the deadline has already been reached
 
- 
requestedpublic void requested()Increase the reference count by one because the holder has been requested (i.e. someone requested the resource held by it).
- 
releasedpublic void released()Decrease the reference count by one because the holder has been released (i.e. someone released the resource held by it).
- 
isOpenpublic boolean isOpen()Return whether there are still open references to this holder.
- 
clearpublic void clear()Clear the transactional state of this resource holder.
- 
resetpublic void reset()Reset this resource holder - transactional state as well as reference count.- Specified by:
- resetin interface- ResourceHolder
 
- 
unboundpublic void unbound()Description copied from interface:ResourceHolderNotify this holder that it has been unbound from transaction synchronization.- Specified by:
- unboundin interface- ResourceHolder
 
- 
isVoidpublic boolean isVoid()Description copied from interface:ResourceHolderDetermine whether this holder is considered as 'void', i.e. as a leftover from a previous thread.- Specified by:
- isVoidin interface- ResourceHolder
 
 
-