org.springframework.transaction.support
Class ResourceHolderSupport

Direct Known Subclasses:
ConnectionHolder, SessionHolder, PersistenceManagerHolder

public abstract class ResourceHolderSupport

Convenient base class for resource holders.

Features rollback-only support for nested Hibernate transactions. Can expire after a certain number of seconds or milliseconds, to determine transactional timeouts.

Author:
Juergen Hoeller
See Also: org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(java.lang.Object,org.springframework.transaction.TransactionDefinition), org.springframework.jdbc.datasource.DataSourceUtils.applyTransactionTimeout(java.sql.Statement,javax.sql.DataSource)

Method Summary
 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.
 booleanisRollbackOnly()
          Return whether the resource transaction is marked as rollback-only.
 voidsetRollbackOnly()
          Mark the resource transaction as rollback-only.
 voidsetTimeoutInMillis(long millis)
          Set the timeout for this object in milliseconds.
 voidsetTimeoutInSeconds(int seconds)
          Set the timeout for this object in seconds.

Method Detail

getDeadline

public Date getDeadline()
Return the expiration deadline of this object.
Returns: the deadline as Date object

getTimeToLiveInMillis

public long getTimeToLiveInMillis()
Return the time to live for this object in milliseconds.
Returns: number of millseconds until expiration

getTimeToLiveInSeconds

public 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

isRollbackOnly

public boolean isRollbackOnly()
Return whether the resource transaction is marked as rollback-only.

setRollbackOnly

public void setRollbackOnly()
Mark the resource transaction as rollback-only.

setTimeoutInMillis

public void setTimeoutInMillis(long millis)
Set the timeout for this object in milliseconds.
Parameters:
millis - number of milliseconds until expiration

setTimeoutInSeconds

public void setTimeoutInSeconds(int seconds)
Set the timeout for this object in seconds.
Parameters:
seconds - number of seconds until expiration