Top Description Methods
net.sf.ehcache.transaction

public Interface SoftLock

Known Direct Implementers
net.sf.ehcache.transaction.ReadCommittedSoftLockImpl
Imports
net.sf.ehcache.Element

A soft lock is used to lock elements in transactional stores
Author
Ludovic Orban

Method Summary

Modifier and TypeMethod and Description
public void
clearTryLock()

Clear the state of the soft lock after a tryLock() call succeeded.

public void
freeze()

Freeze the soft lock.

public Element

Returns:

the Element visible to the current transaction
getElement
(TransactionID
the current transaction under which this call is executed
currentTransactionId
,
SoftLockID
the soft lock ID
softLockId
)

Get the element the current transaction is supposed to see.

public Object

Returns:

the key
getKey
()

Get the key of the element this soft lock is guarding

public boolean

Returns:

true if the soft lock is orphan and should be cleaned up, false otherwise
isExpired
()

Check if the soft lock expired, ie: that the thread which locked it died

public void
lock()

Lock the soft lock

public boolean

Returns:

true if the soft lock was locked, false otherwise
tryLock
(long
the time in milliseconds before this method gives up
ms
)

Attempt to lock the soft lock

public void
unfreeze()

Unfreeze the soft lock

public void
unlock()

Unlock the soft lock.

Method Detail

clearTryLockback to summary
public void clearTryLock()

Clear the state of the soft lock after a tryLock() call succeeded.

freezeback to summary
public void freeze()

Freeze the soft lock. A soft lock should only be frozen for a very short period of time as this blocks the getElement(TransactionID, SoftLockID) method calls. Freeze is used to mark the start of a commit / rollback phase

getElementback to summary
public Element getElement(TransactionID currentTransactionId, SoftLockID softLockId)

Get the element the current transaction is supposed to see.

Parameters
currentTransactionId:TransactionID

the current transaction under which this call is executed

softLockId:SoftLockID

the soft lock ID

Returns:Element

the Element visible to the current transaction

getKeyback to summary
public Object getKey()

Get the key of the element this soft lock is guarding

Returns:Object

the key

isExpiredback to summary
public boolean isExpired()

Check if the soft lock expired, ie: that the thread which locked it died

Returns:boolean

true if the soft lock is orphan and should be cleaned up, false otherwise

lockback to summary
public void lock()

Lock the soft lock

tryLockback to summary
public boolean tryLock(long ms) throws InterruptedException

Attempt to lock the soft lock

Parameters
ms:long

the time in milliseconds before this method gives up

Returns:boolean

true if the soft lock was locked, false otherwise

Exceptions
InterruptedException:
if the thread calling this method was interrupted
unfreezeback to summary
public void unfreeze()

Unfreeze the soft lock

unlockback to summary
public void unlock()

Unlock the soft lock. Once a soft lock got unlocked, it is considered 'dead': it cannot be locked again and must be cleaned up