Top Description Fields Constructors Methods
org.springframework.transaction.support

public abstract Class ResourceHolderSupport

extends Object
implements ResourceHolder
Class Inheritance
All Implemented Interfaces
org.springframework.transaction.support.ResourceHolder
Imports
java.util.Date, org.springframework.lang.Nullable, org.springframework.transaction.TransactionTimedOutException

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.

Author
Juergen Hoeller
Since
02.02.2004
See Also
org.springframework.jdbc.datasource.DataSourceTransactionManager#doBegin, org.springframework.jdbc.datasource.DataSourceUtils#applyTransactionTimeout

Field Summary

Modifier and TypeField and Description
private Date
private boolean
private int
private boolean
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
checkTransactionTimeout(boolean deadlineReached)

Set the transaction rollback-only if the deadline has been reached, and throw a TransactionTimedOutException.

public void
clear()

Clear the transactional state of this resource holder.

public Date

Returns:

the deadline as Date object
getDeadline
()

Return the expiration deadline of this object.

public long

Returns:

number of milliseconds until expiration
getTimeToLiveInMillis
()

Return the time to live for this object in milliseconds.

public int

Returns:

number of seconds until expiration
getTimeToLiveInSeconds
()

Return the time to live for this object in seconds.

public boolean
hasTimeout()

Return whether this object has an associated timeout.

public boolean
isOpen()

Return whether there are still open references to this holder.

public boolean
isRollbackOnly()

Return whether the resource transaction is marked as rollback-only.

public boolean
isSynchronizedWithTransaction()

Return whether the resource is synchronized with a transaction.

public boolean
isVoid()

Implements org.springframework.transaction.support.ResourceHolder.isVoid.

Determine whether this holder is considered as 'void', i.e. as a leftover from a previous thread.
public void
released()

Decrease the reference count by one because the holder has been released (i.e. someone released the resource held by it).

public void
requested()

Increase the reference count by one because the holder has been requested (i.e. someone requested the resource held by it).

public void
reset()

Implements org.springframework.transaction.support.ResourceHolder.reset.

Reset this resource holder - transactional state as well as reference count.
public void
resetRollbackOnly()

Reset the rollback-only status for this resource transaction.

public void
setRollbackOnly()

Mark the resource transaction as rollback-only.

public void
setSynchronizedWithTransaction(boolean synchronizedWithTransaction)

Mark the resource as synchronized with a transaction.

public void
setTimeoutInMillis(long
number of milliseconds until expiration
millis
)

Set the timeout for this object in milliseconds.

public void
setTimeoutInSeconds(int
number of seconds until expiration
seconds
)

Set the timeout for this object in seconds.

public void
unbound()

Implements org.springframework.transaction.support.ResourceHolder.unbound.

Notify this holder that it has been unbound from transaction synchronization.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

deadlineback to summary
private Date deadline
Annotations
@Nullable
isVoidback to summary
private boolean isVoid
referenceCountback to summary
private int referenceCount
rollbackOnlyback to summary
private boolean rollbackOnly
synchronizedWithTransactionback to summary
private boolean synchronizedWithTransaction

Constructor Detail

ResourceHolderSupportback to summary
public ResourceHolderSupport()

Method Detail

checkTransactionTimeoutback to summary
private void checkTransactionTimeout(boolean deadlineReached) throws TransactionTimedOutException

Set the transaction rollback-only if the deadline has been reached, and throw a TransactionTimedOutException.

clearback to summary
public void clear()

Clear the transactional state of this resource holder.

getDeadlineback to summary
public Date getDeadline()

Return the expiration deadline of this object.

Returns:Date

the deadline as Date object

Annotations
@Nullable
getTimeToLiveInMillisback to summary
public long getTimeToLiveInMillis() throws TransactionTimedOutException

Return the time to live for this object in milliseconds.

Returns:long

number of milliseconds until expiration

Exceptions
TransactionTimedOutException:
if the deadline has already been reached
getTimeToLiveInSecondsback to summary
public int getTimeToLiveInSeconds()

Return the time to live for this object in seconds. Rounds up eagerly, e.g. 9.00001 still to 10.

Returns:int

number of seconds until expiration

Exceptions
TransactionTimedOutException:
if the deadline has already been reached
hasTimeoutback to summary
public boolean hasTimeout()

Return whether this object has an associated timeout.

isOpenback to summary
public boolean isOpen()

Return whether there are still open references to this holder.

isRollbackOnlyback to summary
public boolean isRollbackOnly()

Return whether the resource transaction is marked as rollback-only.

isSynchronizedWithTransactionback to summary
public boolean isSynchronizedWithTransaction()

Return whether the resource is synchronized with a transaction.

isVoidback to summary
public boolean isVoid()

Implements org.springframework.transaction.support.ResourceHolder.isVoid.

Doc from org.springframework.transaction.support.ResourceHolder.isVoid.

Determine whether this holder is considered as 'void', i.e. as a leftover from a previous thread.

Annotations
@Override
releasedback to summary
public void released()

Decrease the reference count by one because the holder has been released (i.e. someone released the resource held by it).

requestedback to summary
public void requested()

Increase the reference count by one because the holder has been requested (i.e. someone requested the resource held by it).

resetback to summary
public void reset()

Implements org.springframework.transaction.support.ResourceHolder.reset.

Reset this resource holder - transactional state as well as reference count.

Annotations
@Override
resetRollbackOnlyback to summary
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.

Since
5.0
See Also
org.springframework.transaction.SavepointManager#rollbackToSavepoint
setRollbackOnlyback to summary
public void setRollbackOnly()

Mark the resource transaction as rollback-only.

setSynchronizedWithTransactionback to summary
public void setSynchronizedWithTransaction(boolean synchronizedWithTransaction)

Mark the resource as synchronized with a transaction.

setTimeoutInMillisback to summary
public void setTimeoutInMillis(long millis)

Set the timeout for this object in milliseconds.

Parameters
millis:long

number of milliseconds until expiration

setTimeoutInSecondsback to summary
public void setTimeoutInSeconds(int seconds)

Set the timeout for this object in seconds.

Parameters
seconds:int

number of seconds until expiration

unboundback to summary
public void unbound()

Implements org.springframework.transaction.support.ResourceHolder.unbound.

Doc from org.springframework.transaction.support.ResourceHolder.unbound.

Notify this holder that it has been unbound from transaction synchronization.

Annotations
@Override