commit 45905a1e4913cf059aeecfb3ca82da9d37cd649d
parent 8821a6d30598537c35b3d3b39cd4c6b3402d34a2
Author: Dan Callaghan <djc@djc.id.au>
Date: Wed, 12 May 2010 18:17:24 +1000
change group/package to au.id.djc
--HG--
rename : src/main/java/org/deadlit/rdf/util/ModelOperations.java => src/main/java/au/id/djc/jena/util/ModelOperations.java
rename : src/main/java/org/deadlit/rdf/util/SdbTemplate.java => src/main/java/au/id/djc/jena/util/SdbTemplate.java
Diffstat:
5 files changed, 100 insertions(+), 105 deletions(-)
diff --git a/pom.xml b/pom.xml
@@ -1,17 +1,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.deadlit</groupId>
+ <groupId>au.id.djc</groupId>
<artifactId>jena-spring</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Jena Spring integration</name>
- <url>http://code.deadlit.org/</url>
- <organization>
- <name>deadlit.org</name>
- <url>http://deadlit.org/</url>
- </organization>
<properties>
<spring.version>3.0.2.RELEASE</spring.version>
diff --git a/src/main/java/au/id/djc/jena/util/ModelOperations.java b/src/main/java/au/id/djc/jena/util/ModelOperations.java
@@ -0,0 +1,21 @@
+package au.id.djc.jena.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/au/id/djc/jena/util/SdbTemplate.java b/src/main/java/au/id/djc/jena/util/SdbTemplate.java
@@ -0,0 +1,77 @@
+package au.id.djc.jena.util;
+
+import java.sql.SQLException;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
+import org.springframework.jmx.export.annotation.ManagedOperation;
+import org.springframework.jmx.export.annotation.ManagedResource;
+
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.sdb.SDBFactory;
+import com.hp.hpl.jena.sdb.Store;
+import com.hp.hpl.jena.sdb.StoreDesc;
+import com.hp.hpl.jena.sdb.graph.PrefixMappingSDB;
+import com.hp.hpl.jena.sdb.sql.SDBConnection;
+
+@ManagedResource
+public class SdbTemplate implements ModelOperations {
+
+ private final DataSource dataSource;
+ private final StoreDesc storeDesc;
+
+ public SdbTemplate(DataSource dataSource, StoreDesc storeDesc) {
+ this.dataSource = dataSource;
+ this.storeDesc = storeDesc;
+ }
+
+ private Store create() {
+ try {
+ return SDBFactory.connectStore(new SDBConnection(dataSource), storeDesc);
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public <T> T withModel(ModelExecutionCallback<T> callback) {
+ Store store = create();
+ store.getLoader().setUseThreading(false);
+ try {
+ Model model = SDBFactory.connectDefaultModel(store);
+ try {
+ return callback.execute(model);
+ } finally {
+ model.close();
+ }
+ } finally {
+ store.getConnection().close();
+ store.close();
+ }
+ }
+
+ @ManagedOperation(description = "Creates the tables and indices necessary for SDB")
+ public void format() {
+ Store store = create();
+ store.getLoader().setUseThreading(false);
+ try {
+ store.getTableFormatter().create();
+ } finally {
+ store.close();
+ }
+ }
+
+ @ManagedOperation
+ public Map<String, String> getPrefixMappings() throws SQLException {
+ PrefixMappingSDB mapping = new PrefixMappingSDB(null, new SDBConnection(dataSource));
+ return mapping.getNsPrefixMap();
+ }
+
+ @ManagedOperation
+ public void addPrefixMapping(String prefix, String uri) throws SQLException {
+ PrefixMappingSDB mapping = new PrefixMappingSDB(null, new SDBConnection(dataSource));
+ mapping.setNsPrefix(prefix, uri);
+ }
+
+}
diff --git a/src/main/java/org/deadlit/rdf/util/ModelOperations.java b/src/main/java/org/deadlit/rdf/util/ModelOperations.java
@@ -1,21 +0,0 @@
-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
@@ -1,77 +0,0 @@
-package org.deadlit.rdf.util;
-
-import java.sql.SQLException;
-import java.util.Map;
-
-import javax.sql.DataSource;
-
-import org.springframework.jmx.export.annotation.ManagedOperation;
-import org.springframework.jmx.export.annotation.ManagedResource;
-
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.sdb.SDBFactory;
-import com.hp.hpl.jena.sdb.Store;
-import com.hp.hpl.jena.sdb.StoreDesc;
-import com.hp.hpl.jena.sdb.graph.PrefixMappingSDB;
-import com.hp.hpl.jena.sdb.sql.SDBConnection;
-
-@ManagedResource
-public class SdbTemplate implements ModelOperations {
-
- private final DataSource dataSource;
- private final StoreDesc storeDesc;
-
- public SdbTemplate(DataSource dataSource, StoreDesc storeDesc) {
- this.dataSource = dataSource;
- this.storeDesc = storeDesc;
- }
-
- private Store create() {
- try {
- return SDBFactory.connectStore(new SDBConnection(dataSource), storeDesc);
- } catch (SQLException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public <T> T withModel(ModelExecutionCallback<T> callback) {
- Store store = create();
- store.getLoader().setUseThreading(false);
- try {
- Model model = SDBFactory.connectDefaultModel(store);
- try {
- return callback.execute(model);
- } finally {
- model.close();
- }
- } finally {
- store.getConnection().close();
- store.close();
- }
- }
-
- @ManagedOperation(description = "Creates the tables and indices necessary for SDB")
- public void format() {
- Store store = create();
- store.getLoader().setUseThreading(false);
- try {
- store.getTableFormatter().create();
- } finally {
- store.close();
- }
- }
-
- @ManagedOperation
- public Map<String, String> getPrefixMappings() throws SQLException {
- PrefixMappingSDB mapping = new PrefixMappingSDB(null, new SDBConnection(dataSource));
- return mapping.getNsPrefixMap();
- }
-
- @ManagedOperation
- public void addPrefixMapping(String prefix, String uri) throws SQLException {
- PrefixMappingSDB mapping = new PrefixMappingSDB(null, new SDBConnection(dataSource));
- mapping.setNsPrefix(prefix, uri);
- }
-
-}