1 package org.apache.ojb.odmg.locking; 2 3 17 18 import org.apache.ojb.odmg.TransactionImpl; 19 import org.apache.ojb.broker.util.configuration.Configuration; 20 import org.apache.ojb.broker.util.configuration.impl.OjbConfigurator; 21 22 import java.util.Collection ; 23 24 30 public abstract class AbstractLockStrategy implements LockStrategy 31 { 32 35 public static long DEFAULT_LOCK_TIMEOUT = 30000; 36 37 40 private static LockMap lockMap = null; 41 42 43 public AbstractLockStrategy() 44 { 45 synchronized (AbstractLockStrategy.class) 46 { 47 if (lockMap == null) 48 { 49 lockMap = LockMapFactory.getLockMap(); 50 Configuration conf = OjbConfigurator.getInstance().getConfigurationFor(null); 51 DEFAULT_LOCK_TIMEOUT = conf.getInteger("LockTimeout", 60000); 52 } 53 } 54 } 55 56 57 61 protected LockEntry getWriter(Object obj) 62 { 63 return lockMap.getWriter(obj); 64 } 65 66 70 protected Collection getReaders(Object obj) 71 { 72 return lockMap.getReaders(obj); 73 } 74 75 79 protected boolean addReader(TransactionImpl tx, Object obj) 80 { 81 return lockMap.addReader(tx, obj); 82 } 83 84 88 protected void removeReader(TransactionImpl tx, Object obj) 89 { 90 lockMap.removeReader(tx, obj); 91 } 92 93 97 protected void removeWriter(LockEntry writer) 98 { 99 lockMap.removeWriter(writer); 100 } 101 102 103 107 protected boolean upgradeLock(LockEntry reader) 108 { 109 return lockMap.upgradeLock(reader); 110 } 111 112 116 protected boolean setWriter(TransactionImpl tx, Object obj) 117 { 118 return lockMap.setWriter(tx, obj); 119 } 120 121 125 protected boolean hasReadLock(TransactionImpl tx, Object obj) 126 { 127 return lockMap.hasReadLock(tx, obj); 128 } 129 130 } 131 | Popular Tags |