org.apache.commons.transaction.memory
Class PessimisticTxMap<K,V>
java.lang.Object
org.apache.commons.transaction.AbstractTransactionalResourceManager<BasicTxMap.MapTxContext>
org.apache.commons.transaction.memory.BasicTxMap<K,V>
org.apache.commons.transaction.memory.PessimisticTxMap<K,V>
- All Implemented Interfaces:
- Map<K,V>, ManageableResourceManager, TxMap<K,V>, TransactionalResourceManager
public class PessimisticTxMap<K,V>
- extends BasicTxMap<K,V>
- implements TxMap<K,V>
Map featuring transactional control.
By using pessimistic transaction control (blocking locks) this wrapper has
better isolation than BasicTxMap, but also has less possible
concurrency and may even deadlock. A commit, however, will never fail.
Caution:Some operations that would require global locks (e.g.
size() or clear() or not properly isolated as
this implementation does not support global locks.
This implementation wraps a map of type ConcurrentHashMap.
This implementation is thread-safe.
- See Also:
BasicTxMap,
OptimisticTxMap,
ConcurrentHashMap
| Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
| Methods inherited from class org.apache.commons.transaction.AbstractTransactionalResourceManager |
commitTransaction, forgetTransaction, getCheckedActiveTx, getLm, getName, isPartofComplexTransaction, isReadOnly, isRollbackOnly, joinTransaction, prepareTransaction, rollbackTransaction, setActiveTx, setLm, setName, startTransaction |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.apache.commons.transaction.memory.TxMap |
getWrappedMap |
PessimisticTxMap
public PessimisticTxMap(String name)
PessimisticTxMap
public PessimisticTxMap(String name,
LockManager<Object,Object> lm)
values
public Collection values()
- Specified by:
values in interface Map<K,V>- Overrides:
values in class BasicTxMap<K,V>
- See Also:
Map.values()
entrySet
public Set entrySet()
- Specified by:
entrySet in interface Map<K,V>- Overrides:
entrySet in class BasicTxMap<K,V>
- See Also:
Map.entrySet()
keySet
public Set keySet()
- Specified by:
keySet in interface Map<K,V>- Overrides:
keySet in class BasicTxMap<K,V>
- See Also:
Map.keySet()
remove
public V remove(Object key)
- Specified by:
remove in interface Map<K,V>- Overrides:
remove in class BasicTxMap<K,V>
- See Also:
Map.remove(java.lang.Object)
put
public V put(K key,
V value)
- Specified by:
put in interface Map<K,V>- Overrides:
put in class BasicTxMap<K,V>
- See Also:
Map.put(java.lang.Object, java.lang.Object)
assureWriteLock
protected void assureWriteLock(Object key)
createContext
protected PessimisticTxMap.LockingTxContext createContext()
- Overrides:
createContext in class BasicTxMap<K,V>
commitCanFail
public boolean commitCanFail()
- Description copied from interface:
ManageableResourceManager
- Checks whether a tried commit could possibly fail because of logical
reasons.
- Specified by:
commitCanFail in interface ManageableResourceManager- Overrides:
commitCanFail in class BasicTxMap<K,V>
- Returns:
true if a commit could fail
Copyright © 2004-2007 The Apache Software Foundation. All Rights Reserved.