jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [3/4] jena git commit: Example
Date Tue, 15 Dec 2015 13:07:23 GMT
Example

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

Branch: refs/heads/master
Commit: 65acd7afb6e79e68c6a3d322e218bf459616c516
Parents: a086675
Author: Andy Seaborne <andy@seaborne.org>
Authored: Mon Dec 14 13:18:03 2015 +0000
Committer: Andy Seaborne <andy@seaborne.org>
Committed: Mon Dec 14 13:18:03 2015 +0000

----------------------------------------------------------------------
 .../jena/sparql/core/TransactionalOfOne.java    | 61 ++++++++++++++++++++
 1 file changed, 61 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/65acd7af/jena-arq/src/main/java/org/apache/jena/sparql/core/TransactionalOfOne.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/TransactionalOfOne.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/TransactionalOfOne.java
new file mode 100644
index 0000000..abb54ff
--- /dev/null
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/TransactionalOfOne.java
@@ -0,0 +1,61 @@
+/*
+ * 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 static java.lang.ThreadLocal.withInitial; 
+
+public class TransactionalOfOne implements Transactional
+{
+    private TransactionalComponent component;
+    private ThreadLocal<ReadWrite> state = withInitial(()->null) ;
+    
+    public TransactionalOfOne(TransactionalComponent component) { this.component = component
; }
+    
+    @Override
+    public void begin(ReadWrite readWrite) {
+        state.set(readWrite) ;
+        component.begin(readWrite);
+    }
+    
+    @Override
+    public void commit() {
+        component.commit();
+        end() ;
+    }
+    
+    @Override
+    public void abort() {
+        component.abort();
+        end() ;
+    }
+    
+    @Override
+    public boolean isInTransaction() {
+        return state.get() != null ;
+    }
+    
+    @Override
+    public void end() {
+        if ( isInTransaction() ) {
+            component.end();
+            state.set(null) ;
+        }
+    }
+}


Mime
View raw message