1 28 29 package org.apache.commons.transaction.locking; 30 31 import org.apache.commons.transaction.util.LoggerFacade; 32 33 56 public class ReadWriteUpgradeLockManager extends ReadWriteLockManager { 57 58 64 public ReadWriteUpgradeLockManager(LoggerFacade logger, long timeoutMSecs) { 65 super(ReadWriteUpgradeLock.WRITE_LOCK, logger, timeoutMSecs); 66 } 67 68 81 public boolean tryUpgradeLock(Object ownerId, Object resourceId) { 82 return tryLock(ownerId, resourceId, ReadWriteUpgradeLock.UPGRADE_LOCK, true); 83 } 84 85 98 public boolean tryWriteLock(Object ownerId, Object resourceId) { 99 return tryLock(ownerId, resourceId, ReadWriteUpgradeLock.WRITE_LOCK, true); 100 } 101 102 117 public void upgradeLock(Object ownerId, Object resourceId) throws LockException { 118 super.lock(ownerId, resourceId, ReadWriteUpgradeLock.UPGRADE_LOCK, true); 119 } 120 121 136 public void writeLock(Object ownerId, Object resourceId) throws LockException { 137 super.lock(ownerId, resourceId, ReadWriteUpgradeLock.WRITE_LOCK, true); 138 } 139 140 protected GenericLock createLock(Object resourceId) { 141 synchronized (globalLocks) { 142 GenericLock lock = new ReadWriteUpgradeLock(resourceId, logger); 143 globalLocks.put(resourceId, lock); 144 return lock; 145 } 146 } 147 148 } | Popular Tags |