jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [2/9] jena git commit: DatasetGraph impls must state whether they support transactions.
Date Mon, 08 Feb 2016 20:47:01 GMT
DatasetGraph impls must state whether they support transactions.

Mixin for one style provided - does not always work.
Included class as another style also provided.


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

Branch: refs/heads/master
Commit: 6d93dd2f0fb26abcf77041370ad074df14f6b218
Parents: 4ee46b7
Author: Andy Seaborne <andy@apache.org>
Authored: Mon Feb 8 14:58:15 2016 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Mon Feb 8 20:46:38 2016 +0000

----------------------------------------------------------------------
 .../apache/jena/sparql/core/DatasetGraph.java   |  4 +-
 .../sparql/core/TransactionalNotSupported.java  | 49 ++++++++++++++----
 .../core/TransactionalNotSupportedMixin.java    | 52 ++++++++++++++++++++
 3 files changed, 92 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/6d93dd2f/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraph.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraph.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraph.java
index 634fe9a..04d277e 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraph.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraph.java
@@ -152,9 +152,7 @@ public interface DatasetGraph extends Transactional, Closeable
      * See {@link #supportsTransactionAbort()} for {@link #abort}.
      * In addition, check details of a specific implementation.
      */
-    public default boolean supportsTransactions() {
-        return !(this instanceof TransactionalNotSupported);
-    }
+    public boolean supportsTransactions() ;
     
     /** Declare whether {@link #abort} is supported.
      *  This goes along with clearing up after exceptions inside application transaction
code.

http://git-wip-us.apache.org/repos/asf/jena/blob/6d93dd2f/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 69100ac..55e1571 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
@@ -19,34 +19,63 @@
 package org.apache.jena.sparql.core;
 
 import org.apache.jena.query.ReadWrite ;
-import org.apache.jena.shared.LockMutex ;
 
-/** The "un-Transactional" interface.
- * Use with {@link LockMutex}.
+/** Implementation for "un-Transactional" interface.
+ * 
+ * @see TransactionalNotSupportedMixin
  */ 
-public interface TransactionalNotSupported extends Transactional
+public class TransactionalNotSupported implements Transactional
 {
-    // And sometimes implementations will have to include this code
+    /* Using as an interface mixin (trait) and "implements TransactionalNotSupportedMixin"

+     * does not always work. This may be a Eclipse limitation.
+     * The problem arises with hierarchies involving Transactional
+     * where transaction methods are also in the hierarchy. 
+     */
+
+    // 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(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 boolean supportsTransactions()     { return true ; }
+    @Override public boolean supportsTransactionAbort() { return false ; }
+    */
     
     @Override
-    public default void begin(ReadWrite readWrite)
+    public void begin(ReadWrite readWrite)
     { throw new UnsupportedOperationException("Transactional.begin") ; }
 
     @Override
-    public default void commit()
+    public void commit()
     { throw new UnsupportedOperationException("Transactional.commit") ; }
 
     @Override
-    public default void abort()
+    public void abort()
     { throw new UnsupportedOperationException("Transactional.abort") ; }
 
     @Override
-    public default boolean isInTransaction()
+    public boolean isInTransaction()
     { return false ; }
 
     @Override
-    public default void end()
+    public void end()
     { throw new UnsupportedOperationException("Transactional.end") ; }
+    
+    public boolean supportsTransactions() {
+        return false ;
+    }
+    
+    /** Declare whether {@link #abort} is supported.
+     *  This goes along with clearing up after exceptions inside application transaction
code.
+     */
+    public boolean supportsTransactionAbort() {
+        return false;
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/jena/blob/6d93dd2f/jena-arq/src/main/java/org/apache/jena/sparql/core/TransactionalNotSupportedMixin.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/TransactionalNotSupportedMixin.java
b/jena-arq/src/main/java/org/apache/jena/sparql/core/TransactionalNotSupportedMixin.java
new file mode 100644
index 0000000..b6da902
--- /dev/null
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/TransactionalNotSupportedMixin.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.sparql.core;
+
+import org.apache.jena.query.ReadWrite ;
+import org.apache.jena.shared.LockMutex ;
+
+/** Mixin interface for the "un-Transactional" interface.
+ * Use with {@link LockMutex}.
+ * 
+ *  * 
+ * @see TransactionalNotSupportedMixin
+ */ 
+public interface TransactionalNotSupportedMixin extends Transactional
+{
+    @Override
+    public default void begin(ReadWrite readWrite)
+    { throw new UnsupportedOperationException("Transactional.begin") ; }
+
+    @Override
+    public default void commit()
+    { throw new UnsupportedOperationException("Transactional.commit") ; }
+
+    @Override
+    public default void abort()
+    { throw new UnsupportedOperationException("Transactional.abort") ; }
+
+    @Override
+    public default boolean isInTransaction()
+    { return false ; }
+
+    @Override
+    public default void end()
+    { throw new UnsupportedOperationException("Transactional.end") ; }
+}
+


Mime
View raw message