clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r1535645 - /clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraphWrapper.java
Date Fri, 25 Oct 2013 06:29:29 GMT
Author: reto
Date: Fri Oct 25 06:29:29 2013
New Revision: 1535645

URL: http://svn.apache.org/r1535645
Log:
CLEREZZA-834: enhanced LockableMGraphWrapper so that the lock can be passed to the constructore

Modified:
    clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraphWrapper.java

Modified: clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraphWrapper.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraphWrapper.java?rev=1535645&r1=1535644&r2=1535645&view=diff
==============================================================================
--- clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraphWrapper.java
(original)
+++ clerezza/trunk/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraphWrapper.java
Fri Oct 25 06:29:29 2013
@@ -41,19 +41,11 @@ import org.apache.clerezza.rdf.core.even
  */
 public class LockableMGraphWrapper implements LockableMGraph {
 
-
     private static final String DEBUG_MODE = "rdfLocksDebugging";
     private final ReadWriteLock lock;
-    {
-        String debugMode = System.getProperty(DEBUG_MODE);
-        if (debugMode != null && debugMode.toLowerCase().equals("true")) {
-            lock = new ReentrantReadWriteLockTracker();
-        } else {
-            lock = new ReentrantReadWriteLock();
-        }
-    }
-    private final Lock readLock = lock.readLock();
-    private final Lock writeLock = lock.writeLock();
+
+    private final Lock readLock;
+    private final Lock writeLock;
     private final MGraph wrapped;
 
     /**
@@ -63,6 +55,23 @@ public class LockableMGraphWrapper imple
      */
     public LockableMGraphWrapper(final MGraph providedMGraph) {
         this.wrapped = providedMGraph;
+        {
+            String debugMode = System.getProperty(DEBUG_MODE);
+            if (debugMode != null && debugMode.toLowerCase().equals("true")) {
+                lock = new ReentrantReadWriteLockTracker();
+            } else {
+                lock = new ReentrantReadWriteLock();
+            }
+        }
+        readLock = lock.readLock();
+        writeLock = lock.writeLock();
+    }
+    
+    public LockableMGraphWrapper(final MGraph providedMGraph, final ReadWriteLock lock) {
+        this.wrapped = providedMGraph;
+        this.lock = lock;
+        readLock = lock.readLock();
+        writeLock = lock.writeLock();
     }
 
     @Override
@@ -243,16 +252,16 @@ public class LockableMGraphWrapper imple
 
     @Override
     public boolean equals(Object obj) {
-        if(obj == null) {
+        if (obj == null) {
             return false;
         }
-        if(obj == this) {
+        if (obj == this) {
             return true;
         }
-        if(obj.getClass() != getClass()) {
+        if (obj.getClass() != getClass()) {
             return false;
         }
-        
+
         LockableMGraphWrapper other = (LockableMGraphWrapper) obj;
         return wrapped.equals(other.wrapped);
     }
@@ -261,4 +270,5 @@ public class LockableMGraphWrapper imple
     public String toString() {
         return wrapped.toString();
     }
+
 }



Mime
View raw message