jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rve...@apache.org
Subject [48/52] [abbrv] jena git commit: JEAN-903: Look down DatasetGraphWrapper layers for a DatasetChanges.
Date Tue, 17 Mar 2015 11:22:00 GMT
JEAN-903: Look down DatasetGraphWrapper layers for a DatasetChanges.

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/1ec5702b
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/1ec5702b
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/1ec5702b

Branch: refs/heads/JENA-507
Commit: 1ec5702bb0e6a18b678504d984729284cee9fa51
Parents: 300f9b7
Author: Andy Seaborne <andy@apache.org>
Authored: Tue Mar 17 10:22:52 2015 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Tue Mar 17 10:22:52 2015 +0000

----------------------------------------------------------------------
 .../jena/sparql/core/DatasetGraphWithLock.java  | 30 +++++++++++++++-----
 1 file changed, 23 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/1ec5702b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetGraphWithLock.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetGraphWithLock.java
b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetGraphWithLock.java
index 243388b..b979853 100644
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetGraphWithLock.java
+++ b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetGraphWithLock.java
@@ -49,10 +49,28 @@ public class DatasetGraphWithLock extends DatasetGraphTrackActive implements
Syn
 
     private final ThreadLocalReadWrite readWrite     = new ThreadLocalReadWrite() ;
     private final ThreadLocalBoolean   inTransaction = new ThreadLocalBoolean() ;
-    private DatasetGraph dsg ;
+    private final DatasetGraph dsg ;
+    // Associated DatasetChanges (if any, may be null)
+    private final DatasetChanges dsChanges ;
 
     public DatasetGraphWithLock(DatasetGraph dsg) {
         this.dsg = dsg ;
+        this.dsChanges = findDatasetChanges(dsg) ;
+    }
+    
+    /** Find a DatasetChanges handler.
+     *  Unwrap layers of DatasetGraphWrapper to
+     *  look for a DatasetGraphMonitor.
+     */
+    private static DatasetChanges findDatasetChanges(DatasetGraph dataset) {
+        for(;;) {
+            // DatasetGraphMonitor extends DatasetGraphWrapper
+            if ( dataset instanceof DatasetGraphMonitor )
+                return ((DatasetGraphMonitor)dataset).getMonitor() ;
+            if ( ! ( dataset instanceof DatasetGraphWrapper ) )
+                return null ;
+            dataset = ((DatasetGraphWrapper)dataset).getWrapped() ;
+        }
     }
 
     @Override
@@ -87,9 +105,8 @@ public class DatasetGraphWithLock extends DatasetGraphTrackActive implements
Syn
         boolean b = isTransactionType(ReadWrite.READ) ;
         get().getLock().enterCriticalSection(b) ;
         inTransaction.set(true) ;
-        if (get() instanceof DatasetGraphMonitor) {
-            ((DatasetGraphMonitor)get()).getMonitor().start();
-        }
+        if ( dsChanges != null )
+            dsChanges.start() ;
     }
 
     @Override
@@ -118,9 +135,8 @@ public class DatasetGraphWithLock extends DatasetGraphTrackActive implements
Syn
     @Override
     protected void _end() {
         if ( isInTransaction() ) {
-            if (get() instanceof DatasetGraphMonitor) {
-                ((DatasetGraphMonitor)get()).getMonitor().finish();
-            }
+            if ( dsChanges != null )
+                dsChanges.finish();
             get().getLock().leaveCriticalSection() ;
             clearState() ;
         }


Mime
View raw message