1 package org.apache.ojb.odmg.locking; 2 3 17 18 import org.apache.ojb.odmg.TransactionImpl; 19 20 37 public class ReadUncommittedStrategy extends AbstractLockStrategy 38 { 39 46 public boolean readLock(TransactionImpl tx, Object obj) 47 { 48 return true; 49 } 50 51 58 public boolean writeLock(TransactionImpl tx, Object obj) 59 { 60 LockEntry writer = getWriter(obj); 61 if (writer == null) 62 { 63 if (setWriter(tx, obj)) 64 return true; 65 else 66 return writeLock(tx, obj); 67 } 68 if (writer.isOwnedBy(tx)) 69 { 70 return true; } 72 return false; 73 } 74 75 82 public boolean upgradeLock(TransactionImpl tx, Object obj) 83 { 84 LockEntry writer = getWriter(obj); 85 if (writer == null) 86 { 87 if (setWriter(tx, obj)) 88 return true; 89 else 90 return upgradeLock(tx, obj); 91 } 92 if (writer.isOwnedBy(tx)) 93 { 94 return true; } 96 return false; 97 } 98 99 106 public boolean releaseLock(TransactionImpl tx, Object obj) 107 { 108 LockEntry writer = getWriter(obj); 109 if (writer != null && writer.isOwnedBy(tx)) 110 { 111 removeWriter(writer); 112 return true; 113 } 114 return true; 116 } 117 118 124 public boolean checkRead(TransactionImpl tx, Object obj) 125 { 126 return true; 127 } 128 129 135 public boolean checkWrite(TransactionImpl tx, Object obj) 136 { 137 LockEntry writer = getWriter(obj); 138 return (writer != null && writer.isOwnedBy(tx)); 139 } 140 } 141 | Popular Tags |