jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [5/5] jena git commit: Simpify by using in a Java8 style.
Date Fri, 04 Dec 2015 16:35:32 GMT
Simpify by using in a Java8 style.

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

Branch: refs/heads/master
Commit: 10648973b20d5233b5a6bc199e9806f901510d6b
Parents: 0cfc756
Author: Andy Seaborne <andy@apache.org>
Authored: Fri Dec 4 16:34:27 2015 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Fri Dec 4 16:34:27 2015 +0000

----------------------------------------------------------------------
 .../transaction/DatasetGraphTransaction.java    | 39 ++++++++------------
 1 file changed, 15 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/10648973/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java
b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java
index 4845dfe..f4cc4f2 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java
@@ -27,14 +27,21 @@ import org.apache.jena.tdb.StoreConnection ;
 import org.apache.jena.tdb.TDB ;
 import org.apache.jena.tdb.base.file.Location ;
 import org.apache.jena.tdb.store.DatasetGraphTDB ;
+import static java.lang.ThreadLocal.withInitial ;
 
 /**
- * Transactional DatasetGraph that allows one active transaction. For multiple
- * read transactions, create multiple DatasetGraphTransaction objects. This is
- * analogous to a "connection" in JDBC.
+ * A transactional {@code DatasetGraph} that allows one active transaction per thread.
+ * 
+ * {@link DatasetGraphTxn} holds the {~link Trasnaction} object.
+ *
+ * This is analogous to a "connection" in JDBC. 
+ * It is a holder of a {@link StoreConnection} combined with the machinary from
+ * {@link DatasetGraphTrackActive}.  
+ * 
+ * Not considered to be in the public API.
  */
 
-public class DatasetGraphTransaction extends DatasetGraphTrackActive implements Sync {
+ public class DatasetGraphTransaction extends DatasetGraphTrackActive implements Sync {
     /*
      * Initially, the app can use this DatasetGraph non-transactionally. But as
      * soon as it starts a transaction, the dataset can only be used inside
@@ -46,28 +53,12 @@ public class DatasetGraphTransaction extends DatasetGraphTrackActive implements
      * transactions.
      */
 
-    static class ThreadLocalTxn extends ThreadLocal<DatasetGraphTxn> {
-        // This is the default - but nice to give it a name and to set it
-        // clearly.
-        @Override
-        protected DatasetGraphTxn initialValue() {
-            return null ;
-        }
-    }
-
-    static class ThreadLocalBoolean extends ThreadLocal<Boolean> {
-        @Override
-        protected Boolean initialValue() {
-            return false ;
-        }
-    }
-
     // Transaction per thread per DatasetGraphTransaction object.
-    private ThreadLocalTxn        txn           = new ThreadLocalTxn() ;
-    private ThreadLocalBoolean    inTransaction = new ThreadLocalBoolean() ;
+    private ThreadLocal<DatasetGraphTxn> txn           = withInitial(() -> null);
+    private ThreadLocal<Boolean>         inTransaction = withInitial(() -> false);
 
-    private final StoreConnection sConn ;
-    private boolean               isClosed      = false ;
+    private final StoreConnection        sConn;
+    private boolean                      isClosed      = false;
 
     public DatasetGraphTransaction(Location location) {
         sConn = StoreConnection.make(location) ;


Mime
View raw message