1 package org.apache.ojb.odmg.locking; 2 3 17 18 import org.apache.ojb.broker.Identity; 19 import org.apache.ojb.broker.util.logging.Logger; 20 import org.apache.ojb.broker.util.logging.LoggerFactory; 21 import org.apache.ojb.odmg.TransactionImpl; 22 23 49 public class LockManagerDefaultImpl implements LockManager 50 { 51 private Logger log = LoggerFactory.getLogger(LockManagerDefaultImpl.class); 52 53 public LockManagerDefaultImpl() 54 { 55 } 56 57 61 public synchronized boolean readLock(TransactionImpl tx, Object obj) 62 { 63 if (log.isDebugEnabled()) log.debug("LM.readLock(tx-" + tx.getGUID() + ", " + new Identity(obj, tx.getBroker()).toString() + ")"); 64 LockStrategy lockStrategy = LockStrategyFactory.getStrategyFor(obj); 65 return lockStrategy.readLock(tx, obj); 66 } 67 68 public boolean readLock(TransactionImpl tx, Identity oid, Object obj) 69 { 70 return readLock(tx,obj); 71 } 72 73 77 public synchronized boolean writeLock(TransactionImpl tx, Object obj) 78 { 79 if (log.isDebugEnabled()) log.debug("LM.writeLock(tx-" + tx.getGUID() + ", " + new Identity(obj, tx.getBroker()).toString() + ")"); 80 LockStrategy lockStrategy = LockStrategyFactory.getStrategyFor(obj); 81 return lockStrategy.writeLock(tx, obj); 82 } 83 84 public boolean writeLock(TransactionImpl tx, Identity oid, Object obj) 85 { 86 return writeLock(tx, obj); 87 } 88 89 94 public synchronized boolean upgradeLock(TransactionImpl tx, Object obj) 95 { 96 if (log.isDebugEnabled()) log.debug("LM.upgradeLock(tx-" + tx.getGUID() + ", " + new Identity(obj, tx.getBroker()).toString() + ")"); 97 LockStrategy lockStrategy = LockStrategyFactory.getStrategyFor(obj); 98 return lockStrategy.upgradeLock(tx, obj); 99 } 100 101 public boolean upgradeLock(TransactionImpl tx, Identity oid, Object obj) 102 { 103 return upgradeLock(tx, obj); 104 } 105 106 110 public synchronized boolean releaseLock(TransactionImpl tx, Object obj) 111 { 112 if (log.isDebugEnabled()) log.debug("LM.releaseLock(tx-" + tx.getGUID() + ", " + new Identity(obj, tx.getBroker()).toString() + ")"); 113 LockStrategy lockStrategy = LockStrategyFactory.getStrategyFor(obj); 114 return lockStrategy.releaseLock(tx, obj); 115 } 116 117 public boolean releaseLock(TransactionImpl tx, Identity oid, Object obj) 118 { 119 return releaseLock(tx, obj); 120 } 121 122 126 public synchronized boolean checkRead(TransactionImpl tx, Object obj) 127 { 128 if (log.isDebugEnabled()) log.debug("LM.checkRead(tx-" + tx.getGUID() + ", " + new Identity(obj, tx.getBroker()).toString() + ")"); 129 LockStrategy lockStrategy = LockStrategyFactory.getStrategyFor(obj); 130 return lockStrategy.checkRead(tx, obj); 131 } 132 133 public boolean checkRead(TransactionImpl tx, Identity oid, Object obj) 134 { 135 return checkRead(tx, obj); 136 } 137 138 142 public synchronized boolean checkWrite(TransactionImpl tx, Object obj) 143 { 144 if (log.isDebugEnabled()) log.debug("LM.checkWrite(tx-" + tx.getGUID() + ", " + new Identity(obj, tx.getBroker()).toString() + ")"); 145 LockStrategy lockStrategy = LockStrategyFactory.getStrategyFor(obj); 146 return lockStrategy.checkWrite(tx, obj); 147 } 148 149 public boolean checkWrite(TransactionImpl tx, Identity oid, Object obj) 150 { 151 return checkWrite(tx, obj); 152 } 153 } 154 | Popular Tags |