commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ozeigerm...@apache.org
Subject svn commit: r153448 - jakarta/commons/proper/transaction/trunk/src/java/org/apache/commons/transaction/locking/GenericLockManager.java
Date Fri, 11 Feb 2005 19:42:33 GMT
Author: ozeigermann
Date: Fri Feb 11 11:42:32 2005
New Revision: 153448

URL: http://svn.apache.org/viewcvs?view=rev&rev=153448
Log:
Made #checkLock, #hasLock, #release only check on existing locks
as creating a new lock was silly in that scenario

Modified:
    jakarta/commons/proper/transaction/trunk/src/java/org/apache/commons/transaction/locking/GenericLockManager.java

Modified: jakarta/commons/proper/transaction/trunk/src/java/org/apache/commons/transaction/locking/GenericLockManager.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/transaction/trunk/src/java/org/apache/commons/transaction/locking/GenericLockManager.java?view=diff&r1=153447&r2=153448
==============================================================================
--- jakarta/commons/proper/transaction/trunk/src/java/org/apache/commons/transaction/locking/GenericLockManager.java
(original)
+++ jakarta/commons/proper/transaction/trunk/src/java/org/apache/commons/transaction/locking/GenericLockManager.java
Fri Feb 11 11:42:32 2005
@@ -139,11 +139,14 @@
      */
     public boolean checkLock(Object ownerId, Object resourceId, int targetLockLevel, boolean
reentrant) {
         timeoutCheck(ownerId);
+        boolean possible = true;
 
-        GenericLock lock = (GenericLock) atomicGetOrCreateLock(resourceId);
-        boolean possible = lock.test(ownerId, targetLockLevel,
-                reentrant ? GenericLock.COMPATIBILITY_REENTRANT : GenericLock.COMPATIBILITY_NONE);
-        
+        GenericLock lock = (GenericLock) getLock(resourceId);
+        if (lock != null) {
+            possible = lock.test(ownerId, targetLockLevel,
+                    reentrant ? GenericLock.COMPATIBILITY_REENTRANT
+                            : GenericLock.COMPATIBILITY_NONE);
+        }
         return possible;
     }
 
@@ -153,10 +156,12 @@
      */
     public boolean hasLock(Object ownerId, Object resourceId, int lockLevel) {
         timeoutCheck(ownerId);
+        boolean owned = false;
 
-        GenericLock lock = (GenericLock) atomicGetOrCreateLock(resourceId);
-        boolean owned = lock.has(ownerId, lockLevel);
-        
+        GenericLock lock = (GenericLock) getLock(resourceId);
+        if (lock != null) {
+            owned = lock.has(ownerId, lockLevel);
+        }
         return owned;
     }
 
@@ -290,9 +295,13 @@
      */
     public boolean release(Object ownerId, Object resourceId) {
         timeoutCheck(ownerId);
-        GenericLock lock = (GenericLock) atomicGetOrCreateLock(resourceId);
-        boolean released = lock.release(ownerId);
-        removeOwner(ownerId, lock);
+        boolean released = false;
+
+        GenericLock lock = (GenericLock) getLock(resourceId);
+        if (lock != null) {
+            released = lock.release(ownerId);
+            removeOwner(ownerId, lock);
+        }
         return released;
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message