类 ResourceHolderSupport
- java.lang.Object
- org.springframework.transaction.support.ResourceHolderSupport
- 所有已实现的接口:
ResourceHolder
public abstract class ResourceHolderSupport extends Object implements ResourceHolder
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.
构造器概要
构造器 构造器 说明 ResourceHolderSupport()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidclear()Clear the transactional state of this resource holder.DategetDeadline()Return the expiration deadline of this object.longgetTimeToLiveInMillis()Return the time to live for this object in milliseconds.intgetTimeToLiveInSeconds()Return the time to live for this object in seconds.booleanhasTimeout()Return whether this object has an associated timeout.booleanisOpen()Return whether there are still open references to this holder.booleanisRollbackOnly()Return whether the resource transaction is marked as rollback-only.booleanisSynchronizedWithTransaction()Return whether the resource is synchronized with a transaction.booleanisVoid()Determine whether this holder is considered as 'void', i.e. as a leftover from a previous thread.voidreleased()Decrease the reference count by one because the holder has been released (i.e. someone released the resource held by it).voidrequested()Increase the reference count by one because the holder has been requested (i.e. someone requested the resource held by it).voidreset()Reset this resource holder - transactional state as well as reference count.voidresetRollbackOnly()Reset the rollback-only status for this resource transaction.voidsetRollbackOnly()Mark 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.
构造器详细资料
ResourceHolderSupport
public ResourceHolderSupport()
方法详细资料
setSynchronizedWithTransaction
public void setSynchronizedWithTransaction(boolean synchronizedWithTransaction)
Mark the resource as synchronized with a transaction.
isSynchronizedWithTransaction
public boolean isSynchronizedWithTransaction()
Return whether the resource is synchronized with a transaction.
setRollbackOnly
public void setRollbackOnly()
Mark the resource transaction as rollback-only.
resetRollbackOnly
public 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.
- 从以下版本开始:
- 5.0
- 另请参阅:
SavepointManager.rollbackToSavepoint(java.lang.Object)
isRollbackOnly
public boolean isRollbackOnly()
Return whether the resource transaction is marked as rollback-only.
setTimeoutInSeconds
public void setTimeoutInSeconds(int seconds)
Set the timeout for this object in seconds.- 参数:
seconds- number of seconds until expiration
setTimeoutInMillis
public void setTimeoutInMillis(long millis)
Set the timeout for this object in milliseconds.- 参数:
millis- number of milliseconds until expiration
hasTimeout
public boolean hasTimeout()
Return whether this object has an associated timeout.
getDeadline
@Nullable public Date getDeadline()
Return the expiration deadline of this object.- 返回:
- the deadline as Date object
getTimeToLiveInSeconds
public int getTimeToLiveInSeconds()
Return the time to live for this object in seconds. Rounds up eagerly, e.g. 9.00001 still to 10.- 返回:
- number of seconds until expiration
- 抛出:
TransactionTimedOutException- if the deadline has already been reached
getTimeToLiveInMillis
public long getTimeToLiveInMillis() throws TransactionTimedOutException
Return the time to live for this object in milliseconds.- 返回:
- number of milliseconds until expiration
- 抛出:
TransactionTimedOutException- if the deadline has already been reached
requested
public void requested()
Increase the reference count by one because the holder has been requested (i.e. someone requested the resource held by it).
released
public void released()
Decrease the reference count by one because the holder has been released (i.e. someone released the resource held by it).
isOpen
public boolean isOpen()
Return whether there are still open references to this holder.
clear
public void clear()
Clear the transactional state of this resource holder.
reset
public void reset()
Reset this resource holder - transactional state as well as reference count.- 指定者:
reset在接口中ResourceHolder
unbound
public void unbound()
从接口复制的说明:ResourceHolderNotify this holder that it has been unbound from transaction synchronization.- 指定者:
unbound在接口中ResourceHolder
isVoid
public boolean isVoid()
从接口复制的说明:ResourceHolderDetermine whether this holder is considered as 'void', i.e. as a leftover from a previous thread.- 指定者:
isVoid在接口中ResourceHolder