commit 8821a6d30598537c35b3d3b39cd4c6b3402d34a2
parent 311d312efc2608cf787175aa4d5d64f37064d894
Author: Dan Callaghan <djc@djc.id.au>
Date: Sun, 9 May 2010 20:23:19 +1000
extracted interface for SdbTemplate
Diffstat:
2 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/src/main/java/org/deadlit/rdf/util/ModelOperations.java b/src/main/java/org/deadlit/rdf/util/ModelOperations.java
@@ -0,0 +1,21 @@
+package org.deadlit.rdf.util;
+
+import com.hp.hpl.jena.rdf.model.Model;
+
+public interface ModelOperations {
+
+ public static interface ModelExecutionCallback<T> {
+ T execute(Model model);
+ }
+ public static abstract class ModelExecutionCallbackWithoutResult implements ModelExecutionCallback<Object> {
+ @Override
+ final public Object execute(Model model) {
+ executeWithoutResult(model);
+ return null;
+ }
+ protected abstract void executeWithoutResult(Model model);
+ }
+
+ <T> T withModel(ModelExecutionCallback<T> callback);
+
+}
+\ No newline at end of file
diff --git a/src/main/java/org/deadlit/rdf/util/SdbTemplate.java b/src/main/java/org/deadlit/rdf/util/SdbTemplate.java
@@ -16,19 +16,7 @@ import com.hp.hpl.jena.sdb.graph.PrefixMappingSDB;
import com.hp.hpl.jena.sdb.sql.SDBConnection;
@ManagedResource
-public class SdbTemplate {
-
- public static interface ModelExecutionCallback<T> {
- T execute(Model model);
- }
- public static abstract class ModelExecutionCallbackWithoutResult implements ModelExecutionCallback<Object> {
- @Override
- final public Object execute(Model model) {
- executeWithoutResult(model);
- return null;
- }
- protected abstract void executeWithoutResult(Model model);
- }
+public class SdbTemplate implements ModelOperations {
private final DataSource dataSource;
private final StoreDesc storeDesc;
@@ -46,6 +34,7 @@ public class SdbTemplate {
}
}
+ @Override
public <T> T withModel(ModelExecutionCallback<T> callback) {
Store store = create();
store.getLoader().setUseThreading(false);