org.springframework.transaction.support
Class ResourceHolderSupport

java.lang.Object
  extended byorg.springframework.transaction.support.ResourceHolderSupport
Direct Known Subclasses:
ConnectionHolder, PersistenceManagerHolder, SessionHolder

public abstract class ResourceHolderSupport
extends java.lang.Object

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:
DataSourceTransactionManager.doBegin(java.lang.Object, org.springframework.transaction.TransactionDefinition), DataSourceUtils.applyTransactionTimeout(java.sql.Statement, javax.sql.DataSource)

Constructor Summary
ResourceHolderSupport()
           
 
Method Summary
 java.util.Date getDeadline()
          Return the expiration deadline of this object.
 long getTimeToLiveInMillis()
          Return the time to live for this object in milliseconds.
 int getTimeToLiveInSeconds()
          Return the time to live for this object in seconds.
 boolean isRollbackOnly()
          Return whether the resource transaction is marked as rollback-only.
 void setRollbackOnly()
          Mark the resource transaction as rollback-only.
 void setTimeoutInMillis(long millis)
          Set the timeout for this object in milliseconds.
 void setTimeoutInSeconds(int seconds)
          Set the timeout for this object in seconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceHolderSupport

public ResourceHolderSupport()
Method Detail

setRollbackOnly

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


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.

Parameters:
seconds - number of seconds until expiration

setTimeoutInMillis

public void setTimeoutInMillis(long millis)
Set the timeout for this object in milliseconds.

Parameters:
millis - number of milliseconds until expiration

getDeadline

public java.util.Date getDeadline()
Return the expiration deadline of this object.

Returns:
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.

Returns:
number of seconds until expiration

getTimeToLiveInMillis

public long getTimeToLiveInMillis()
Return the time to live for this object in milliseconds.

Returns:
number of millseconds until expiration


Copyright (C) 2003-2004 The Spring Framework Project.