ehcache

net.sf.ehcache.transaction
Class AbstractSoftLockManager

java.lang.Object
  extended by net.sf.ehcache.transaction.AbstractSoftLockManager
All Implemented Interfaces:
SoftLockManager
Direct Known Subclasses:
SoftLockManagerImpl

public abstract class AbstractSoftLockManager
extends Object
implements SoftLockManager

An abstract map backed soft lock manager.

Author:
Chris Dennis

Constructor Summary
AbstractSoftLockManager(String cacheName, SoftLockFactory lockFactory)
          Create an abstract soft lock manager for the given cache name and soft lock factory.
 
Method Summary
 void clearSoftLock(SoftLock softLock)
          Clear a soft lock
 Set<SoftLock> collectAllSoftLocksForTransactionID(TransactionID transactionID)
          Get a the soft locks of the specified transaction ID
 SoftLockID createSoftLockID(TransactionID transactionID, Object key, Element newElement, Element oldElement)
          Create a new soft lock ID and associated soft lock if necessary.
 SoftLock findSoftLockById(SoftLockID softLockId)
          Find a previously created and still existing soft lock
protected abstract  ConcurrentMap<SoftLockID,SoftLock> getAllLocks()
          Return the map of all soft locks.
 Set<Object> getKeysInvisibleInContext(LocalTransactionContext currentTransactionContext, Store underlyingStore)
          Get a Set of keys protected by soft locks which must not be visible to a transaction context according to the isolation level.
protected abstract  ConcurrentMap<SoftLockID,Boolean> getNewKeyLocks()
          Return the map of all locks that are for new keys.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSoftLockManager

public AbstractSoftLockManager(String cacheName,
                               SoftLockFactory lockFactory)
Create an abstract soft lock manager for the given cache name and soft lock factory.

Parameters:
cacheName - name of the cache
lockFactory - factory of managed locks
Method Detail

getAllLocks

protected abstract ConcurrentMap<SoftLockID,SoftLock> getAllLocks()
Return the map of all soft locks.

Returns:
the map of all locks

getNewKeyLocks

protected abstract ConcurrentMap<SoftLockID,Boolean> getNewKeyLocks()
Return the map of all locks that are for new keys.

Returns:
the map of all new key locks

createSoftLockID

public SoftLockID createSoftLockID(TransactionID transactionID,
                                   Object key,
                                   Element newElement,
                                   Element oldElement)
Create a new soft lock ID and associated soft lock if necessary.

Specified by:
createSoftLockID in interface SoftLockManager
Parameters:
transactionID - the transaction ID under which the soft lock will operate
key - the key of the Element this soft lock is protecting
newElement - the new Element
oldElement - the actual Element
Returns:
the soft lock ID

findSoftLockById

public SoftLock findSoftLockById(SoftLockID softLockId)
Find a previously created and still existing soft lock

Specified by:
findSoftLockById in interface SoftLockManager
Parameters:
softLockId - the soft lock's ID
Returns:
the soft lock, or null if no soft lock with the corresponding ID could be found

getKeysInvisibleInContext

public Set<Object> getKeysInvisibleInContext(LocalTransactionContext currentTransactionContext,
                                             Store underlyingStore)
Get a Set of keys protected by soft locks which must not be visible to a transaction context according to the isolation level.

Specified by:
getKeysInvisibleInContext in interface SoftLockManager
Parameters:
currentTransactionContext - the transaction context
Returns:
a Set of keys invisible to the context

collectAllSoftLocksForTransactionID

public Set<SoftLock> collectAllSoftLocksForTransactionID(TransactionID transactionID)
Get a the soft locks of the specified transaction ID

Specified by:
collectAllSoftLocksForTransactionID in interface SoftLockManager
Parameters:
transactionID - the transaction ID
Returns:
a Set of SoftLocks

clearSoftLock

public void clearSoftLock(SoftLock softLock)
Clear a soft lock

Specified by:
clearSoftLock in interface SoftLockManager
Parameters:
softLock - the lock to clear

ehcache

Copyright 2001-2014, Terracotta, Inc.