jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [2/3] jena git commit: Put usage examples into the code so they stay up-to-date.
Date Fri, 16 Feb 2018 12:32:16 GMT
Put usage examples into the code so they stay up-to-date.


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

Branch: refs/heads/master
Commit: 634cced9f83fefa826c2f7bf893b0e05214d5962
Parents: 30d2d87
Author: Andy Seaborne <andy@apache.org>
Authored: Thu Feb 15 13:42:52 2018 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Thu Feb 15 13:42:52 2018 +0000

----------------------------------------------------------------------
 .../jena/sparql/core/DatasetGraphSink.java      | 10 ++----
 .../jena/sparql/core/DatasetGraphZero.java      |  2 +-
 .../sparql/core/TransactionalNotSupported.java  | 36 +++++++++++---------
 .../jena/sparql/core/TransactionalNull.java     | 35 ++++++++++---------
 4 files changed, 41 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/634cced9/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphSink.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphSink.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphSink.java
index 90cda52..88716ca 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphSink.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphSink.java
@@ -31,7 +31,7 @@ import org.apache.jena.sparql.graph.GraphSink;
 /** 
  * An always empty {@link DatasetGraph} that accepts changes but ignores them.
  * 
- * @see DatasetGraphZero
+ * @see DatasetGraphZero - a DSG that does not allow changes.
  */
 public class DatasetGraphSink extends DatasetGraphBaseFind {
 
@@ -41,7 +41,7 @@ public class DatasetGraphSink extends DatasetGraphBaseFind {
     
     public DatasetGraphSink() {}
     
-    private TransactionalNull txn                       = TransactionalNull.create();
+    private Transactional txn                           = TransactionalNull.create();
     @Override public void begin(TxnType txnType)        { txn.begin(txnType); }
     @Override public void begin(ReadWrite mode)         { txn.begin(mode); }
     @Override public boolean promote(Promote txnType)   { return txn.promote(txnType); }
@@ -99,10 +99,4 @@ public class DatasetGraphSink extends DatasetGraphBaseFind {
 
     @Override
     public void removeGraph(Node graphName) { /* ignore */ }
-    
-    @Override
-    public void close() {
-        txn.remove();
-        txn = null;
-    }
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/634cced9/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphZero.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphZero.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphZero.java
index 388d850..4612179 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphZero.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphZero.java
@@ -40,7 +40,7 @@ public class DatasetGraphZero extends DatasetGraphBaseFind {
 
     public DatasetGraphZero() {}
     
-    private TransactionalNull txn                       = TransactionalNull.create();
+    private Transactional txn                           = TransactionalNull.create();
     @Override public void begin()                       { txn.begin(); }
     @Override public void begin(TxnType txnType)        { txn.begin(txnType); }
     @Override public void begin(ReadWrite mode)         { txn.begin(mode); }

http://git-wip-us.apache.org/repos/asf/jena/blob/634cced9/jena-arq/src/main/java/org/apache/jena/sparql/core/TransactionalNotSupported.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/TransactionalNotSupported.java
b/jena-arq/src/main/java/org/apache/jena/sparql/core/TransactionalNotSupported.java
index d16f1fc..d02b6b9 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/TransactionalNotSupported.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/TransactionalNotSupported.java
@@ -23,6 +23,7 @@ import org.apache.jena.query.TxnType;
 
 /** Implementation for "un-Transactional" interface.
  * 
+ * @see TransactionalNull for a do nothing implementation of Transactions.
  * @see TransactionalNotSupportedMixin
  */ 
 public class TransactionalNotSupported implements Transactional
@@ -36,24 +37,25 @@ public class TransactionalNotSupported implements Transactional
     // Sometimes implementations will have to include this code
     // directly to override super class versions.
 
-    // As an included component. 
-    /*
-    private final Transactional txn                     = new TransactionalNotSupported()
;
-    @Override public void begin()                       { txn.begin(); }
-    @Override public void begin(TxnType txnType)        { txn.begin(txnType); }
-    @Override public void begin(ReadWrite mode)         { txn.begin(mode); }
-    @Override public void commit()                      { txn.commit(); }
-    @Override public void abort()                       { txn.abort(); }
-    @Override public boolean isInTransaction()          { return txn.isInTransaction(); }
-    @Override public void end()                         { txn.end(); }
-    @Override public ReadWrite transactionMode()        { return txn.transactionMode(); }
-    @Override public TxnType transactionType()          { return txn.transactionType(); }
+    // As an included component: 
+    private static class Example implements Transactional { 
+        private final Transactional txn                     = new TransactionalNotSupported()
;
+        @Override public void begin()                       { txn.begin(); }
+        @Override public void begin(TxnType txnType)        { txn.begin(txnType); }
+        @Override public void begin(ReadWrite mode)         { txn.begin(mode); }
+        @Override public void commit()                      { txn.commit(); }
+        @Override public void abort()                       { txn.abort(); }
+        @Override public boolean promote(Promote mode)      { return txn.promote(mode) ;
}
+        @Override public boolean isInTransaction()          { return txn.isInTransaction();
}
+        @Override public void end()                         { txn.end(); }
+        @Override public ReadWrite transactionMode()        { return txn.transactionMode();
}
+        @Override public TxnType transactionType()          { return txn.transactionType();
}
+//        // For Datasets: add:
+//        @Override public boolean supportsTransactions()     { return false; }
+//        @Override public boolean supportsTransactionAbort() { return false; }
+    }
     
-     For DatasetGraphs:
-     
-    @Override public boolean supportsTransactions()     { return true; }
-    @Override public boolean supportsTransactionAbort() { return false; }
-    */
+    public static Transactional create() { return new TransactionalNotSupported(); }
     
     @Override
     public void begin()

http://git-wip-us.apache.org/repos/asf/jena/blob/634cced9/jena-arq/src/main/java/org/apache/jena/sparql/core/TransactionalNull.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/TransactionalNull.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/TransactionalNull.java
index 89dee0f..b2ea5c6 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/TransactionalNull.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/TransactionalNull.java
@@ -28,24 +28,27 @@ import org.apache.jena.sparql.JenaTransactionException;
  * It does provide "abort".   
  */
 public class TransactionalNull implements Transactional {
-    /*
-    @Override public void begin()                       { txn.begin(); }
-    @Override public void begin(TxnType txnType)        { txn.begin(txnType); }
-    @Override public void begin(ReadWrite mode)         { txn.begin(mode); }
-    @Override public void commit()                      { txn.commit(); }
-    @Override public void abort()                       { txn.abort(); }
-    @Override public boolean isInTransaction()          { return txn.isInTransaction(); }
-    @Override public void end()                         { txn.end(); }
-    @Override public ReadWrite transactionMode()        { return txn.transactionMode(); }
-    @Override public TxnType transactionType()          { return txn.transactionType(); }
- 
-     For DatasetGraphs:
+    
+    // Usage example:
+    private static class Example implements Transactional {  
+        private final Transactional txn                     = new TransactionalNotSupported()
;
+        @Override public void begin()                       { txn.begin(); }
+        @Override public void begin(TxnType txnType)        { txn.begin(txnType); }
+        @Override public void begin(ReadWrite mode)         { txn.begin(mode); }
+        @Override public void commit()                      { txn.commit(); }
+        @Override public void abort()                       { txn.abort(); }
+        @Override public boolean promote(Promote mode)      { return txn.promote(mode) ;
}
+        @Override public boolean isInTransaction()          { return txn.isInTransaction();
}
+        @Override public void end()                         { txn.end(); }
+        @Override public ReadWrite transactionMode()        { return txn.transactionMode();
}
+        @Override public TxnType transactionType()          { return txn.transactionType();
}
      
-    @Override public boolean supportsTransactions()     { return true; }
-    @Override public boolean supportsTransactionAbort() { return false; }
-    */
+//        For DatasetGraphs:
+//        @Override public boolean supportsTransactions()     { return true; }
+//        @Override public boolean supportsTransactionAbort() { return false; }
+    }
     
-    public static TransactionalNull create() { return new TransactionalNull(); }
+    public static Transactional create() { return new TransactionalNull(); }
     
     private ThreadLocal<Boolean> inTransaction = ThreadLocal.withInitial(() -> Boolean.FALSE);
     private ThreadLocal<TxnType> txnType = ThreadLocal.withInitial(() -> null);


Mime
View raw message