You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2014/01/10 18:09:19 UTC

[1/4] git commit: MARMOTTA-418: switched all modules to new LDCache API

Updated Branches:
  refs/heads/develop e030d8805 -> 8941574ce


MARMOTTA-418: switched all modules to new LDCache API


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

Branch: refs/heads/develop
Commit: aa843450b63b029466129afb4c9a5f7eb1ec84e5
Parents: e030d88
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Fri Jan 10 18:01:11 2014 +0100
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Fri Jan 10 18:01:11 2014 +0100

----------------------------------------------------------------------
 .../commons/sesame/model/ModelCommons.java      |  2 +-
 .../backend/kiwi/LDCachingKiWiBackendNG.java    | 69 +++++++++++++-------
 .../services/test/LDCacheKiWiNGTest.java        |  4 +-
 .../ldcache/sail/GenericLinkedDataSail.java     | 26 ++++----
 .../sail/GenericLinkedDataSailConnection.java   | 51 ++++-----------
 .../test/GenericLinkedDataSailOfflineTest.java  |  6 +-
 .../ldcache/sail/KiWiLinkedDataSail.java        | 16 ++---
 .../sail/KiWiLinkedDataSailConnection.java      | 15 ++---
 .../backend/linkeddata/LDPersistentBackend.java |  6 +-
 .../api/ldcache/LDCacheSailProvider.java        |  6 +-
 .../services/kiwi/FileLDCacheSailProvider.java  | 12 ++--
 .../services/kiwi/KiWiLDCacheSailProvider.java  |  6 +-
 12 files changed, 103 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/ModelCommons.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/ModelCommons.java b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/ModelCommons.java
index 6a1b338..d4bb143 100644
--- a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/ModelCommons.java
+++ b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/model/ModelCommons.java
@@ -126,7 +126,7 @@ public class ModelCommons {
      * @throws IOException
      * @throws RDFParseException
      */
-    public static <X extends Exception> void add(Model model, CloseableIteration<Statement,X> triples, Predicate<Statement>... filters) throws X {
+    public static <X extends Exception> void add(Model model, CloseableIteration<? extends Statement,X> triples, Predicate<Statement>... filters) throws X {
         try {
             rloop: while(triples.hasNext()) {
                 Statement st = triples.next();

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackendNG.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackendNG.java b/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackendNG.java
index 3102caa..dd5082c 100644
--- a/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackendNG.java
+++ b/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackendNG.java
@@ -27,14 +27,15 @@ import org.apache.marmotta.ldcache.backend.kiwi.persistence.LDCachingKiWiPersist
 import org.apache.marmotta.ldcache.model.CacheEntry;
 import org.openrdf.model.Model;
 import org.openrdf.model.Resource;
+import org.openrdf.model.Statement;
 import org.openrdf.model.URI;
 import org.openrdf.model.impl.TreeModel;
 import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
 import org.openrdf.repository.base.RepositoryWrapper;
 import org.openrdf.repository.sail.SailRepository;
 import org.openrdf.sail.Sail;
+import org.openrdf.sail.SailConnection;
+import org.openrdf.sail.SailException;
 import org.openrdf.sail.helpers.SailWrapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -64,7 +65,7 @@ public class LDCachingKiWiBackendNG implements LDCachingBackendNG {
     /**
      * Repository API access to the cache data
      */
-    protected Repository repository;
+    protected KiWiStore store;
 
 
     /**
@@ -75,7 +76,19 @@ public class LDCachingKiWiBackendNG implements LDCachingBackendNG {
      */
     public LDCachingKiWiBackendNG(Repository repository, String cacheContext) {
         this.cacheContext = cacheContext;
-        this.repository   = repository;
+        this.store   = getStore(repository);
+        this.persistence  = new LDCachingKiWiPersistence(getStore(repository).getPersistence());
+    }
+
+    /**
+     * Create a new LDCache KiWi backend using the given store and context for caching triples and storing cache
+     * metadata via JDBC in the database.
+     *
+     * @param cacheContext
+     */
+    public LDCachingKiWiBackendNG(Sail repository, String cacheContext) {
+        this.cacheContext = cacheContext;
+        this.store   = getStore(repository);
         this.persistence  = new LDCachingKiWiPersistence(getStore(repository).getPersistence());
     }
 
@@ -124,16 +137,16 @@ public class LDCachingKiWiBackendNG implements LDCachingBackendNG {
 
                 // if entry exists, load triples for the resource from the cache context of the repository
                 if(ce != null) {
-                    RepositoryConnection con = repository.getConnection();
+                    SailConnection con = store.getConnection();
                     try {
                         con.begin();
 
                         Model triples = new TreeModel();
-                        ModelCommons.add(triples,con.getStatements(resource,null,null,true,con.getValueFactory().createURI(cacheContext)));
+                        ModelCommons.add(triples,con.getStatements(resource,null,null,true,store.getValueFactory().createURI(cacheContext)));
                         ce.setTriples(triples);
 
                         con.commit();
-                    } catch(RepositoryException ex) {
+                    } catch(SailException ex) {
                         con.rollback();
                     } finally {
                         con.close();
@@ -143,7 +156,7 @@ public class LDCachingKiWiBackendNG implements LDCachingBackendNG {
 
             }
 
-        } catch (RepositoryException | SQLException e) {
+        } catch (SailException | SQLException e) {
             log.error("could not retrieve cached triples from repository",e);
         }
 
@@ -165,19 +178,21 @@ public class LDCachingKiWiBackendNG implements LDCachingBackendNG {
                 dbcon.removeCacheEntry(resource.stringValue());
 
                 // update triples in cache
-                RepositoryConnection con = repository.getConnection();
+                SailConnection con = store.getConnection();
                 try {
                     con.begin();
 
-                    con.remove(resource,null,null,con.getValueFactory().createURI(cacheContext));
-                    con.add(entry.getTriples(),con.getValueFactory().createURI(cacheContext));
+                    con.removeStatements(resource, null, null, store.getValueFactory().createURI(cacheContext));
+                    for(Statement stmt : entry.getTriples()) {
+                        con.addStatement(stmt.getSubject(), stmt.getPredicate(), stmt.getObject(), store.getValueFactory().createURI(cacheContext));
+                    }
 
                     con.commit();
 
-                    entry.setResource(con.getValueFactory().createURI(resource.stringValue()));
+                    entry.setResource(store.getValueFactory().createURI(resource.stringValue()));
 
                     dbcon.storeCacheEntry(entry);
-                } catch(RepositoryException ex) {
+                } catch(SailException ex) {
                     con.rollback();
                 } finally {
                     con.close();
@@ -185,7 +200,7 @@ public class LDCachingKiWiBackendNG implements LDCachingBackendNG {
 
             }
 
-        } catch (RepositoryException | SQLException e) {
+        } catch (SailException | SQLException e) {
             log.error("could not retrieve cached triples from repository",e);
         }
 
@@ -205,14 +220,14 @@ public class LDCachingKiWiBackendNG implements LDCachingBackendNG {
                 dbcon.removeCacheEntry(resource.stringValue());
 
                 // update triples in cache
-                RepositoryConnection con = repository.getConnection();
+                SailConnection con = store.getConnection();
                 try {
                     con.begin();
 
-                    con.remove(resource, null, null, con.getValueFactory().createURI(cacheContext));
+                    con.removeStatements(resource, null, null, store.getValueFactory().createURI(cacheContext));
 
                     con.commit();
-                } catch(RepositoryException ex) {
+                } catch(SailException ex) {
                     con.rollback();
                 } finally {
                     con.close();
@@ -220,8 +235,8 @@ public class LDCachingKiWiBackendNG implements LDCachingBackendNG {
 
             }
 
-        } catch (RepositoryException | SQLException e) {
-            log.error("could not retrieve cached triples from repository",e);
+        } catch (SailException | SQLException e) {
+            log.error("could not remove cached triples from repository",e);
         }
     }
 
@@ -240,14 +255,14 @@ public class LDCachingKiWiBackendNG implements LDCachingBackendNG {
                 }
 
                 // update triples in cache
-                RepositoryConnection con = repository.getConnection();
+                SailConnection con = store.getConnection();
                 try {
                     con.begin();
 
-                    con.remove((Resource)null,null,null,con.getValueFactory().createURI(cacheContext));
+                    con.removeStatements((Resource) null, null, null, store.getValueFactory().createURI(cacheContext));
 
                     con.commit();
-                } catch(RepositoryException ex) {
+                } catch(SailException ex) {
                     con.rollback();
                 } finally {
                     con.close();
@@ -255,8 +270,8 @@ public class LDCachingKiWiBackendNG implements LDCachingBackendNG {
 
             }
 
-        } catch (RepositoryException | SQLException e) {
-            log.error("could not retrieve cached triples from repository",e);
+        } catch (SailException | SQLException e) {
+            log.error("could not remove cached triples from repository",e);
         }
 
     }
@@ -273,7 +288,7 @@ public class LDCachingKiWiBackendNG implements LDCachingBackendNG {
         }
 
         // register cache context in database
-        repository.getValueFactory().createURI(cacheContext);
+        store.getValueFactory().createURI(cacheContext);
 
     }
 
@@ -283,4 +298,8 @@ public class LDCachingKiWiBackendNG implements LDCachingBackendNG {
     @Override
     public void shutdown() {
     }
+
+    public LDCachingKiWiPersistence getPersistence() {
+        return persistence;
+    }
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiNGTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiNGTest.java b/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiNGTest.java
index a67587f..4b822bc 100644
--- a/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiNGTest.java
+++ b/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiNGTest.java
@@ -129,7 +129,7 @@ public class LDCacheKiWiNGTest extends BaseLDCacheNGTest {
     protected LDCachingBackendNG createBackend() {
         try {
             KiWiStore store = new KiWiStore("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred");
-            Repository repository = new SailRepository(store);
+            final Repository repository = new SailRepository(store);
             repository.initialize();
 
             LDCachingKiWiBackendNG backend = new LDCachingKiWiBackendNG(repository, CACHE_CONTEXT) {
@@ -141,7 +141,7 @@ public class LDCacheKiWiNGTest extends BaseLDCacheNGTest {
 
                     try {
                         persistence.dropDatabase();
-                        getStore(repository).getPersistence().dropDatabase();
+                        store.getPersistence().dropDatabase();
 
                         super.shutdown();
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSail.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSail.java b/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSail.java
index f41879c..c4936bc 100644
--- a/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSail.java
+++ b/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSail.java
@@ -19,9 +19,9 @@ package org.apache.marmotta.ldcache.sail;
 
 import org.apache.marmotta.commons.sesame.filter.AlwaysTrueFilter;
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
-import org.apache.marmotta.ldcache.api.LDCachingBackend;
+import org.apache.marmotta.ldcache.api.LDCachingBackendNG;
 import org.apache.marmotta.ldcache.model.CacheConfiguration;
-import org.apache.marmotta.ldcache.services.LDCache;
+import org.apache.marmotta.ldcache.services.LDCacheNG;
 import org.apache.marmotta.ldclient.model.ClientConfiguration;
 import org.openrdf.model.Resource;
 import org.openrdf.sail.NotifyingSail;
@@ -37,32 +37,32 @@ import org.openrdf.sail.helpers.NotifyingSailWrapper;
  */
 public class GenericLinkedDataSail extends NotifyingSailWrapper {
 
-	private final LDCachingBackend cachingBackend;
+	private final LDCachingBackendNG cachingBackend;
 	private CacheConfiguration config;
-	private LDCache ldcache;
+	private LDCacheNG ldcache;
 	private SesameFilter<Resource> acceptForCaching;
 
-	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackend cachingBackend) {
+	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackendNG cachingBackend) {
 		this(base, cachingBackend, new AlwaysTrueFilter<Resource>(), createCacheConfiguration(null));
 	}
 
-	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackend cachingBackend, ClientConfiguration clientConfig) {
+	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackendNG cachingBackend, ClientConfiguration clientConfig) {
 		this(base, cachingBackend, new AlwaysTrueFilter<Resource>(), clientConfig);
 	}
 
-	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackend cachingBackend, CacheConfiguration cacheConfig) {
+	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackendNG cachingBackend, CacheConfiguration cacheConfig) {
 		this(base, cachingBackend, new AlwaysTrueFilter<Resource>(), cacheConfig);
 	}
 	
-	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackend cachingBackend, SesameFilter<Resource> acceptForCaching) {
+	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackendNG cachingBackend, SesameFilter<Resource> acceptForCaching) {
 		this(base, cachingBackend, acceptForCaching, createCacheConfiguration(null));
 	}
 
-	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackend cachingBackend, SesameFilter<Resource> acceptForCaching, ClientConfiguration clientConfig) {
+	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackendNG cachingBackend, SesameFilter<Resource> acceptForCaching, ClientConfiguration clientConfig) {
 		this(base, cachingBackend, acceptForCaching, createCacheConfiguration(clientConfig));
 	}
 
-	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackend cachingBackend, SesameFilter<Resource> acceptForCaching, CacheConfiguration cacheConfig) {
+	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackendNG cachingBackend, SesameFilter<Resource> acceptForCaching, CacheConfiguration cacheConfig) {
 		super(base);
 		this.cachingBackend = cachingBackend;
 		this.acceptForCaching = acceptForCaching;
@@ -88,7 +88,7 @@ public class GenericLinkedDataSail extends NotifyingSailWrapper {
 		
 		cachingBackend.initialize();
 		
-		ldcache = new LDCache(this.config,cachingBackend);
+		ldcache = new LDCacheNG(this.config,cachingBackend);
 	}
 	
 	@Override
@@ -102,14 +102,14 @@ public class GenericLinkedDataSail extends NotifyingSailWrapper {
 	
 	public void reinit() {
 		ldcache.shutdown();
-		ldcache = new LDCache(this.config,cachingBackend);
+		ldcache = new LDCacheNG(this.config,cachingBackend);
 	}
 	
 	public CacheConfiguration getCacheConfiguration() {
 		return config;
 	}
 
-    public LDCache getLDCache() {
+    public LDCacheNG getLDCache() {
         return ldcache;
     }
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSailConnection.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSailConnection.java b/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSailConnection.java
index b67977e..3eb996a 100644
--- a/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSailConnection.java
+++ b/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSailConnection.java
@@ -18,19 +18,13 @@
 package org.apache.marmotta.ldcache.sail;
 
 import info.aduna.iteration.CloseableIteration;
-
-import info.aduna.iteration.ExceptionConvertingIteration;
+import info.aduna.iteration.CloseableIteratorIteration;
 import info.aduna.iteration.UnionIteration;
 import org.apache.marmotta.commons.sesame.filter.AlwaysTrueFilter;
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
 import org.apache.marmotta.commons.sesame.repository.ResourceUtils;
-import org.apache.marmotta.ldcache.api.LDCachingConnection;
-import org.apache.marmotta.ldcache.services.LDCache;
-import org.openrdf.model.Resource;
-import org.openrdf.model.Statement;
-import org.openrdf.model.URI;
-import org.openrdf.model.Value;
-import org.openrdf.repository.RepositoryException;
+import org.apache.marmotta.ldcache.services.LDCacheNG;
+import org.openrdf.model.*;
 import org.openrdf.sail.NotifyingSailConnection;
 import org.openrdf.sail.SailException;
 import org.openrdf.sail.helpers.NotifyingSailConnectionWrapper;
@@ -49,15 +43,15 @@ public class GenericLinkedDataSailConnection extends NotifyingSailConnectionWrap
 
     private static Logger log = LoggerFactory.getLogger(GenericLinkedDataSailConnection.class);
 
-    private final LDCache ldcache;
+    private final LDCacheNG ldcache;
     private final SesameFilter<Resource> acceptForCaching;
 
-    public GenericLinkedDataSailConnection(NotifyingSailConnection connection, LDCache ldcache) {
+    public GenericLinkedDataSailConnection(NotifyingSailConnection connection, LDCacheNG ldcache) {
         this(connection, ldcache, new AlwaysTrueFilter<Resource>());
     }
 
 
-    public GenericLinkedDataSailConnection(NotifyingSailConnection connection, LDCache ldcache, SesameFilter<Resource> acceptForCaching) {
+    public GenericLinkedDataSailConnection(NotifyingSailConnection connection, LDCacheNG ldcache, SesameFilter<Resource> acceptForCaching) {
         super(connection);
         this.ldcache = ldcache;
         this.acceptForCaching = acceptForCaching;
@@ -81,34 +75,13 @@ public class GenericLinkedDataSailConnection extends NotifyingSailConnectionWrap
 
         if (accept(subj)) {
             log.debug("Refreshing resource: {}", subj.stringValue());
-            ldcache.refreshResource((URI) subj, false);
-
-            try {
-                final LDCachingConnection cachingConnection = ldcache.getCacheConnection(subj.stringValue());
-                // join the results of the cache connection and the wrapped connection in a single result
-                return new UnionIteration<Statement, SailException>(
-                        new ExceptionConvertingIteration<Statement, SailException>(cachingConnection.getStatements(subj,pred,obj,includeInferred, contexts)) {
-                            @Override
-                            protected SailException convert(Exception e) {
-                                return new SailException("error while accessing cache connection",e);
-                            }
-
-                            @Override
-                            protected void handleClose() throws SailException {
-                                super.handleClose();
+            final Model cached = ldcache.get((URI)subj);
 
-                                try {
-                                    cachingConnection.close();
-                                } catch (RepositoryException e) {
-                                    throw new SailException("error while closing cache connection",e);
-                                }
-                            }
-                        },
-                        super.getStatements(subj, pred, obj, includeInferred, contexts)
-                );
-            } catch (RepositoryException e) {
-                throw new SailException("error while accessing cache connection",e);
-            }
+            // join the results of the cache connection and the wrapped connection in a single result
+            return new UnionIteration<Statement, SailException>(
+                    new CloseableIteratorIteration<Statement,SailException>(cached.iterator()),
+                    super.getStatements(subj, pred, obj, includeInferred, contexts)
+            );
         } else {
             return super.getStatements(subj, pred, obj, includeInferred, contexts);
         }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/libraries/ldcache/ldcache-sail-generic/src/test/java/org/apache/marmotta/ldcache/sail/test/GenericLinkedDataSailOfflineTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-sail-generic/src/test/java/org/apache/marmotta/ldcache/sail/test/GenericLinkedDataSailOfflineTest.java b/libraries/ldcache/ldcache-sail-generic/src/test/java/org/apache/marmotta/ldcache/sail/test/GenericLinkedDataSailOfflineTest.java
index 0d4ef57..4bff0ac 100644
--- a/libraries/ldcache/ldcache-sail-generic/src/test/java/org/apache/marmotta/ldcache/sail/test/GenericLinkedDataSailOfflineTest.java
+++ b/libraries/ldcache/ldcache-sail-generic/src/test/java/org/apache/marmotta/ldcache/sail/test/GenericLinkedDataSailOfflineTest.java
@@ -21,7 +21,7 @@ import info.aduna.iteration.Iterations;
 import org.apache.commons.io.FileUtils;
 import org.apache.marmotta.commons.sesame.filter.resource.ResourceFilter;
 import org.apache.marmotta.commons.sesame.filter.resource.UriPrefixFilter;
-import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackend;
+import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackendNG;
 import org.apache.marmotta.ldcache.sail.GenericLinkedDataSail;
 import org.apache.marmotta.ldcache.services.test.dummy.DummyEndpoint;
 import org.apache.marmotta.ldclient.model.ClientConfiguration;
@@ -60,7 +60,7 @@ public class GenericLinkedDataSailOfflineTest {
 
     private Repository repository;
 
-    private LDCachingFileBackend backend;
+    private LDCachingFileBackendNG backend;
 
     private GenericLinkedDataSail lsail;
 
@@ -76,7 +76,7 @@ public class GenericLinkedDataSailOfflineTest {
 
         tmpDirectory = Files.createTempDir();
 
-        backend = new LDCachingFileBackend(tmpDirectory);
+        backend = new LDCachingFileBackendNG(tmpDirectory);
         lsail = new GenericLinkedDataSail(new MemoryStore(),backend, cacheFilter, config);
         repository = new SailRepository(lsail);
         repository.initialize();

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSail.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSail.java b/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSail.java
index 70a0625..a571234 100644
--- a/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSail.java
+++ b/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSail.java
@@ -19,9 +19,9 @@ package org.apache.marmotta.ldcache.sail;
 
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
 import org.apache.marmotta.kiwi.sail.KiWiStore;
-import org.apache.marmotta.ldcache.backend.kiwi.LDCachingKiWiBackend;
+import org.apache.marmotta.ldcache.backend.kiwi.LDCachingKiWiBackendNG;
 import org.apache.marmotta.ldcache.model.CacheConfiguration;
-import org.apache.marmotta.ldcache.services.LDCache;
+import org.apache.marmotta.ldcache.services.LDCacheNG;
 import org.apache.marmotta.ldclient.model.ClientConfiguration;
 import org.openrdf.model.Resource;
 import org.openrdf.sail.NotifyingSail;
@@ -39,9 +39,9 @@ public class KiWiLinkedDataSail extends NotifyingSailWrapper {
 
     private KiWiStore store;
 
-    private LDCachingKiWiBackend backend;
+    private LDCachingKiWiBackendNG backend;
 
-    private LDCache ldcache;
+    private LDCacheNG ldcache;
 
     private SesameFilter<Resource> acceptor;
 
@@ -88,10 +88,10 @@ public class KiWiLinkedDataSail extends NotifyingSailWrapper {
     public void initialize() throws SailException {
         super.initialize();
 
-        backend = new LDCachingKiWiBackend(store, cache_context);
+        backend = new LDCachingKiWiBackendNG(store, cache_context);
         backend.initialize();
 
-        ldcache = new LDCache(config,backend);
+        ldcache = new LDCacheNG(config,backend);
 
     }
 
@@ -126,11 +126,11 @@ public class KiWiLinkedDataSail extends NotifyingSailWrapper {
         }
     }
 
-    public LDCachingKiWiBackend getBackend() {
+    public LDCachingKiWiBackendNG getBackend() {
         return backend;
     }
 
-    public LDCache getLDCache() {
+    public LDCacheNG getLDCache() {
         return ldcache;
     }
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSailConnection.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSailConnection.java b/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSailConnection.java
index d9141b3..36dae58 100644
--- a/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSailConnection.java
+++ b/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSailConnection.java
@@ -18,14 +18,9 @@
 package org.apache.marmotta.ldcache.sail;
 
 import info.aduna.iteration.CloseableIteration;
-
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
-import org.apache.marmotta.ldcache.services.LDCache;
-import org.openrdf.model.BNode;
-import org.openrdf.model.Resource;
-import org.openrdf.model.Statement;
-import org.openrdf.model.URI;
-import org.openrdf.model.Value;
+import org.apache.marmotta.ldcache.services.LDCacheNG;
+import org.openrdf.model.*;
 import org.openrdf.sail.NotifyingSailConnection;
 import org.openrdf.sail.SailException;
 import org.openrdf.sail.helpers.NotifyingSailConnectionWrapper;
@@ -37,11 +32,11 @@ import org.openrdf.sail.helpers.NotifyingSailConnectionWrapper;
  */
 public class KiWiLinkedDataSailConnection extends NotifyingSailConnectionWrapper {
 
-    private LDCache ldcache;
+    private LDCacheNG ldcache;
 
     private SesameFilter<Resource> acceptor;
 
-    public KiWiLinkedDataSailConnection(NotifyingSailConnection wrappedCon, LDCache ldcache, SesameFilter<Resource> acceptor) {
+    public KiWiLinkedDataSailConnection(NotifyingSailConnection wrappedCon, LDCacheNG ldcache, SesameFilter<Resource> acceptor) {
         super(wrappedCon);
 
         this.ldcache = ldcache;
@@ -59,7 +54,7 @@ public class KiWiLinkedDataSailConnection extends NotifyingSailConnectionWrapper
     @Override
     public CloseableIteration<? extends Statement, SailException> getStatements(Resource subj, URI pred, Value obj, boolean includeInferred, Resource... contexts) throws SailException {
         if(subj != null && isAcceptable(subj)) {
-            ldcache.refreshResource((URI)subj,false);
+            ldcache.refresh((URI) subj);
         }
 
         // the refreshed resources will anyways be stored in the same triple store, so we can simply delegate the query

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/libraries/ldpath/ldpath-backend-linkeddata/src/main/java/org/apache/marmotta/ldpath/backend/linkeddata/LDPersistentBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-linkeddata/src/main/java/org/apache/marmotta/ldpath/backend/linkeddata/LDPersistentBackend.java b/libraries/ldpath/ldpath-backend-linkeddata/src/main/java/org/apache/marmotta/ldpath/backend/linkeddata/LDPersistentBackend.java
index 1e56703..a7d2067 100644
--- a/libraries/ldpath/ldpath-backend-linkeddata/src/main/java/org/apache/marmotta/ldpath/backend/linkeddata/LDPersistentBackend.java
+++ b/libraries/ldpath/ldpath-backend-linkeddata/src/main/java/org/apache/marmotta/ldpath/backend/linkeddata/LDPersistentBackend.java
@@ -19,7 +19,7 @@ package org.apache.marmotta.ldpath.backend.linkeddata;
 
 import org.apache.marmotta.commons.sesame.filter.AlwaysTrueFilter;
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
-import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackend;
+import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackendNG;
 import org.apache.marmotta.ldcache.sail.GenericLinkedDataSail;
 import org.apache.marmotta.ldclient.model.ClientConfiguration;
 import org.apache.marmotta.ldpath.backend.sesame.SesameRepositoryBackend;
@@ -43,7 +43,7 @@ import java.io.IOException;
 public class LDPersistentBackend extends SesameRepositoryBackend {
     private static final Logger log = LoggerFactory.getLogger(LDPersistentBackend.class);
 
-    private LDCachingFileBackend backend;
+    private LDCachingFileBackendNG backend;
 
     private GenericLinkedDataSail sail;
 
@@ -72,7 +72,7 @@ public class LDPersistentBackend extends SesameRepositoryBackend {
         try {
             ClientConfiguration config = new ClientConfiguration();
 
-            backend = new LDCachingFileBackend(dataDirectory);
+            backend = new LDCachingFileBackendNG(dataDirectory);
             sail = new GenericLinkedDataSail(new MemoryStore(),backend, cacheFilter, config);
             Repository repository = new SailRepository(sail);
             repository.initialize();

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/platform/ldcache/marmotta-ldcache-common/src/main/java/org/apache/marmotta/platform/ldcache/api/ldcache/LDCacheSailProvider.java
----------------------------------------------------------------------
diff --git a/platform/ldcache/marmotta-ldcache-common/src/main/java/org/apache/marmotta/platform/ldcache/api/ldcache/LDCacheSailProvider.java b/platform/ldcache/marmotta-ldcache-common/src/main/java/org/apache/marmotta/platform/ldcache/api/ldcache/LDCacheSailProvider.java
index 2cc597d..f99a23e 100644
--- a/platform/ldcache/marmotta-ldcache-common/src/main/java/org/apache/marmotta/platform/ldcache/api/ldcache/LDCacheSailProvider.java
+++ b/platform/ldcache/marmotta-ldcache-common/src/main/java/org/apache/marmotta/platform/ldcache/api/ldcache/LDCacheSailProvider.java
@@ -17,7 +17,7 @@
 
 package org.apache.marmotta.platform.ldcache.api.ldcache;
 
-import org.apache.marmotta.ldcache.services.LDCache;
+import org.apache.marmotta.ldcache.services.LDCacheNG;
 import org.apache.marmotta.ldclient.api.endpoint.Endpoint;
 import org.apache.marmotta.ldclient.api.ldclient.LDClientService;
 import org.apache.marmotta.ldclient.model.ClientConfiguration;
@@ -79,7 +79,7 @@ public abstract class LDCacheSailProvider implements NotifyingSailProvider {
      * @return
      */
     public boolean isCached(URI resource) throws RepositoryException {
-        return getLDCache().isCached(resource.stringValue());
+        return getLDCache().contains(resource);
     }
 
     /**
@@ -155,7 +155,7 @@ public abstract class LDCacheSailProvider implements NotifyingSailProvider {
      * Return the caching backend used by the caching system (e.g. for debugging)
      * @return
      */
-    public abstract LDCache getLDCache();
+    public abstract LDCacheNG getLDCache();
 
     /**
      * Add a volatile (in-memory) endpoint to the LDClient configuration. Can be used by other services for auto-registering

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java
----------------------------------------------------------------------
diff --git a/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java b/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java
index 394a4a2..b71ac41 100644
--- a/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java
+++ b/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java
@@ -20,9 +20,9 @@ import com.google.common.collect.Lists;
 import org.apache.marmotta.commons.sesame.filter.NotFilter;
 import org.apache.marmotta.commons.sesame.filter.OneOfFilter;
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
-import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackend;
+import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackendNG;
 import org.apache.marmotta.ldcache.sail.GenericLinkedDataSail;
-import org.apache.marmotta.ldcache.services.LDCache;
+import org.apache.marmotta.ldcache.services.LDCacheNG;
 import org.apache.marmotta.ldclient.api.ldclient.LDClientService;
 import org.apache.marmotta.platform.core.model.filter.MarmottaLocalFilter;
 import org.apache.marmotta.platform.ldcache.api.ldcache.LDCacheSailProvider;
@@ -51,7 +51,7 @@ public class FileLDCacheSailProvider extends LDCacheSailProvider {
 
     private static Logger log = LoggerFactory.getLogger(FileLDCacheSailProvider.class);
 
-    private LDCachingFileBackend backend;
+    private LDCachingFileBackendNG backend;
 
     private GenericLinkedDataSail sail;
 
@@ -87,7 +87,7 @@ public class FileLDCacheSailProvider extends LDCacheSailProvider {
         directory = new File(configurationService.getHome() + File.separator + "ldcache");
 
         try {
-            backend = new LDCachingFileBackend(directory);
+            backend = new LDCachingFileBackendNG(directory);
             sail = new GenericLinkedDataSail(parent, backend, new NotFilter<Resource>(cacheFilters), ldclientConfig);
             return sail;
         } catch (RepositoryException e) {
@@ -103,7 +103,7 @@ public class FileLDCacheSailProvider extends LDCacheSailProvider {
      */
     public LDClientService getLDClient() {
         if(sail != null) {
-            return sail.getLDCache().getLDClient();
+            return sail.getLDCache().getClient();
         } else {
             return null;
         }
@@ -113,7 +113,7 @@ public class FileLDCacheSailProvider extends LDCacheSailProvider {
      * Return the caching backend used by the caching system (e.g. for debugging)
      * @return
      */
-    public LDCache getLDCache() {
+    public LDCacheNG getLDCache() {
         if(sail != null) {
             return sail.getLDCache();
         } else {

http://git-wip-us.apache.org/repos/asf/marmotta/blob/aa843450/platform/ldcache/marmotta-ldcache-kiwi/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/KiWiLDCacheSailProvider.java
----------------------------------------------------------------------
diff --git a/platform/ldcache/marmotta-ldcache-kiwi/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/KiWiLDCacheSailProvider.java b/platform/ldcache/marmotta-ldcache-kiwi/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/KiWiLDCacheSailProvider.java
index e97737d..cb8f328 100644
--- a/platform/ldcache/marmotta-ldcache-kiwi/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/KiWiLDCacheSailProvider.java
+++ b/platform/ldcache/marmotta-ldcache-kiwi/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/KiWiLDCacheSailProvider.java
@@ -22,7 +22,7 @@ import org.apache.marmotta.commons.sesame.filter.NotFilter;
 import org.apache.marmotta.commons.sesame.filter.OneOfFilter;
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
 import org.apache.marmotta.ldcache.sail.KiWiLinkedDataSail;
-import org.apache.marmotta.ldcache.services.LDCache;
+import org.apache.marmotta.ldcache.services.LDCacheNG;
 import org.apache.marmotta.ldclient.api.ldclient.LDClientService;
 import org.apache.marmotta.platform.core.model.filter.MarmottaLocalFilter;
 import org.apache.marmotta.platform.ldcache.api.ldcache.LDCacheSailProvider;
@@ -85,7 +85,7 @@ public class KiWiLDCacheSailProvider extends LDCacheSailProvider {
      */
     public LDClientService getLDClient() {
         if(sail != null) {
-            return sail.getLDCache().getLDClient();
+            return sail.getLDCache().getClient();
         } else {
             return null;
         }
@@ -95,7 +95,7 @@ public class KiWiLDCacheSailProvider extends LDCacheSailProvider {
      * Return the caching backend used by the caching system (e.g. for debugging)
      * @return
      */
-    public LDCache getLDCache() {
+    public LDCacheNG getLDCache() {
         if(sail != null) {
             return sail.getLDCache();
         } else {


[2/4] MARMOTTA-418: removed old LDCache API

Posted by ss...@apache.org.
http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-core/src/main/java/org/apache/marmotta/ldcache/services/LDCache.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-core/src/main/java/org/apache/marmotta/ldcache/services/LDCache.java b/libraries/ldcache/ldcache-core/src/main/java/org/apache/marmotta/ldcache/services/LDCache.java
index 0605fc9..ca2bae2 100644
--- a/libraries/ldcache/ldcache-core/src/main/java/org/apache/marmotta/ldcache/services/LDCache.java
+++ b/libraries/ldcache/ldcache-core/src/main/java/org/apache/marmotta/ldcache/services/LDCache.java
@@ -1,13 +1,12 @@
-/**
- * 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
+/*
+ * 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
+ *      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,
@@ -15,15 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.marmotta.ldcache.services;
 
-import info.aduna.iteration.CloseableIteration;
 import org.apache.marmotta.commons.locking.ObjectLocks;
-import org.apache.marmotta.commons.sesame.model.ModelCommons;
 import org.apache.marmotta.ldcache.api.LDCachingBackend;
-import org.apache.marmotta.ldcache.api.LDCachingConnection;
 import org.apache.marmotta.ldcache.api.LDCachingService;
-import org.apache.marmotta.ldcache.api.LDCachingServiceNG;
 import org.apache.marmotta.ldcache.model.CacheConfiguration;
 import org.apache.marmotta.ldcache.model.CacheEntry;
 import org.apache.marmotta.ldclient.api.ldclient.LDClientService;
@@ -33,46 +29,43 @@ import org.apache.marmotta.ldclient.services.ldclient.LDClient;
 import org.openrdf.model.Model;
 import org.openrdf.model.URI;
 import org.openrdf.model.impl.TreeModel;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.Arrays;
 import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 /**
- * Main class for accessing the Linked Data Cache. A new LDCache can be instantiated with
- * <code>new LDCache(CacheConfiguration, LDCachingBackend)</code> and passing an appropriate
- * configuration and caching backend.
- * <p/>
- * Author: Sebastian Schaffert (sschaffert@apache.org)
+ * Next generation LDCache API. Will eventually replace the old LDCache API.
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
  */
-public class LDCache implements LDCachingService, LDCachingServiceNG {
+public class LDCache implements LDCachingService {
 
     private static Logger log = LoggerFactory.getLogger(LDCache.class);
 
-
     // lock a resource while refreshing it so that not several threads trigger a refresh at the same time
     private ObjectLocks resourceLocks;
 
-    private LDClientService  ldclient;
+    private CacheConfiguration config;
+
+    private LDClientService ldclient;
 
     private LDCachingBackend backend;
 
-    private CacheConfiguration config;
-
     private ReentrantReadWriteLock lock;
 
     /**
-     * Instantiate a new LDCache service by passing a configuration and a backend for storing cache data.
+     * Create a new instance of LDCache using the provided LDCache configuration and backend. The backend needs to
+     * be initialized already. The cache configuration will be used to create an instance of LDClient.
      *
      * @param config
      * @param backend
      */
     public LDCache(CacheConfiguration config, LDCachingBackend backend) {
-        log.info("Linked Data Caching Service initialising ...");
-
         this.resourceLocks = new ObjectLocks();
         this.backend  = backend;
         this.ldclient = new LDClient(config.getClientConfiguration());
@@ -80,6 +73,7 @@ public class LDCache implements LDCachingService, LDCachingServiceNG {
         this.lock = new ReentrantReadWriteLock();
     }
 
+
     /**
      * Reload configuration and initialise LDClient.
      */
@@ -97,146 +91,6 @@ public class LDCache implements LDCachingService, LDCachingServiceNG {
     }
 
     /**
-     * Return a repository connection that can be used for accessing cached resources.
-     *
-     * @param  resource the resource that will be cached
-     * @return a repository connection that can be used for storing retrieved triples for caching
-     */
-    @Override
-    public LDCachingConnection getCacheConnection(String resource) throws RepositoryException {
-        return backend.getCacheConnection(resource);
-    }
-
-    /**
-     * Return an iterator over all cache entries (can e.g. be used for refreshing or expiring).
-     *
-     * @return
-     */
-    @Override
-    public CloseableIteration<CacheEntry, RepositoryException> listCacheEntries() throws RepositoryException {
-        return backend.listCacheEntries();
-    }
-
-    /**
-     * Return an iterator over all expired cache entries (can e.g. be used for refreshing).
-     *
-     * @return
-     */
-    @Override
-    public CloseableIteration<CacheEntry, RepositoryException> listExpiredEntries() throws RepositoryException {
-        return backend.listExpiredEntries();
-    }
-
-
-    /**
-     * Return true if the resource is a cached resource.
-     *
-     * @param resourceUri
-     * @return
-     * @throws RepositoryException
-     */
-    public boolean isCached(String resourceUri) throws RepositoryException {
-        // if there is no cache entry, then return false in any case
-        if(!backend.isCached(resourceUri)) {
-            return false;
-        } else {
-            // else list all cached triples - if there are none, the resource is not cached (e.g. blacklist or no LD resource)
-            RepositoryConnection con = backend.getCacheConnection(resourceUri);
-            try {
-                con.begin();
-                return con.hasStatement(con.getValueFactory().createURI(resourceUri), null, null, false);
-            } finally {
-                con.commit();
-                con.close();
-            }
-        }
-    }
-
-
-    /**
-     * Return true in case the cache contains an entry for the resource given as argument.
-     *
-     * @param resource the resource to check
-     * @return true in case the resource is contained in the cache
-     */
-    @Override
-    public boolean contains(URI resource) {
-        try {
-            return isCached(resource.stringValue());
-        } catch (RepositoryException e) {
-            return false;
-        }
-    }
-
-    /**
-     * Manually expire the caching information for the given resource. The resource will be
-     * re-retrieved upon the next access.
-     *
-     * @param resource the Resource to expire.
-     */
-    @Override
-    public void expire(URI resource) {
-        Date now = new Date();
-
-        try {
-            LDCachingConnection con = backend.getCacheConnection(resource.stringValue());
-            try {
-                con.begin();
-
-                CacheEntry entry = con.getCacheEntry(resource);
-                if(entry.getExpiryDate().getTime() > now.getTime()) {
-                    entry.setExpiryDate(now);
-
-                    con.removeCacheEntry(entry.getResource());
-                    con.addCacheEntry(entry.getResource(),entry);
-                }
-
-                con.commit();
-            } catch(RepositoryException ex) {
-                con.rollback();
-            } finally {
-                con.close();
-            }
-        } catch(RepositoryException ex) {
-            ex.printStackTrace(); // TODO: handle error
-        }
-
-    }
-
-
-    /**
-     * Return the triples for the linked data resource given as argument. Will transparently retrieve triples from
-     * remote servers if needed or retrieve them from the cache.
-     *
-     * @param resource
-     * @return
-     * @throws RepositoryException
-     */
-    public Model get(URI resource, RefreshOpts... options)  {
-        refreshResource(resource,false);
-
-        Model m = new TreeModel();
-
-        try {
-            LDCachingConnection c = getCacheConnection(resource.stringValue());
-            try {
-                c.begin();
-
-                ModelCommons.add(m, c.getStatements(resource,null,null,false));
-
-                c.commit();
-            } finally {
-                c.close();
-            }
-        } catch (RepositoryException e) {
-            log.error("error adding cached triples to model:",e);
-        }
-        return m;
-
-    }
-
-
-    /**
      * Refresh the resource passed as argument. If the resource is not yet cached or the cache entry is
      * expired or refreshing is forced, the remote resource is retrieved using LDClient and the result stored
      * in the cache. Otherwise the method does nothing.
@@ -246,70 +100,18 @@ public class LDCache implements LDCachingService, LDCachingServiceNG {
      */
     @Override
     public void refresh(URI resource, RefreshOpts... options) {
-        boolean force = false;
-        for(RefreshOpts opt : options) {
-            if(opt == RefreshOpts.FORCE) {
-                force = true;
-            }
-        }
-
-        refreshResource(resource, force);
-    }
-
-
-    /**
-     * Manually expire all cached resources.
-     */
-    @Override
-    public void clear() {
-        expireAll();
-    }
+        Set<RefreshOpts> optionSet = new HashSet<>(Arrays.asList(options));
 
-    /**
-     * Refresh the cached resource passed as argument. The method will do nothing for local
-     * resources.
-     * Calling the method will carry out the following tasks:
-     * 1. check whether the resource is a remote resource; if no, returns immediately
-     * 2. check whether the resource has a cache entry; if no, goto 4
-     * 3. check whether the expiry time of the cache entry has passed; if no, returns immediately
-     * 4. retrieve the triples for the resource from the Linked Data Cloud using the methods offered
-     * by the
-     * LinkedDataClientService (registered endpoints etc); returns immediately if the result is null
-     * or
-     * an exception is thrown
-     * 5. remove all old triples for the resource and add all new triples for the resource
-     * 6. create new expiry information of the cache entry and persist it in the transaction
-     *
-     * @param resource
-     * @param forceRefresh if <code>true</code> the resource will be refreshed despite the
-     */
-    @Override
-    public void refreshResource(URI resource, boolean forceRefresh) {
         resourceLocks.lock(resource.stringValue());
         try {
-            LDCachingConnection cacheConnection = backend.getCacheConnection(resource.stringValue());
-            CacheEntry entry = null;
-            try {
-                cacheConnection.begin();
-
-                // 2. check whether the resource has a cache entry; if no, goto 4
-                entry = cacheConnection.getCacheEntry(resource);
-
-                // commit/close the connection, the retrieveResource method takes too long to hold the DB connection open
-                cacheConnection.commit();
-
-                // 3. check whether the expiry time of the cache entry has passed; if no, returns immediately
-                if(!forceRefresh && entry != null && entry.getExpiryDate().after(new Date())) {
-                    log.debug("not refreshing resource {}, as the cached entry is not yet expired",resource);
-                    return;
-                }
-            } catch(RepositoryException ex) {
-                cacheConnection.rollback();
-            } finally {
-                cacheConnection.close();
+            // check if the resource is already cached; if yes, and refresh is not forced, return immediately
+            CacheEntry entry = backend.getEntry(resource);
+            if(!optionSet.contains(RefreshOpts.FORCE) && entry != null && entry.getExpiryDate().after(new Date())) {
+                log.debug("not refreshing resource {}, as the cached entry is not yet expired",resource);
+                return;
             }
 
-            // 4.
+            // refresh the resource by calling LDClient
             log.debug("refreshing resource {}",resource);
             this.lock.readLock().lock();
             try {
@@ -318,40 +120,27 @@ public class LDCache implements LDCachingService, LDCachingServiceNG {
                 if(response != null) {
                     log.info("refreshed resource {}",resource);
 
-                    // obtain a new cache connection, since we closed the original connection above
-                    LDCachingConnection cacheConnection1 = backend.getCacheConnection(resource.stringValue());
-                    cacheConnection1.begin();
-                    try {
-                        URI subject = cacheConnection1.getValueFactory().createURI(resource.stringValue());
-
-                        cacheConnection1.add(response.getData());
-
-                        CacheEntry newEntry = new CacheEntry();
-                        newEntry.setResource(subject);
-                        newEntry.setExpiryDate(response.getExpires());
-                        newEntry.setLastRetrieved(new Date());
-                        if(entry != null) {
-                            newEntry.setUpdateCount(entry.getUpdateCount()+1);
-                        } else {
-                            newEntry.setUpdateCount(1);
-                        }
-                        newEntry.setTripleCount(response.getData().size());
-
-                        cacheConnection1.removeCacheEntry(resource);
-                        cacheConnection1.addCacheEntry(resource, newEntry);
-                        cacheConnection1.commit();
-                    } catch (RepositoryException e) {
-                        log.error("repository error while refreshing the remote resource {} from the Linked Data Cloud", resource, e);
-                        cacheConnection1.rollback();
-                    } finally {
-                        cacheConnection1.close();
+                    CacheEntry newEntry = new CacheEntry();
+                    newEntry.setResource(resource);
+                    newEntry.setExpiryDate(response.getExpires());
+                    newEntry.setLastRetrieved(new Date());
+                    if(entry != null) {
+                        newEntry.setUpdateCount(entry.getUpdateCount()+1);
+                    } else {
+                        newEntry.setUpdateCount(1);
                     }
+                    newEntry.setTripleCount(response.getData().size());
+                    newEntry.setTriples(response.getData());
+
+                    backend.putEntry(resource, newEntry);
+
                 }
 
             } catch (DataRetrievalException e) {
+
                 // on exception, save an expiry information and retry in one day
                 CacheEntry newEntry = new CacheEntry();
-                newEntry.setResource(cacheConnection.getValueFactory().createURI(resource.stringValue()));
+                newEntry.setResource(resource);
                 newEntry.setExpiryDate(new Date(System.currentTimeMillis() + config.getDefaultExpiry()*1000));
                 newEntry.setLastRetrieved(new Date());
                 if(entry != null) {
@@ -360,106 +149,70 @@ public class LDCache implements LDCachingService, LDCachingServiceNG {
                     newEntry.setUpdateCount(1);
                 }
                 newEntry.setTripleCount(0);
+                newEntry.setTriples(new TreeModel());
+
+                backend.putEntry(resource, newEntry);
 
-                LDCachingConnection cacheConnection2 = backend.getCacheConnection(resource.stringValue());
-                cacheConnection2.begin();
-                try {
-                    cacheConnection2.removeCacheEntry(resource);
-                    cacheConnection2.addCacheEntry(resource, newEntry);
-
-                    cacheConnection2.commit();
-                    log.error("refreshing the remote resource {} from the Linked Data Cloud failed ({})",resource,e.getMessage());
-                    //log.info("exception was:",e);
-                    return;
-                } catch (RepositoryException ex) {
-                    log.error("repository error while refreshing the remote resource {} from the Linked Data Cloud", resource, ex);
-                    cacheConnection2.rollback();
-                } finally {
-                    cacheConnection2.close();
-                }
             } finally {
                 this.lock.readLock().unlock();
             }
-        } catch (RepositoryException e) {
-            log.error("repository exception while obtaining cache connection",e);
         } finally {
             resourceLocks.unlock(resource.stringValue());
         }
 
     }
 
-
     /**
-     * Refresh all expired resources by listing the cache entries that have expired and calling refreshResource on
-     * them. This method can e.g. be called by a scheduled task to regularly update cache entries to always have
-     * the latest version available in the Search Index and elsewhere.
+     * Refresh and return the resource passed as argument. If the resource is not yet cached or the cache entry is
+     * expired or refreshing is forced, the remote resource is retrieved using LDClient and the result stored
+     * in the cache. Otherwise the method returns the cached entry. In case a cached entry does not exist, the method
+     * returns an empty Model.
+     *
+     * @param resource the resource to retrieve
+     * @param options  options for refreshing
+     * @return a Sesame Model holding the triples representing the resource
      */
     @Override
-    public void refreshExpired() {
-        Date now = new Date();
+    public Model get(URI resource, RefreshOpts... options) {
+        refresh(resource, options);
 
-        try {
-            CloseableIteration<CacheEntry,RepositoryException> it = backend.listExpiredEntries();
-            try {
-                while(it.hasNext()) {
-                    CacheEntry next =  it.next();
+        CacheEntry entry =  backend.getEntry(resource);
 
-                    if(next.getExpiryDate().getTime() < now.getTime()) {
-                        refreshResource(next.getResource(),false);
-                    }
-                }
-            } finally {
-                it.close();
-            }
-        } catch(RepositoryException ex) {
-            log.error("exception while refreshing cache entries", ex);
+        if(entry != null) {
+            return entry.getTriples();
+        } else {
+            return new TreeModel();
         }
-
     }
 
     /**
-     * Manually expire all cached resources.
+     * Manually expire the caching information for the given resource. The resource will be
+     * re-retrieved upon the next access.
      *
-     * @see #expire(org.openrdf.model.URI)
+     * @param resource the resource to expire.
      */
     @Override
-    public void expireAll() {
-        Date now = new Date();
+    public void expire(URI resource) {
+        backend.removeEntry(resource);
+    }
 
-        try {
-            CloseableIteration<CacheEntry,RepositoryException> it = backend.listCacheEntries();
-            try {
-                while(it.hasNext()) {
-                    CacheEntry next =  it.next();
-
-                    if(next.getExpiryDate().getTime() > now.getTime()) {
-                        next.setExpiryDate(now);
-
-                        try {
-                            LDCachingConnection con = backend.getCacheConnection(next.getResource().stringValue());
-                            try {
-                                con.begin();
-
-                                con.removeCacheEntry(next.getResource());
-                                con.addCacheEntry(next.getResource(), next);
-
-                                con.commit();
-                            } catch(RepositoryException ex) {
-                                con.rollback();
-                            } finally {
-                                con.close();
-                            }
-                        } catch(RepositoryException ex) {
-                        }
-                    }
-                }
-            } finally {
-                it.close();
-            }
-        } catch(RepositoryException ex) {
-            log.error("exception while expiring cache entries",ex);
-        }
+    /**
+     * Return true in case the cache contains an entry for the resource given as argument.
+     *
+     * @param resource the resource to check
+     * @return true in case the resource is contained in the cache
+     */
+    @Override
+    public boolean contains(URI resource) {
+        return backend.getEntry(resource) != null;
+    }
 
+    /**
+     * Manually expire all cached resources.
+     */
+    @Override
+    public void clear() {
+        backend.clear();
     }
 
     /**
@@ -467,17 +220,11 @@ public class LDCache implements LDCachingService, LDCachingServiceNG {
      */
     @Override
     public void shutdown() {
-        lock.writeLock().lock();
-        try {
-            backend.shutdown();
-            ldclient.shutdown();
-        } finally {
-            lock.writeLock().unlock();
-        }
+        backend.shutdown();
     }
 
 
-    public LDClientService getLDClient() {
+    public LDClientService getClient() {
         return ldclient;
     }
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-core/src/main/java/org/apache/marmotta/ldcache/services/LDCacheNG.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-core/src/main/java/org/apache/marmotta/ldcache/services/LDCacheNG.java b/libraries/ldcache/ldcache-core/src/main/java/org/apache/marmotta/ldcache/services/LDCacheNG.java
deleted file mode 100644
index d41e558..0000000
--- a/libraries/ldcache/ldcache-core/src/main/java/org/apache/marmotta/ldcache/services/LDCacheNG.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * 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.marmotta.ldcache.services;
-
-import org.apache.marmotta.commons.locking.ObjectLocks;
-import org.apache.marmotta.ldcache.api.LDCachingBackendNG;
-import org.apache.marmotta.ldcache.api.LDCachingServiceNG;
-import org.apache.marmotta.ldcache.model.CacheConfiguration;
-import org.apache.marmotta.ldcache.model.CacheEntry;
-import org.apache.marmotta.ldclient.api.ldclient.LDClientService;
-import org.apache.marmotta.ldclient.exception.DataRetrievalException;
-import org.apache.marmotta.ldclient.model.ClientResponse;
-import org.apache.marmotta.ldclient.services.ldclient.LDClient;
-import org.openrdf.model.Model;
-import org.openrdf.model.URI;
-import org.openrdf.model.impl.TreeModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-/**
- * Next generation LDCache API. Will eventually replace the old LDCache API.
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class LDCacheNG implements LDCachingServiceNG {
-
-    private static Logger log = LoggerFactory.getLogger(LDCacheNG.class);
-
-    // lock a resource while refreshing it so that not several threads trigger a refresh at the same time
-    private ObjectLocks resourceLocks;
-
-    private CacheConfiguration config;
-
-    private LDClientService ldclient;
-
-    private LDCachingBackendNG backend;
-
-    private ReentrantReadWriteLock lock;
-
-    /**
-     * Create a new instance of LDCache using the provided LDCache configuration and backend. The backend needs to
-     * be initialized already. The cache configuration will be used to create an instance of LDClient.
-     *
-     * @param config
-     * @param backend
-     */
-    public LDCacheNG(CacheConfiguration config, LDCachingBackendNG backend) {
-        this.resourceLocks = new ObjectLocks();
-        this.backend  = backend;
-        this.ldclient = new LDClient(config.getClientConfiguration());
-        this.config   = config;
-        this.lock = new ReentrantReadWriteLock();
-    }
-
-
-    /**
-     * Reload configuration and initialise LDClient.
-     */
-    public void reload() {
-        lock.writeLock().lock();
-        try {
-            if(this.ldclient != null) {
-                log.info("Reloading LDClient configuration ...");
-                this.ldclient.shutdown();
-                this.ldclient = new LDClient(config.getClientConfiguration());
-            }
-        } finally {
-            lock.writeLock().unlock();
-        }
-    }
-
-    /**
-     * Refresh the resource passed as argument. If the resource is not yet cached or the cache entry is
-     * expired or refreshing is forced, the remote resource is retrieved using LDClient and the result stored
-     * in the cache. Otherwise the method does nothing.
-     *
-     * @param resource the resource to refresh
-     * @param options  options for refreshing
-     */
-    @Override
-    public void refresh(URI resource, RefreshOpts... options) {
-        Set<RefreshOpts> optionSet = new HashSet<>(Arrays.asList(options));
-
-        resourceLocks.lock(resource.stringValue());
-        try {
-            // check if the resource is already cached; if yes, and refresh is not forced, return immediately
-            CacheEntry entry = backend.getEntry(resource);
-            if(!optionSet.contains(RefreshOpts.FORCE) && entry != null && entry.getExpiryDate().after(new Date())) {
-                log.debug("not refreshing resource {}, as the cached entry is not yet expired",resource);
-                return;
-            }
-
-            // refresh the resource by calling LDClient
-            log.debug("refreshing resource {}",resource);
-            this.lock.readLock().lock();
-            try {
-                ClientResponse response = ldclient.retrieveResource(resource.stringValue());
-
-                if(response != null) {
-                    log.info("refreshed resource {}",resource);
-
-                    CacheEntry newEntry = new CacheEntry();
-                    newEntry.setResource(resource);
-                    newEntry.setExpiryDate(response.getExpires());
-                    newEntry.setLastRetrieved(new Date());
-                    if(entry != null) {
-                        newEntry.setUpdateCount(entry.getUpdateCount()+1);
-                    } else {
-                        newEntry.setUpdateCount(1);
-                    }
-                    newEntry.setTripleCount(response.getData().size());
-                    newEntry.setTriples(response.getData());
-
-                    backend.putEntry(resource, newEntry);
-
-                }
-
-            } catch (DataRetrievalException e) {
-
-                // on exception, save an expiry information and retry in one day
-                CacheEntry newEntry = new CacheEntry();
-                newEntry.setResource(resource);
-                newEntry.setExpiryDate(new Date(System.currentTimeMillis() + config.getDefaultExpiry()*1000));
-                newEntry.setLastRetrieved(new Date());
-                if(entry != null) {
-                    newEntry.setUpdateCount(entry.getUpdateCount()+1);
-                } else {
-                    newEntry.setUpdateCount(1);
-                }
-                newEntry.setTripleCount(0);
-                newEntry.setTriples(new TreeModel());
-
-                backend.putEntry(resource, newEntry);
-
-            } finally {
-                this.lock.readLock().unlock();
-            }
-        } finally {
-            resourceLocks.unlock(resource.stringValue());
-        }
-
-    }
-
-    /**
-     * Refresh and return the resource passed as argument. If the resource is not yet cached or the cache entry is
-     * expired or refreshing is forced, the remote resource is retrieved using LDClient and the result stored
-     * in the cache. Otherwise the method returns the cached entry. In case a cached entry does not exist, the method
-     * returns an empty Model.
-     *
-     * @param resource the resource to retrieve
-     * @param options  options for refreshing
-     * @return a Sesame Model holding the triples representing the resource
-     */
-    @Override
-    public Model get(URI resource, RefreshOpts... options) {
-        refresh(resource, options);
-
-        CacheEntry entry =  backend.getEntry(resource);
-
-        if(entry != null) {
-            return entry.getTriples();
-        } else {
-            return new TreeModel();
-        }
-    }
-
-    /**
-     * Manually expire the caching information for the given resource. The resource will be
-     * re-retrieved upon the next access.
-     *
-     * @param resource the resource to expire.
-     */
-    @Override
-    public void expire(URI resource) {
-        backend.removeEntry(resource);
-    }
-
-    /**
-     * Return true in case the cache contains an entry for the resource given as argument.
-     *
-     * @param resource the resource to check
-     * @return true in case the resource is contained in the cache
-     */
-    @Override
-    public boolean contains(URI resource) {
-        return backend.getEntry(resource) != null;
-    }
-
-    /**
-     * Manually expire all cached resources.
-     */
-    @Override
-    public void clear() {
-        backend.clear();
-    }
-
-    /**
-     * Shutdown the caching service and free all occupied runtime resources.
-     */
-    @Override
-    public void shutdown() {
-        backend.shutdown();
-    }
-
-
-    public LDClientService getClient() {
-        return ldclient;
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-core/src/test/java/org/apache/marmotta/ldcache/services/test/ng/BaseLDCacheNGTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-core/src/test/java/org/apache/marmotta/ldcache/services/test/ng/BaseLDCacheNGTest.java b/libraries/ldcache/ldcache-core/src/test/java/org/apache/marmotta/ldcache/services/test/ng/BaseLDCacheNGTest.java
deleted file mode 100644
index be97d70..0000000
--- a/libraries/ldcache/ldcache-core/src/test/java/org/apache/marmotta/ldcache/services/test/ng/BaseLDCacheNGTest.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * 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.marmotta.ldcache.services.test.ng;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.marmotta.commons.sesame.model.ModelCommons;
-import org.apache.marmotta.ldcache.api.LDCachingBackendNG;
-import org.apache.marmotta.ldcache.model.CacheConfiguration;
-import org.apache.marmotta.ldcache.services.LDCacheNG;
-import org.junit.*;
-import org.openrdf.model.Model;
-import org.openrdf.model.ValueFactory;
-import org.openrdf.model.impl.ValueFactoryImpl;
-import org.openrdf.query.BooleanQuery;
-import org.openrdf.query.QueryLanguage;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.rio.RDFFormat;
-import org.openrdf.rio.Rio;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.InputStream;
-import java.io.StringWriter;
-
-/**
- * Add file description here!
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public abstract class BaseLDCacheNGTest {
-
-    private static final String DBPEDIA = "http://dbpedia.org/resource/Berlin";
-    private static final String GEONAMES = "http://sws.geonames.org/3020251/";
-    private static final String MARMOTTA = "http://rdfohloh.wikier.org/project/marmotta";
-    private static final String WIKIER = "http://www.wikier.org/foaf#wikier";
-
-    private static Logger log = LoggerFactory.getLogger(BaseLDCacheNGTest.class);
-
-    protected LDCacheNG ldcache;
-
-
-    protected ValueFactory valueFactory = ValueFactoryImpl.getInstance();
-
-    /**
-     * Needs to be implemented by tests to provide the correct backend. Backend needs to be properly initialised.
-     *
-     * @return
-     */
-    protected abstract LDCachingBackendNG createBackend();
-
-
-
-    @Before
-    public void setup() {
-        ldcache = new LDCacheNG(new CacheConfiguration(), createBackend());
-    }
-
-
-    @Test
-    @Ignore("test failing for the moment because the data returned by the service is wrong")
-    public void testDBPedia() throws Exception {
-        Assume.assumeTrue(existsClass("org.apache.marmotta.ldclient.provider.rdf.LinkedDataProvider"));
-
-        testResource(DBPEDIA, "dbpedia-berlin.sparql");
-    }
-
-    @Test
-    public void testGeonames() throws Exception {
-        Assume.assumeTrue(existsClass("org.apache.marmotta.ldclient.provider.rdf.LinkedDataProvider"));
-
-        testResource(GEONAMES, "geonames-embrun.sparql");
-    }
-
-    @Test
-    public void testFOAF() throws Exception {
-        Assume.assumeTrue(existsClass("org.apache.marmotta.ldclient.provider.rdf.LinkedDataProvider"));
-
-        testResource(WIKIER, "foaf-wikier.sparql");
-    }
-
-    @Test
-    @Ignore("test failing for the moment because the data returned by the service is wrong")
-    public void testOHLOH() throws Exception {
-        Assume.assumeTrue(existsClass("org.apache.marmotta.ldclient.provider.rdf.LinkedDataProvider"));
-
-        testResource(MARMOTTA, "ohloh-marmotta.sparql");
-    }
-
-    /**
-     * Test retrieving and caching some resources (provided by DummyProvider).
-     */
-    @Test
-    public void testLocal() throws Exception {
-        String uri1 = "http://localhost/resource1";
-        String uri2 = "http://localhost/resource2";
-        String uri3 = "http://localhost/resource3";
-
-        ldcache.refresh(valueFactory.createURI(uri1));
-
-        Assert.assertTrue(ldcache.contains(valueFactory.createURI(uri1)));
-        Assert.assertEquals(3, ldcache.get(valueFactory.createURI(uri1)).size());
-
-        ldcache.refresh(valueFactory.createURI(uri2));
-
-        Assert.assertTrue(ldcache.contains(valueFactory.createURI(uri2)));
-        Assert.assertEquals(2, ldcache.get(valueFactory.createURI(uri2)).size());
-
-        ldcache.refresh(valueFactory.createURI(uri3));
-
-        Assert.assertTrue(ldcache.contains(valueFactory.createURI(uri3)));
-        Assert.assertEquals(2, ldcache.get(valueFactory.createURI(uri3)).size());
-    }
-
-
-    protected void testResource(String uri, String sparqlFile) throws Exception {
-
-        Assume.assumeTrue(ldcache.getClient().ping(uri));
-
-
-        Model model = ldcache.get(valueFactory.createURI(uri));
-
-        Assert.assertTrue(model.size() > 0);
-
-        RepositoryConnection connection = ModelCommons.asRepository(model).getConnection();
-        connection.begin();
-
-        // run a SPARQL test to see if the returned data is correct
-        InputStream sparql = BaseLDCacheNGTest.class.getResourceAsStream(sparqlFile);
-        BooleanQuery testLabel = connection.prepareBooleanQuery(QueryLanguage.SPARQL, IOUtils.toString(sparql));
-        Assert.assertTrue("SPARQL test query failed", testLabel.evaluate());
-
-        if(log.isDebugEnabled()) {
-            StringWriter out = new StringWriter();
-            connection.export(Rio.createWriter(RDFFormat.TURTLE, out));
-            log.debug("DATA:");
-            log.debug(out.toString());
-        }
-
-        connection.commit();
-        connection.close();
-        connection.getRepository().shutDown();
-    }
-
-
-    protected boolean existsClass(String className) {
-        try {
-            Class.forName(className);
-            return true;
-        } catch (ClassNotFoundException e) {
-            return false;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-core/src/test/java/org/apache/marmotta/ldcache/services/test/ng/BaseLDCacheTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-core/src/test/java/org/apache/marmotta/ldcache/services/test/ng/BaseLDCacheTest.java b/libraries/ldcache/ldcache-core/src/test/java/org/apache/marmotta/ldcache/services/test/ng/BaseLDCacheTest.java
new file mode 100644
index 0000000..f2d243d
--- /dev/null
+++ b/libraries/ldcache/ldcache-core/src/test/java/org/apache/marmotta/ldcache/services/test/ng/BaseLDCacheTest.java
@@ -0,0 +1,168 @@
+/*
+ * 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.marmotta.ldcache.services.test.ng;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.marmotta.commons.sesame.model.ModelCommons;
+import org.apache.marmotta.ldcache.api.LDCachingBackend;
+import org.apache.marmotta.ldcache.model.CacheConfiguration;
+import org.apache.marmotta.ldcache.services.LDCache;
+import org.junit.*;
+import org.openrdf.model.Model;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+import org.openrdf.query.BooleanQuery;
+import org.openrdf.query.QueryLanguage;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.rio.RDFFormat;
+import org.openrdf.rio.Rio;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.InputStream;
+import java.io.StringWriter;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public abstract class BaseLDCacheTest {
+
+    private static final String DBPEDIA = "http://dbpedia.org/resource/Berlin";
+    private static final String GEONAMES = "http://sws.geonames.org/3020251/";
+    private static final String MARMOTTA = "http://rdfohloh.wikier.org/project/marmotta";
+    private static final String WIKIER = "http://www.wikier.org/foaf#wikier";
+
+    private static Logger log = LoggerFactory.getLogger(BaseLDCacheTest.class);
+
+    protected LDCache ldcache;
+
+
+    protected ValueFactory valueFactory = ValueFactoryImpl.getInstance();
+
+    /**
+     * Needs to be implemented by tests to provide the correct backend. Backend needs to be properly initialised.
+     *
+     * @return
+     */
+    protected abstract LDCachingBackend createBackend();
+
+
+
+    @Before
+    public void setup() {
+        ldcache = new LDCache(new CacheConfiguration(), createBackend());
+    }
+
+
+    @Test
+    @Ignore("test failing for the moment because the data returned by the service is wrong")
+    public void testDBPedia() throws Exception {
+        Assume.assumeTrue(existsClass("org.apache.marmotta.ldclient.provider.rdf.LinkedDataProvider"));
+
+        testResource(DBPEDIA, "dbpedia-berlin.sparql");
+    }
+
+    @Test
+    public void testGeonames() throws Exception {
+        Assume.assumeTrue(existsClass("org.apache.marmotta.ldclient.provider.rdf.LinkedDataProvider"));
+
+        testResource(GEONAMES, "geonames-embrun.sparql");
+    }
+
+    @Test
+    public void testFOAF() throws Exception {
+        Assume.assumeTrue(existsClass("org.apache.marmotta.ldclient.provider.rdf.LinkedDataProvider"));
+
+        testResource(WIKIER, "foaf-wikier.sparql");
+    }
+
+    @Test
+    @Ignore("test failing for the moment because the data returned by the service is wrong")
+    public void testOHLOH() throws Exception {
+        Assume.assumeTrue(existsClass("org.apache.marmotta.ldclient.provider.rdf.LinkedDataProvider"));
+
+        testResource(MARMOTTA, "ohloh-marmotta.sparql");
+    }
+
+    /**
+     * Test retrieving and caching some resources (provided by DummyProvider).
+     */
+    @Test
+    public void testLocal() throws Exception {
+        String uri1 = "http://localhost/resource1";
+        String uri2 = "http://localhost/resource2";
+        String uri3 = "http://localhost/resource3";
+
+        ldcache.refresh(valueFactory.createURI(uri1));
+
+        Assert.assertTrue(ldcache.contains(valueFactory.createURI(uri1)));
+        Assert.assertEquals(3, ldcache.get(valueFactory.createURI(uri1)).size());
+
+        ldcache.refresh(valueFactory.createURI(uri2));
+
+        Assert.assertTrue(ldcache.contains(valueFactory.createURI(uri2)));
+        Assert.assertEquals(2, ldcache.get(valueFactory.createURI(uri2)).size());
+
+        ldcache.refresh(valueFactory.createURI(uri3));
+
+        Assert.assertTrue(ldcache.contains(valueFactory.createURI(uri3)));
+        Assert.assertEquals(2, ldcache.get(valueFactory.createURI(uri3)).size());
+    }
+
+
+    protected void testResource(String uri, String sparqlFile) throws Exception {
+
+        Assume.assumeTrue(ldcache.getClient().ping(uri));
+
+
+        Model model = ldcache.get(valueFactory.createURI(uri));
+
+        Assert.assertTrue(model.size() > 0);
+
+        RepositoryConnection connection = ModelCommons.asRepository(model).getConnection();
+        connection.begin();
+
+        // run a SPARQL test to see if the returned data is correct
+        InputStream sparql = BaseLDCacheTest.class.getResourceAsStream(sparqlFile);
+        BooleanQuery testLabel = connection.prepareBooleanQuery(QueryLanguage.SPARQL, IOUtils.toString(sparql));
+        Assert.assertTrue("SPARQL test query failed", testLabel.evaluate());
+
+        if(log.isDebugEnabled()) {
+            StringWriter out = new StringWriter();
+            connection.export(Rio.createWriter(RDFFormat.TURTLE, out));
+            log.debug("DATA:");
+            log.debug(out.toString());
+        }
+
+        connection.commit();
+        connection.close();
+        connection.getRepository().shutDown();
+    }
+
+
+    protected boolean existsClass(String className) {
+        try {
+            Class.forName(className);
+            return true;
+        } catch (ClassNotFoundException e) {
+            return false;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSail.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSail.java b/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSail.java
index c4936bc..f41879c 100644
--- a/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSail.java
+++ b/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSail.java
@@ -19,9 +19,9 @@ package org.apache.marmotta.ldcache.sail;
 
 import org.apache.marmotta.commons.sesame.filter.AlwaysTrueFilter;
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
-import org.apache.marmotta.ldcache.api.LDCachingBackendNG;
+import org.apache.marmotta.ldcache.api.LDCachingBackend;
 import org.apache.marmotta.ldcache.model.CacheConfiguration;
-import org.apache.marmotta.ldcache.services.LDCacheNG;
+import org.apache.marmotta.ldcache.services.LDCache;
 import org.apache.marmotta.ldclient.model.ClientConfiguration;
 import org.openrdf.model.Resource;
 import org.openrdf.sail.NotifyingSail;
@@ -37,32 +37,32 @@ import org.openrdf.sail.helpers.NotifyingSailWrapper;
  */
 public class GenericLinkedDataSail extends NotifyingSailWrapper {
 
-	private final LDCachingBackendNG cachingBackend;
+	private final LDCachingBackend cachingBackend;
 	private CacheConfiguration config;
-	private LDCacheNG ldcache;
+	private LDCache ldcache;
 	private SesameFilter<Resource> acceptForCaching;
 
-	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackendNG cachingBackend) {
+	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackend cachingBackend) {
 		this(base, cachingBackend, new AlwaysTrueFilter<Resource>(), createCacheConfiguration(null));
 	}
 
-	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackendNG cachingBackend, ClientConfiguration clientConfig) {
+	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackend cachingBackend, ClientConfiguration clientConfig) {
 		this(base, cachingBackend, new AlwaysTrueFilter<Resource>(), clientConfig);
 	}
 
-	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackendNG cachingBackend, CacheConfiguration cacheConfig) {
+	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackend cachingBackend, CacheConfiguration cacheConfig) {
 		this(base, cachingBackend, new AlwaysTrueFilter<Resource>(), cacheConfig);
 	}
 	
-	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackendNG cachingBackend, SesameFilter<Resource> acceptForCaching) {
+	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackend cachingBackend, SesameFilter<Resource> acceptForCaching) {
 		this(base, cachingBackend, acceptForCaching, createCacheConfiguration(null));
 	}
 
-	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackendNG cachingBackend, SesameFilter<Resource> acceptForCaching, ClientConfiguration clientConfig) {
+	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackend cachingBackend, SesameFilter<Resource> acceptForCaching, ClientConfiguration clientConfig) {
 		this(base, cachingBackend, acceptForCaching, createCacheConfiguration(clientConfig));
 	}
 
-	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackendNG cachingBackend, SesameFilter<Resource> acceptForCaching, CacheConfiguration cacheConfig) {
+	public GenericLinkedDataSail(NotifyingSail base, LDCachingBackend cachingBackend, SesameFilter<Resource> acceptForCaching, CacheConfiguration cacheConfig) {
 		super(base);
 		this.cachingBackend = cachingBackend;
 		this.acceptForCaching = acceptForCaching;
@@ -88,7 +88,7 @@ public class GenericLinkedDataSail extends NotifyingSailWrapper {
 		
 		cachingBackend.initialize();
 		
-		ldcache = new LDCacheNG(this.config,cachingBackend);
+		ldcache = new LDCache(this.config,cachingBackend);
 	}
 	
 	@Override
@@ -102,14 +102,14 @@ public class GenericLinkedDataSail extends NotifyingSailWrapper {
 	
 	public void reinit() {
 		ldcache.shutdown();
-		ldcache = new LDCacheNG(this.config,cachingBackend);
+		ldcache = new LDCache(this.config,cachingBackend);
 	}
 	
 	public CacheConfiguration getCacheConfiguration() {
 		return config;
 	}
 
-    public LDCacheNG getLDCache() {
+    public LDCache getLDCache() {
         return ldcache;
     }
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSailConnection.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSailConnection.java b/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSailConnection.java
index 3eb996a..3c56985 100644
--- a/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSailConnection.java
+++ b/libraries/ldcache/ldcache-sail-generic/src/main/java/org/apache/marmotta/ldcache/sail/GenericLinkedDataSailConnection.java
@@ -23,7 +23,7 @@ import info.aduna.iteration.UnionIteration;
 import org.apache.marmotta.commons.sesame.filter.AlwaysTrueFilter;
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
 import org.apache.marmotta.commons.sesame.repository.ResourceUtils;
-import org.apache.marmotta.ldcache.services.LDCacheNG;
+import org.apache.marmotta.ldcache.services.LDCache;
 import org.openrdf.model.*;
 import org.openrdf.sail.NotifyingSailConnection;
 import org.openrdf.sail.SailException;
@@ -43,15 +43,15 @@ public class GenericLinkedDataSailConnection extends NotifyingSailConnectionWrap
 
     private static Logger log = LoggerFactory.getLogger(GenericLinkedDataSailConnection.class);
 
-    private final LDCacheNG ldcache;
+    private final LDCache ldcache;
     private final SesameFilter<Resource> acceptForCaching;
 
-    public GenericLinkedDataSailConnection(NotifyingSailConnection connection, LDCacheNG ldcache) {
+    public GenericLinkedDataSailConnection(NotifyingSailConnection connection, LDCache ldcache) {
         this(connection, ldcache, new AlwaysTrueFilter<Resource>());
     }
 
 
-    public GenericLinkedDataSailConnection(NotifyingSailConnection connection, LDCacheNG ldcache, SesameFilter<Resource> acceptForCaching) {
+    public GenericLinkedDataSailConnection(NotifyingSailConnection connection, LDCache ldcache, SesameFilter<Resource> acceptForCaching) {
         super(connection);
         this.ldcache = ldcache;
         this.acceptForCaching = acceptForCaching;

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-sail-generic/src/test/java/org/apache/marmotta/ldcache/sail/test/GenericLinkedDataSailOfflineTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-sail-generic/src/test/java/org/apache/marmotta/ldcache/sail/test/GenericLinkedDataSailOfflineTest.java b/libraries/ldcache/ldcache-sail-generic/src/test/java/org/apache/marmotta/ldcache/sail/test/GenericLinkedDataSailOfflineTest.java
index 4bff0ac..0d4ef57 100644
--- a/libraries/ldcache/ldcache-sail-generic/src/test/java/org/apache/marmotta/ldcache/sail/test/GenericLinkedDataSailOfflineTest.java
+++ b/libraries/ldcache/ldcache-sail-generic/src/test/java/org/apache/marmotta/ldcache/sail/test/GenericLinkedDataSailOfflineTest.java
@@ -21,7 +21,7 @@ import info.aduna.iteration.Iterations;
 import org.apache.commons.io.FileUtils;
 import org.apache.marmotta.commons.sesame.filter.resource.ResourceFilter;
 import org.apache.marmotta.commons.sesame.filter.resource.UriPrefixFilter;
-import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackendNG;
+import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackend;
 import org.apache.marmotta.ldcache.sail.GenericLinkedDataSail;
 import org.apache.marmotta.ldcache.services.test.dummy.DummyEndpoint;
 import org.apache.marmotta.ldclient.model.ClientConfiguration;
@@ -60,7 +60,7 @@ public class GenericLinkedDataSailOfflineTest {
 
     private Repository repository;
 
-    private LDCachingFileBackendNG backend;
+    private LDCachingFileBackend backend;
 
     private GenericLinkedDataSail lsail;
 
@@ -76,7 +76,7 @@ public class GenericLinkedDataSailOfflineTest {
 
         tmpDirectory = Files.createTempDir();
 
-        backend = new LDCachingFileBackendNG(tmpDirectory);
+        backend = new LDCachingFileBackend(tmpDirectory);
         lsail = new GenericLinkedDataSail(new MemoryStore(),backend, cacheFilter, config);
         repository = new SailRepository(lsail);
         repository.initialize();

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSail.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSail.java b/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSail.java
index a571234..70a0625 100644
--- a/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSail.java
+++ b/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSail.java
@@ -19,9 +19,9 @@ package org.apache.marmotta.ldcache.sail;
 
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
 import org.apache.marmotta.kiwi.sail.KiWiStore;
-import org.apache.marmotta.ldcache.backend.kiwi.LDCachingKiWiBackendNG;
+import org.apache.marmotta.ldcache.backend.kiwi.LDCachingKiWiBackend;
 import org.apache.marmotta.ldcache.model.CacheConfiguration;
-import org.apache.marmotta.ldcache.services.LDCacheNG;
+import org.apache.marmotta.ldcache.services.LDCache;
 import org.apache.marmotta.ldclient.model.ClientConfiguration;
 import org.openrdf.model.Resource;
 import org.openrdf.sail.NotifyingSail;
@@ -39,9 +39,9 @@ public class KiWiLinkedDataSail extends NotifyingSailWrapper {
 
     private KiWiStore store;
 
-    private LDCachingKiWiBackendNG backend;
+    private LDCachingKiWiBackend backend;
 
-    private LDCacheNG ldcache;
+    private LDCache ldcache;
 
     private SesameFilter<Resource> acceptor;
 
@@ -88,10 +88,10 @@ public class KiWiLinkedDataSail extends NotifyingSailWrapper {
     public void initialize() throws SailException {
         super.initialize();
 
-        backend = new LDCachingKiWiBackendNG(store, cache_context);
+        backend = new LDCachingKiWiBackend(store, cache_context);
         backend.initialize();
 
-        ldcache = new LDCacheNG(config,backend);
+        ldcache = new LDCache(config,backend);
 
     }
 
@@ -126,11 +126,11 @@ public class KiWiLinkedDataSail extends NotifyingSailWrapper {
         }
     }
 
-    public LDCachingKiWiBackendNG getBackend() {
+    public LDCachingKiWiBackend getBackend() {
         return backend;
     }
 
-    public LDCacheNG getLDCache() {
+    public LDCache getLDCache() {
         return ldcache;
     }
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSailConnection.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSailConnection.java b/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSailConnection.java
index 36dae58..b483ad8 100644
--- a/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSailConnection.java
+++ b/libraries/ldcache/ldcache-sail-kiwi/src/main/java/org/apache/marmotta/ldcache/sail/KiWiLinkedDataSailConnection.java
@@ -19,7 +19,7 @@ package org.apache.marmotta.ldcache.sail;
 
 import info.aduna.iteration.CloseableIteration;
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
-import org.apache.marmotta.ldcache.services.LDCacheNG;
+import org.apache.marmotta.ldcache.services.LDCache;
 import org.openrdf.model.*;
 import org.openrdf.sail.NotifyingSailConnection;
 import org.openrdf.sail.SailException;
@@ -32,11 +32,11 @@ import org.openrdf.sail.helpers.NotifyingSailConnectionWrapper;
  */
 public class KiWiLinkedDataSailConnection extends NotifyingSailConnectionWrapper {
 
-    private LDCacheNG ldcache;
+    private LDCache ldcache;
 
     private SesameFilter<Resource> acceptor;
 
-    public KiWiLinkedDataSailConnection(NotifyingSailConnection wrappedCon, LDCacheNG ldcache, SesameFilter<Resource> acceptor) {
+    public KiWiLinkedDataSailConnection(NotifyingSailConnection wrappedCon, LDCache ldcache, SesameFilter<Resource> acceptor) {
         super(wrappedCon);
 
         this.ldcache = ldcache;

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldpath/ldpath-backend-linkeddata/src/main/java/org/apache/marmotta/ldpath/backend/linkeddata/LDPersistentBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-backend-linkeddata/src/main/java/org/apache/marmotta/ldpath/backend/linkeddata/LDPersistentBackend.java b/libraries/ldpath/ldpath-backend-linkeddata/src/main/java/org/apache/marmotta/ldpath/backend/linkeddata/LDPersistentBackend.java
index a7d2067..1e56703 100644
--- a/libraries/ldpath/ldpath-backend-linkeddata/src/main/java/org/apache/marmotta/ldpath/backend/linkeddata/LDPersistentBackend.java
+++ b/libraries/ldpath/ldpath-backend-linkeddata/src/main/java/org/apache/marmotta/ldpath/backend/linkeddata/LDPersistentBackend.java
@@ -19,7 +19,7 @@ package org.apache.marmotta.ldpath.backend.linkeddata;
 
 import org.apache.marmotta.commons.sesame.filter.AlwaysTrueFilter;
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
-import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackendNG;
+import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackend;
 import org.apache.marmotta.ldcache.sail.GenericLinkedDataSail;
 import org.apache.marmotta.ldclient.model.ClientConfiguration;
 import org.apache.marmotta.ldpath.backend.sesame.SesameRepositoryBackend;
@@ -43,7 +43,7 @@ import java.io.IOException;
 public class LDPersistentBackend extends SesameRepositoryBackend {
     private static final Logger log = LoggerFactory.getLogger(LDPersistentBackend.class);
 
-    private LDCachingFileBackendNG backend;
+    private LDCachingFileBackend backend;
 
     private GenericLinkedDataSail sail;
 
@@ -72,7 +72,7 @@ public class LDPersistentBackend extends SesameRepositoryBackend {
         try {
             ClientConfiguration config = new ClientConfiguration();
 
-            backend = new LDCachingFileBackendNG(dataDirectory);
+            backend = new LDCachingFileBackend(dataDirectory);
             sail = new GenericLinkedDataSail(new MemoryStore(),backend, cacheFilter, config);
             Repository repository = new SailRepository(sail);
             repository.initialize();

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/platform/ldcache/marmotta-ldcache-common/src/main/java/org/apache/marmotta/platform/ldcache/api/ldcache/LDCacheSailProvider.java
----------------------------------------------------------------------
diff --git a/platform/ldcache/marmotta-ldcache-common/src/main/java/org/apache/marmotta/platform/ldcache/api/ldcache/LDCacheSailProvider.java b/platform/ldcache/marmotta-ldcache-common/src/main/java/org/apache/marmotta/platform/ldcache/api/ldcache/LDCacheSailProvider.java
index f99a23e..9fac83d 100644
--- a/platform/ldcache/marmotta-ldcache-common/src/main/java/org/apache/marmotta/platform/ldcache/api/ldcache/LDCacheSailProvider.java
+++ b/platform/ldcache/marmotta-ldcache-common/src/main/java/org/apache/marmotta/platform/ldcache/api/ldcache/LDCacheSailProvider.java
@@ -17,7 +17,7 @@
 
 package org.apache.marmotta.platform.ldcache.api.ldcache;
 
-import org.apache.marmotta.ldcache.services.LDCacheNG;
+import org.apache.marmotta.ldcache.services.LDCache;
 import org.apache.marmotta.ldclient.api.endpoint.Endpoint;
 import org.apache.marmotta.ldclient.api.ldclient.LDClientService;
 import org.apache.marmotta.ldclient.model.ClientConfiguration;
@@ -155,7 +155,7 @@ public abstract class LDCacheSailProvider implements NotifyingSailProvider {
      * Return the caching backend used by the caching system (e.g. for debugging)
      * @return
      */
-    public abstract LDCacheNG getLDCache();
+    public abstract LDCache getLDCache();
 
     /**
      * Add a volatile (in-memory) endpoint to the LDClient configuration. Can be used by other services for auto-registering

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java
----------------------------------------------------------------------
diff --git a/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java b/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java
index b71ac41..96daf10 100644
--- a/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java
+++ b/platform/ldcache/marmotta-ldcache-file/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/FileLDCacheSailProvider.java
@@ -20,9 +20,9 @@ import com.google.common.collect.Lists;
 import org.apache.marmotta.commons.sesame.filter.NotFilter;
 import org.apache.marmotta.commons.sesame.filter.OneOfFilter;
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
-import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackendNG;
+import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackend;
 import org.apache.marmotta.ldcache.sail.GenericLinkedDataSail;
-import org.apache.marmotta.ldcache.services.LDCacheNG;
+import org.apache.marmotta.ldcache.services.LDCache;
 import org.apache.marmotta.ldclient.api.ldclient.LDClientService;
 import org.apache.marmotta.platform.core.model.filter.MarmottaLocalFilter;
 import org.apache.marmotta.platform.ldcache.api.ldcache.LDCacheSailProvider;
@@ -51,7 +51,7 @@ public class FileLDCacheSailProvider extends LDCacheSailProvider {
 
     private static Logger log = LoggerFactory.getLogger(FileLDCacheSailProvider.class);
 
-    private LDCachingFileBackendNG backend;
+    private LDCachingFileBackend backend;
 
     private GenericLinkedDataSail sail;
 
@@ -87,7 +87,7 @@ public class FileLDCacheSailProvider extends LDCacheSailProvider {
         directory = new File(configurationService.getHome() + File.separator + "ldcache");
 
         try {
-            backend = new LDCachingFileBackendNG(directory);
+            backend = new LDCachingFileBackend(directory);
             sail = new GenericLinkedDataSail(parent, backend, new NotFilter<Resource>(cacheFilters), ldclientConfig);
             return sail;
         } catch (RepositoryException e) {
@@ -113,7 +113,7 @@ public class FileLDCacheSailProvider extends LDCacheSailProvider {
      * Return the caching backend used by the caching system (e.g. for debugging)
      * @return
      */
-    public LDCacheNG getLDCache() {
+    public LDCache getLDCache() {
         if(sail != null) {
             return sail.getLDCache();
         } else {

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/platform/ldcache/marmotta-ldcache-kiwi/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/KiWiLDCacheSailProvider.java
----------------------------------------------------------------------
diff --git a/platform/ldcache/marmotta-ldcache-kiwi/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/KiWiLDCacheSailProvider.java b/platform/ldcache/marmotta-ldcache-kiwi/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/KiWiLDCacheSailProvider.java
index cb8f328..a285c66 100644
--- a/platform/ldcache/marmotta-ldcache-kiwi/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/KiWiLDCacheSailProvider.java
+++ b/platform/ldcache/marmotta-ldcache-kiwi/src/main/java/org/apache/marmotta/platform/ldcache/services/kiwi/KiWiLDCacheSailProvider.java
@@ -22,7 +22,7 @@ import org.apache.marmotta.commons.sesame.filter.NotFilter;
 import org.apache.marmotta.commons.sesame.filter.OneOfFilter;
 import org.apache.marmotta.commons.sesame.filter.SesameFilter;
 import org.apache.marmotta.ldcache.sail.KiWiLinkedDataSail;
-import org.apache.marmotta.ldcache.services.LDCacheNG;
+import org.apache.marmotta.ldcache.services.LDCache;
 import org.apache.marmotta.ldclient.api.ldclient.LDClientService;
 import org.apache.marmotta.platform.core.model.filter.MarmottaLocalFilter;
 import org.apache.marmotta.platform.ldcache.api.ldcache.LDCacheSailProvider;
@@ -95,7 +95,7 @@ public class KiWiLDCacheSailProvider extends LDCacheSailProvider {
      * Return the caching backend used by the caching system (e.g. for debugging)
      * @return
      */
-    public LDCacheNG getLDCache() {
+    public LDCache getLDCache() {
         if(sail != null) {
             return sail.getLDCache();
         } else {


[4/4] git commit: MARMOTTA-418: removed old LDCache API

Posted by ss...@apache.org.
MARMOTTA-418: removed old LDCache API


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/8941574c
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/8941574c
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/8941574c

Branch: refs/heads/develop
Commit: 8941574ce76f806b0f20ad805ab9766ca7dc13ad
Parents: aa84345
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Fri Jan 10 18:09:01 2014 +0100
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Fri Jan 10 18:09:01 2014 +0100

----------------------------------------------------------------------
 .../marmotta/ldcache/api/LDCachingBackend.java  |  64 ++-
 .../ldcache/api/LDCachingBackendNG.java         |  75 ----
 .../marmotta/ldcache/api/LDCachingService.java  | 101 ++---
 .../ldcache/api/LDCachingServiceNG.java         |  92 ----
 .../marmotta/ldcache/sail/LDCachingSail.java    |  34 --
 .../ldcache/sail/LDCachingSailConnection.java   |  57 ---
 .../backend/file/LDCachingFileBackend.java      | 185 +++++---
 .../backend/file/LDCachingFileBackendNG.java    | 227 ----------
 .../LDCachingFileRepositoryConnection.java      |  70 ---
 .../backend/file/test/LDCacheBackendTest.java   | 226 ----------
 .../backend/file/test/LDCacheFileNGTest.java    |  74 ----
 .../backend/file/test/LDCacheFileTest.java      |  74 ++++
 .../infinispan/LDCachingInfinispanBackend.java  |  89 ++--
 .../LDCachingInfinispanBackendNG.java           | 222 ----------
 ...LDCachingInfinispanRepositoryConnection.java | 130 ------
 .../test/LDCacheInfinispanNGTest.java           |  43 --
 .../infinispan/test/LDCacheInfinispanTest.java  | 124 +-----
 .../backend/kiwi/LDCachingKiWiBackend.java      | 307 ++++++++------
 .../backend/kiwi/LDCachingKiWiBackendNG.java    | 305 -------------
 .../LDCachingSailRepositoryConnection.java      |  91 ----
 .../backend/kiwi/sail/LDCachingKiWiSail.java    |  60 ---
 .../kiwi/sail/LDCachingKiWiSailConnection.java  | 134 ------
 .../backend/kiwi/test/LDCacheBackendTest.java   | 315 --------------
 .../services/test/LDCacheKiWiNGTest.java        | 168 --------
 .../ldcache/services/test/LDCacheKiWiTest.java  | 221 ++--------
 .../marmotta/ldcache/services/LDCache.java      | 425 ++++---------------
 .../marmotta/ldcache/services/LDCacheNG.java    | 230 ----------
 .../services/test/ng/BaseLDCacheNGTest.java     | 168 --------
 .../services/test/ng/BaseLDCacheTest.java       | 168 ++++++++
 .../ldcache/sail/GenericLinkedDataSail.java     |  26 +-
 .../sail/GenericLinkedDataSailConnection.java   |   8 +-
 .../test/GenericLinkedDataSailOfflineTest.java  |   6 +-
 .../ldcache/sail/KiWiLinkedDataSail.java        |  16 +-
 .../sail/KiWiLinkedDataSailConnection.java      |   6 +-
 .../backend/linkeddata/LDPersistentBackend.java |   6 +-
 .../api/ldcache/LDCacheSailProvider.java        |   4 +-
 .../services/kiwi/FileLDCacheSailProvider.java  |  10 +-
 .../services/kiwi/KiWiLDCacheSailProvider.java  |   4 +-
 38 files changed, 847 insertions(+), 3718 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingBackend.java b/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingBackend.java
index a121e20..34a2028 100644
--- a/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingBackend.java
+++ b/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingBackend.java
@@ -1,13 +1,12 @@
-/**
- * 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
+/*
+ * 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
+ *      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,
@@ -15,57 +14,53 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.marmotta.ldcache.api;
 
-import info.aduna.iteration.CloseableIteration;
 import org.apache.marmotta.ldcache.model.CacheEntry;
-import org.openrdf.repository.RepositoryException;
+import org.openrdf.model.URI;
 
 /**
- * This interface defines the API for different backends for storing the caching results.
- * <p/>
- * Author: Sebastian Schaffert (sschaffert@apache.org)
+ * Next generation caching backend API. Needs to be implemented by backend providers to offer caching support.
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
  */
 public interface LDCachingBackend {
 
+
     /**
-     * Return a repository connection that can be used for caching. The LDCache will first remove all statements for
-     * the newly cached resources and then add retrieved statements as-is to this connection and properly commit and
-     * close it after use.
-     * <p/>
-     * Note that in case the statements should be rewritten this method must take care of providing the proper
-     * connection, e.g. by using a ContextAwareRepositoryConnection to add a context to all statements when adding them.
+     * Return the cache entry for the given resource, or null if this entry does not exist.
      *
      *
-     * @param  resource the resource that will be cached
-     * @return a repository connection that can be used for storing retrieved triples for caching
+     * @param resource the resource to retrieve the cache entry for
+     * @return
      */
-    public LDCachingConnection getCacheConnection(String resource) throws RepositoryException;
+    public CacheEntry getEntry(URI resource);
 
 
     /**
-     * Return an iterator over all expired cache entries (can e.g. be used for refreshing).
+     * Update the cache entry for the given resource with the given entry.
      *
-     * @return
+     * @param resource the resource to update
+     * @param entry    the entry for the resource
      */
-    public CloseableIteration<CacheEntry,RepositoryException> listExpiredEntries() throws RepositoryException;
+    public void putEntry(URI resource, CacheEntry entry);
 
 
     /**
-     * Return an iterator over all cache entries (can e.g. be used for refreshing or expiring).
+     * Remove the cache entry for the given resource if it exists. Does nothing otherwise.
      *
-     * @return
+     * @param resource the resource to remove the entry for
      */
-    public CloseableIteration<CacheEntry,RepositoryException> listCacheEntries() throws RepositoryException;
+    public void removeEntry(URI resource);
 
 
     /**
-     * Return true in case the resource is a cached resource.
-     *
-     * @param resource the URI of the resource to check
-     * @return true in case the resource is a cached resource
+     * Clear all entries in the cache backend.
      */
-    public boolean isCached(String resource)  throws RepositoryException;
+    public void clear();
+
+
 
     /**
      * Carry out any initialization tasks that might be necessary
@@ -76,4 +71,5 @@ public interface LDCachingBackend {
      * Shutdown the backend and free all runtime resources.
      */
     public void shutdown();
+
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingBackendNG.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingBackendNG.java b/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingBackendNG.java
deleted file mode 100644
index 1f0e6b9..0000000
--- a/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingBackendNG.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.marmotta.ldcache.api;
-
-import org.apache.marmotta.ldcache.model.CacheEntry;
-import org.openrdf.model.URI;
-
-/**
- * Next generation caching backend API. Needs to be implemented by backend providers to offer caching support.
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public interface LDCachingBackendNG {
-
-
-    /**
-     * Return the cache entry for the given resource, or null if this entry does not exist.
-     *
-     *
-     * @param resource the resource to retrieve the cache entry for
-     * @return
-     */
-    public CacheEntry getEntry(URI resource);
-
-
-    /**
-     * Update the cache entry for the given resource with the given entry.
-     *
-     * @param resource the resource to update
-     * @param entry    the entry for the resource
-     */
-    public void putEntry(URI resource, CacheEntry entry);
-
-
-    /**
-     * Remove the cache entry for the given resource if it exists. Does nothing otherwise.
-     *
-     * @param resource the resource to remove the entry for
-     */
-    public void removeEntry(URI resource);
-
-
-    /**
-     * Clear all entries in the cache backend.
-     */
-    public void clear();
-
-
-
-    /**
-     * Carry out any initialization tasks that might be necessary
-     */
-    public void initialize();
-
-    /**
-     * Shutdown the backend and free all runtime resources.
-     */
-    public void shutdown();
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingService.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingService.java b/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingService.java
index bd385ca..82c2df7 100644
--- a/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingService.java
+++ b/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingService.java
@@ -1,13 +1,12 @@
-/**
- * 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
+/*
+ * 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
+ *      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,
@@ -17,13 +16,12 @@
  */
 package org.apache.marmotta.ldcache.api;
 
-import info.aduna.iteration.CloseableIteration;
-import org.apache.marmotta.ldcache.model.CacheEntry;
+import org.openrdf.model.Model;
 import org.openrdf.model.URI;
-import org.openrdf.repository.RepositoryException;
 
 /**
- * Add file description here!
+ * This is the next-generation API for LDCache that will become the default in Marmotta 3.3 or 4.0. For now,
+ * LDCache implements both the old and the new style.
  * <p/>
  * User: sschaffe
  */
@@ -31,47 +29,50 @@ public interface LDCachingService {
 
 
     /**
-     * Refresh the cached resource passed as argument. The method will do nothing for local
-     * resources.
-     * Calling the method will carry out the following tasks:
-     * 1. check whether the resource is a remote resource; if no, returns immediately
-     * 2. check whether the resource has a cache entry; if no, goto 4
-     * 3. check whether the expiry time of the cache entry has passed; if no, returns immediately
-     * 4. retrieve the triples for the resource from the Linked Data Cloud using the methods offered
-     * by the
-     * LinkedDataClientService (registered endpoints etc); returns immediately if the result is null
-     * or
-     * an exception is thrown
-     * 5. remove all old triples for the resource and add all new triples for the resource
-     * 6. create new expiry information of the cache entry and persist it in the transaction
+     * Refresh the resource passed as argument. If the resource is not yet cached or the cache entry is
+     * expired or refreshing is forced, the remote resource is retrieved using LDClient and the result stored
+     * in the cache. Otherwise the method does nothing.
      * 
      *
-     * @param resource
-     * @param forceRefresh if <code>true</code> the resource will be refreshed despite the
+     * @param resource  the resource to refresh
+     * @param options   options for refreshing
      */
-    public void refreshResource(URI resource, boolean forceRefresh);
+    public void refresh(URI resource, RefreshOpts... options);
+
 
     /**
-     * Refresh all expired resources by listing the cache entries that have expired and calling refreshResource on
-     * them. This method can e.g. be called by a scheduled task to regularly update cache entries to always have
-     * the latest version available in the Search Index and elsewhere.
+     * Refresh and return the resource passed as argument. If the resource is not yet cached or the cache entry is
+     * expired or refreshing is forced, the remote resource is retrieved using LDClient and the result stored
+     * in the cache. Otherwise the method does nothing.
+     *
+     * @param resource  the resource to retrieve
+     * @param options   options for refreshing
+     * @return a Sesame Model holding the triples representing the resource
      */
-    public void refreshExpired();
+    public Model get(URI resource, RefreshOpts... options);
+
 
     /**
      * Manually expire the caching information for the given resource. The resource will be
      * re-retrieved upon the next access.
      *
-     * @param resource the Resource to expire.
+     * @param resource the resource to expire.
      */
     public void expire(URI resource);
 
+
+    /**
+     * Return true in case the cache contains an entry for the resource given as argument.
+     *
+     * @param resource the resource to check
+     * @return true in case the resource is contained in the cache
+     */
+    public boolean contains(URI resource);
+
     /**
      * Manually expire all cached resources.
-     * 
-     * @see #expire(org.openrdf.model.URI)
      */
-    public void expireAll();
+    public void clear();
 
 
     /**
@@ -79,25 +80,13 @@ public interface LDCachingService {
      */
     public void shutdown();
 
-    /**
-     * Return a repository connection that can be used for accessing cached resources.
-     *
-     * @param  resource the resource that will be cached
-     * @return a repository connection that can be used for storing retrieved triples for caching
-     */
-    LDCachingConnection getCacheConnection(String resource) throws RepositoryException;
 
-    /**
-     * Return an iterator over all cache entries (can e.g. be used for refreshing or expiring).
-     *
-     * @return
-     */
-    CloseableIteration<CacheEntry, RepositoryException> listCacheEntries() throws RepositoryException;
 
-    /**
-     * Return an iterator over all expired cache entries (can e.g. be used for refreshing).
-     *
-     * @return
-     */
-    CloseableIteration<CacheEntry, RepositoryException> listExpiredEntries() throws RepositoryException;
+    public enum RefreshOpts {
+
+        /**
+         * Refresh the resource even if it is not yet expired
+         */
+        FORCE
+    }
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingServiceNG.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingServiceNG.java b/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingServiceNG.java
deleted file mode 100644
index 1a9d549..0000000
--- a/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingServiceNG.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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.marmotta.ldcache.api;
-
-import org.openrdf.model.Model;
-import org.openrdf.model.URI;
-
-/**
- * This is the next-generation API for LDCache that will become the default in Marmotta 3.3 or 4.0. For now,
- * LDCache implements both the old and the new style.
- * <p/>
- * User: sschaffe
- */
-public interface LDCachingServiceNG {
-
-
-    /**
-     * Refresh the resource passed as argument. If the resource is not yet cached or the cache entry is
-     * expired or refreshing is forced, the remote resource is retrieved using LDClient and the result stored
-     * in the cache. Otherwise the method does nothing.
-     * 
-     *
-     * @param resource  the resource to refresh
-     * @param options   options for refreshing
-     */
-    public void refresh(URI resource, RefreshOpts... options);
-
-
-    /**
-     * Refresh and return the resource passed as argument. If the resource is not yet cached or the cache entry is
-     * expired or refreshing is forced, the remote resource is retrieved using LDClient and the result stored
-     * in the cache. Otherwise the method does nothing.
-     *
-     * @param resource  the resource to retrieve
-     * @param options   options for refreshing
-     * @return a Sesame Model holding the triples representing the resource
-     */
-    public Model get(URI resource, RefreshOpts... options);
-
-
-    /**
-     * Manually expire the caching information for the given resource. The resource will be
-     * re-retrieved upon the next access.
-     *
-     * @param resource the resource to expire.
-     */
-    public void expire(URI resource);
-
-
-    /**
-     * Return true in case the cache contains an entry for the resource given as argument.
-     *
-     * @param resource the resource to check
-     * @return true in case the resource is contained in the cache
-     */
-    public boolean contains(URI resource);
-
-    /**
-     * Manually expire all cached resources.
-     */
-    public void clear();
-
-
-    /**
-     * Shutdown the caching service and free all occupied runtime resources.
-     */
-    public void shutdown();
-
-
-
-    public enum RefreshOpts {
-
-        /**
-         * Refresh the resource even if it is not yet expired
-         */
-        FORCE
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/sail/LDCachingSail.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/sail/LDCachingSail.java b/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/sail/LDCachingSail.java
deleted file mode 100644
index 4bd678b..0000000
--- a/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/sail/LDCachingSail.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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.marmotta.ldcache.sail;
-
-import org.openrdf.sail.Sail;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert (sschaffert@apache.org)
- */
-public interface LDCachingSail extends Sail {
-
-    /**
-     * Return a caching connection.
-     * @return
-     */
-    public LDCachingSailConnection getConnection();
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/sail/LDCachingSailConnection.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/sail/LDCachingSailConnection.java b/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/sail/LDCachingSailConnection.java
deleted file mode 100644
index bc4f0ce..0000000
--- a/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/sail/LDCachingSailConnection.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * 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.marmotta.ldcache.sail;
-
-import org.apache.marmotta.ldcache.model.CacheEntry;
-import org.openrdf.model.URI;
-import org.openrdf.sail.SailConnection;
-import org.openrdf.sail.SailException;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert (sschaffert@apache.org)
- */
-public interface LDCachingSailConnection extends SailConnection {
-
-    /**
-     * Get the cache entry for the passed resource, if any. Returns null in case there is no cache entry.
-     *
-     *
-     * @param resource the resource to look for
-     * @return the cache entry for the resource, or null if the resource has never been cached or is expired
-     */
-    public CacheEntry getCacheEntry(URI resource) throws SailException;
-
-    /**
-     * Store a cache entry for the passed resource in the backend. Depending on the backend, this can be a
-     * persistent storage or an in-memory storage.
-     *
-     * @param resource
-     * @param entry
-     */
-    public void addCacheEntry(URI resource, CacheEntry entry) throws SailException;
-
-
-    /**
-     * Remove the currently stored cache entry for the passed resource from the backend.
-     * @param resource
-     */
-    public void removeCacheEntry(URI resource) throws SailException;
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/LDCachingFileBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/LDCachingFileBackend.java b/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/LDCachingFileBackend.java
index bff143a..205933d 100644
--- a/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/LDCachingFileBackend.java
+++ b/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/LDCachingFileBackend.java
@@ -15,38 +15,32 @@
  * limitations under the License.
  */
 
-/**
- *
- */
 package org.apache.marmotta.ldcache.backend.file;
 
-import info.aduna.iteration.CloseableIteration;
-import info.aduna.iteration.ConvertingIteration;
-import info.aduna.iteration.FilterIteration;
-import info.aduna.iteration.IteratorIteration;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Date;
-
+import org.apache.marmotta.commons.sesame.model.ModelCommons;
 import org.apache.marmotta.ldcache.api.LDCachingBackend;
-import org.apache.marmotta.ldcache.api.LDCachingConnection;
-import org.apache.marmotta.ldcache.backend.file.repository.LDCachingFileRepositoryConnection;
 import org.apache.marmotta.ldcache.backend.file.util.FileBackendUtils;
 import org.apache.marmotta.ldcache.model.CacheEntry;
+import org.openrdf.model.Model;
+import org.openrdf.model.URI;
 import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.TreeModel;
 import org.openrdf.model.impl.ValueFactoryImpl;
 import org.openrdf.repository.Repository;
+import org.openrdf.repository.RepositoryConnection;
 import org.openrdf.repository.RepositoryException;
 import org.openrdf.repository.sail.SailRepository;
-import org.openrdf.sail.SailException;
 import org.openrdf.sail.nativerdf.NativeStore;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.File;
+import java.io.IOException;
+
 /**
- * @author jakob
+ * File-based implementation of the next generation LDCaching Backend API
  *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
  */
 public class LDCachingFileBackend implements LDCachingBackend {
 
@@ -62,75 +56,135 @@ public class LDCachingFileBackend implements LDCachingBackend {
 
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.marmotta.ldcache.api.LDCachingBackend#getCacheConnection(java.lang.String)
+
+    /**
+     * Return the cache entry for the given resource, or null if this entry does not exist.
+     *
+     *
+     * @param resource the resource to retrieve the cache entry for
+     * @return
      */
     @Override
-    public LDCachingConnection getCacheConnection(String resource) throws RepositoryException {
+    public CacheEntry getEntry(URI resource) {
+        try {
+            // load metadata from disk
+            final File dataFile = FileBackendUtils.getMetaFile(resource, storageDir);
+            if (!(dataFile.exists())) return null;
+            final CacheEntry ce = FileBackendUtils.readCacheEntry(dataFile, getValueFactory());
+            if (FileBackendUtils.isExpired(ce)) return null;
+
+            // read triples for this entry from cache repository
+            RepositoryConnection con = cacheRepository.getConnection();
+            try {
+                con.begin();
+
+                Model triples = new TreeModel();
+                ModelCommons.add(triples, con.getStatements(resource,null,null,true));
+                ce.setTriples(triples);
+
+                con.commit();
+            } catch(RepositoryException ex) {
+                con.rollback();
+            } finally {
+                con.close();
+            }
+
+            return ce;
+        } catch (IOException | RepositoryException e) {
+            log.error("error while loading cache entry from file system:",e);
 
-        return new LDCachingFileRepositoryConnection(cacheRepository, cacheRepository.getConnection(), storageDir);
+            return null;
+        }
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.marmotta.ldcache.api.LDCachingBackend#listExpiredEntries()
+
+    /**
+     * Update the cache entry for the given resource with the given entry.
+     *
+     * @param resource the resource to update
+     * @param entry    the entry for the resource
      */
     @Override
-    public CloseableIteration<CacheEntry, RepositoryException> listExpiredEntries() throws RepositoryException {
-        final Date now = new Date();
-        return new FilterIteration<CacheEntry, RepositoryException>(listCacheEntries()) {
-
-            @Override
-            protected boolean accept(CacheEntry object)
-                    throws RepositoryException {
-                return object.getExpiryDate().before(now);
+    public void putEntry(URI resource, CacheEntry entry) {
+        try {
+            FileBackendUtils.writeCacheEntry(entry, storageDir);
+
+            // update the repository with the triples from the entry
+            RepositoryConnection con = cacheRepository.getConnection();
+            try {
+                con.begin();
+
+                con.remove(resource,null,null);
+                con.add(entry.getTriples());
+
+                con.commit();
+            } catch(RepositoryException ex) {
+                con.rollback();
+            } finally {
+                con.close();
             }
-        };
+        } catch (IOException | RepositoryException e) {
+            log.error("could not store cache entry for {}: {}", resource.stringValue(), e.getMessage());
+        }
+
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.marmotta.ldcache.api.LDCachingBackend#listCacheEntries()
+    /**
+     * Remove the cache entry for the given resource if it exists. Does nothing otherwise.
+     *
+     * @param resource the resource to remove the entry for
      */
     @Override
-    public CloseableIteration<CacheEntry, RepositoryException> listCacheEntries()
-            throws RepositoryException {
-
-        final IteratorIteration<File, RepositoryException> ii = new IteratorIteration<File, RepositoryException>(FileBackendUtils.listMetaFiles(storageDir).iterator());
-        return new ConvertingIteration<File, CacheEntry, RepositoryException>(ii) {
-
-            @Override
-            protected CacheEntry convert(File sourceObject)
-                    throws RepositoryException {
-                try {
-                    return FileBackendUtils.readCacheEntry(sourceObject, cacheRepository.getValueFactory());
-                } catch (IOException e) {
-                    log.warn("Could not read caching properties from '{}'", sourceObject.getPath());
-                    throw new RepositoryException(e);
-                }
-            }
+    public void removeEntry(URI resource) {
+        try {
+            final File metaFile = FileBackendUtils.getMetaFile(resource, storageDir);
+            if (metaFile.exists()) metaFile.delete();
+
+            // update the repository with the triples from the entry
+            RepositoryConnection con = cacheRepository.getConnection();
+            try {
+                con.begin();
 
-        };
+                con.remove(resource, null, null);
+
+                con.commit();
+            } catch(RepositoryException ex) {
+                con.rollback();
+            } finally {
+                con.close();
+            }
+        } catch (RepositoryException e) {
+            log.error("could not remove cache entry for {}: {}", resource.stringValue(), e.getMessage());
+        }
     }
 
     /**
-     * Return true in case the resource is a cached resource.
-     *
-     * @param resource the URI of the resource to check
-     * @return true in case the resource is a cached resource
+     * Clear all entries in the cache backend.
      */
     @Override
-    public boolean isCached(String resource) throws RepositoryException {
+    public void clear() {
+        for(File metaFile : FileBackendUtils.listMetaFiles(storageDir)) {
+            metaFile.delete();
+        }
+
         try {
-            final File dataFile = FileBackendUtils.getMetaFile(resource, storageDir);
-            if (!(dataFile.exists())) return false;
-            final CacheEntry ce = FileBackendUtils.readCacheEntry(dataFile, new ValueFactoryImpl());
-            //return ce != null && !FileBackendUtils.isExpired(ce) && ce.getTripleCount() > 0;
-            return ce != null && ce.getTripleCount() > 0;
-        } catch (IOException e) {
-            throw new RepositoryException(e);
+            RepositoryConnection con = cacheRepository.getConnection();
+            try {
+                con.begin();
+
+                con.clear();
+
+                con.commit();
+            } catch(RepositoryException ex) {
+                con.rollback();
+            } finally {
+                con.close();
+            }
+        } catch(RepositoryException ex) {
+            log.error("could not clear cache: {}", ex.getMessage());
         }
     }
 
-
     /* (non-Javadoc)
      * @see org.apache.marmotta.ldcache.api.LDCachingBackend#initialize()
      */
@@ -165,4 +219,9 @@ public class LDCachingFileBackend implements LDCachingBackend {
 
     }
 
+
+    private ValueFactory getValueFactory() {
+        return ValueFactoryImpl.getInstance();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/LDCachingFileBackendNG.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/LDCachingFileBackendNG.java b/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/LDCachingFileBackendNG.java
deleted file mode 100644
index d6c99fa..0000000
--- a/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/LDCachingFileBackendNG.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * 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.marmotta.ldcache.backend.file;
-
-import org.apache.marmotta.commons.sesame.model.ModelCommons;
-import org.apache.marmotta.ldcache.api.LDCachingBackendNG;
-import org.apache.marmotta.ldcache.backend.file.util.FileBackendUtils;
-import org.apache.marmotta.ldcache.model.CacheEntry;
-import org.openrdf.model.Model;
-import org.openrdf.model.URI;
-import org.openrdf.model.ValueFactory;
-import org.openrdf.model.impl.TreeModel;
-import org.openrdf.model.impl.ValueFactoryImpl;
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.repository.sail.SailRepository;
-import org.openrdf.sail.nativerdf.NativeStore;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * File-based implementation of the next generation LDCaching Backend API
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class LDCachingFileBackendNG implements LDCachingBackendNG {
-
-    private static Logger log = LoggerFactory.getLogger(LDCachingFileBackend.class);
-
-    private final File storageDir;
-
-    private Repository cacheRepository;
-
-    public LDCachingFileBackendNG(File storageDir) throws RepositoryException {
-        if (storageDir == null) throw new NullPointerException();
-        this.storageDir = storageDir;
-
-    }
-
-
-    /**
-     * Return the cache entry for the given resource, or null if this entry does not exist.
-     *
-     *
-     * @param resource the resource to retrieve the cache entry for
-     * @return
-     */
-    @Override
-    public CacheEntry getEntry(URI resource) {
-        try {
-            // load metadata from disk
-            final File dataFile = FileBackendUtils.getMetaFile(resource, storageDir);
-            if (!(dataFile.exists())) return null;
-            final CacheEntry ce = FileBackendUtils.readCacheEntry(dataFile, getValueFactory());
-            if (FileBackendUtils.isExpired(ce)) return null;
-
-            // read triples for this entry from cache repository
-            RepositoryConnection con = cacheRepository.getConnection();
-            try {
-                con.begin();
-
-                Model triples = new TreeModel();
-                ModelCommons.add(triples, con.getStatements(resource,null,null,true));
-                ce.setTriples(triples);
-
-                con.commit();
-            } catch(RepositoryException ex) {
-                con.rollback();
-            } finally {
-                con.close();
-            }
-
-            return ce;
-        } catch (IOException | RepositoryException e) {
-            log.error("error while loading cache entry from file system:",e);
-
-            return null;
-        }
-    }
-
-
-    /**
-     * Update the cache entry for the given resource with the given entry.
-     *
-     * @param resource the resource to update
-     * @param entry    the entry for the resource
-     */
-    @Override
-    public void putEntry(URI resource, CacheEntry entry) {
-        try {
-            FileBackendUtils.writeCacheEntry(entry, storageDir);
-
-            // update the repository with the triples from the entry
-            RepositoryConnection con = cacheRepository.getConnection();
-            try {
-                con.begin();
-
-                con.remove(resource,null,null);
-                con.add(entry.getTriples());
-
-                con.commit();
-            } catch(RepositoryException ex) {
-                con.rollback();
-            } finally {
-                con.close();
-            }
-        } catch (IOException | RepositoryException e) {
-            log.error("could not store cache entry for {}: {}", resource.stringValue(), e.getMessage());
-        }
-
-    }
-
-    /**
-     * Remove the cache entry for the given resource if it exists. Does nothing otherwise.
-     *
-     * @param resource the resource to remove the entry for
-     */
-    @Override
-    public void removeEntry(URI resource) {
-        try {
-            final File metaFile = FileBackendUtils.getMetaFile(resource, storageDir);
-            if (metaFile.exists()) metaFile.delete();
-
-            // update the repository with the triples from the entry
-            RepositoryConnection con = cacheRepository.getConnection();
-            try {
-                con.begin();
-
-                con.remove(resource, null, null);
-
-                con.commit();
-            } catch(RepositoryException ex) {
-                con.rollback();
-            } finally {
-                con.close();
-            }
-        } catch (RepositoryException e) {
-            log.error("could not remove cache entry for {}: {}", resource.stringValue(), e.getMessage());
-        }
-    }
-
-    /**
-     * Clear all entries in the cache backend.
-     */
-    @Override
-    public void clear() {
-        for(File metaFile : FileBackendUtils.listMetaFiles(storageDir)) {
-            metaFile.delete();
-        }
-
-        try {
-            RepositoryConnection con = cacheRepository.getConnection();
-            try {
-                con.begin();
-
-                con.clear();
-
-                con.commit();
-            } catch(RepositoryException ex) {
-                con.rollback();
-            } finally {
-                con.close();
-            }
-        } catch(RepositoryException ex) {
-            log.error("could not clear cache: {}", ex.getMessage());
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.marmotta.ldcache.api.LDCachingBackend#initialize()
-     */
-    @Override
-    public void initialize() {
-        if (!storageDir.exists() && !storageDir.mkdirs()){
-            log.error("Could not create storage directory: " + storageDir.getPath());
-        } else if (!storageDir.isDirectory()) {
-            log.error(storageDir.getPath() + " is not a directory");
-        }
-
-        File tripleDir = new File(storageDir,"triples");
-
-        try {
-            cacheRepository = new SailRepository(new NativeStore(tripleDir, "spoc"));
-            cacheRepository.initialize();
-        } catch (RepositoryException ex) {
-            log.error("could not initialize cache directory",ex);
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.marmotta.ldcache.api.LDCachingBackend#shutdown()
-     */
-    @Override
-    public void shutdown() {
-        try {
-            cacheRepository.shutDown();
-        } catch (RepositoryException e) {
-            log.error("error while shutting down cache repository", e);
-        }
-
-    }
-
-
-    private ValueFactory getValueFactory() {
-        return ValueFactoryImpl.getInstance();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/repository/LDCachingFileRepositoryConnection.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/repository/LDCachingFileRepositoryConnection.java b/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/repository/LDCachingFileRepositoryConnection.java
deleted file mode 100644
index 959e424..0000000
--- a/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/repository/LDCachingFileRepositoryConnection.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.marmotta.ldcache.backend.file.repository;
-
-import org.apache.marmotta.ldcache.api.LDCachingConnection;
-import org.apache.marmotta.ldcache.backend.file.util.FileBackendUtils;
-import org.apache.marmotta.ldcache.model.CacheEntry;
-import org.openrdf.model.URI;
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.repository.base.RepositoryConnectionWrapper;
-
-import java.io.File;
-import java.io.IOException;
-
-public class LDCachingFileRepositoryConnection extends RepositoryConnectionWrapper implements LDCachingConnection {
-
-	private final File baseDir;
-
-	public LDCachingFileRepositoryConnection(Repository repository, RepositoryConnection repositoryConnection, File baseDir) {
-		super(repository, repositoryConnection);
-		this.baseDir = baseDir;
-	}
-
-	@Override
-	public CacheEntry getCacheEntry(URI resource) throws RepositoryException {
-		try {
-			final File dataFile = FileBackendUtils.getMetaFile(resource, baseDir);
-			if (!(dataFile.exists())) return null;
-			final CacheEntry ce = FileBackendUtils.readCacheEntry(dataFile, getValueFactory());
-			if (FileBackendUtils.isExpired(ce)) return null;
-			return ce;
-		} catch (IOException e) {
-			throw new RepositoryException("could not read cache entry for " + resource.stringValue(), e);
-		}
-	}
-
-	@Override
-	public void addCacheEntry(URI resource, CacheEntry entry)
-			throws RepositoryException {
-		try {
-			FileBackendUtils.writeCacheEntry(entry, baseDir);
-		} catch (IOException e) {
-			throw new RepositoryException("could not store cache entry for " + resource.stringValue(), e);
-		}
-	}
-
-	@Override
-	public void removeCacheEntry(URI resource) throws RepositoryException {
-		final File metaFile = FileBackendUtils.getMetaFile(resource, baseDir);
-		if (metaFile.exists()) metaFile.delete();
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-file/src/test/java/org/apache/marmotta/ldcache/backend/file/test/LDCacheBackendTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-file/src/test/java/org/apache/marmotta/ldcache/backend/file/test/LDCacheBackendTest.java b/libraries/ldcache/ldcache-backend-file/src/test/java/org/apache/marmotta/ldcache/backend/file/test/LDCacheBackendTest.java
deleted file mode 100644
index 0a24002..0000000
--- a/libraries/ldcache/ldcache-backend-file/src/test/java/org/apache/marmotta/ldcache/backend/file/test/LDCacheBackendTest.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * 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.marmotta.ldcache.backend.file.test;
-
-import com.google.common.io.Files;
-import info.aduna.iteration.CloseableIteration;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.marmotta.ldcache.api.LDCachingConnection;
-import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackend;
-import org.apache.marmotta.ldcache.model.CacheEntry;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
-import org.openrdf.model.Literal;
-import org.openrdf.model.Statement;
-import org.openrdf.model.URI;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.repository.RepositoryResult;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-/**
- * This test checks if the ldcache backend works, i.e. the system properly stores cache entries and cached triples.
- *
- * <p/>
- * Author: Sebastian Schaffert
- */
-public class LDCacheBackendTest {
-
-
-    private LDCachingFileBackend backend;
-
-    private File tmpDirectory;
-
-    @Before
-    public void initDatabase() throws RepositoryException {
-        tmpDirectory = Files.createTempDir();
-
-        backend = new LDCachingFileBackend(tmpDirectory);
-        backend.initialize();
-    }
-
-    @After
-    public void dropDatabase() throws RepositoryException, IOException {
-        backend.shutdown();
-
-        FileUtils.deleteDirectory(tmpDirectory);
-    }
-
-
-    final Logger logger =
-            LoggerFactory.getLogger(this.getClass());
-
-    @Rule
-    public TestWatcher watchman = new TestWatcher() {
-        /**
-         * Invoked when a test is about to start
-         */
-        @Override
-        protected void starting(Description description) {
-            logger.info("{} being run...", description.getMethodName());
-        }
-    };
-    /**
-     * This test verifies if triples are added to the correct context using the repository connection obtained from the backend
-     * @throws Exception
-     */
-    @Test
-    public void testStoreTriples() throws Exception {
-
-        RepositoryConnection con = backend.getCacheConnection("http://localhost/resource/1");
-        try {
-            con.begin();
-
-            URI subject    = con.getValueFactory().createURI("http://localhost/resource/1");
-            URI predicate  = con.getValueFactory().createURI("http://localhost/resource/" + RandomStringUtils.randomAlphanumeric(8));
-            Literal object1 = con.getValueFactory().createLiteral(RandomStringUtils.random(64));
-            Literal object2 = con.getValueFactory().createLiteral(RandomStringUtils.random(64));
-
-            Statement stmt1 = con.getValueFactory().createStatement(subject,predicate,object1);
-            Statement stmt2 = con.getValueFactory().createStatement(subject,predicate,object2);
-
-            con.add(stmt1);
-            con.add(stmt2);
-
-            con.commit();
-
-            RepositoryResult<Statement> it = con.getStatements(subject,predicate,null,true);
-            try {
-                while(it.hasNext()) {
-                    Statement next =  it.next();
-                    Assert.assertEquals(subject, next.getSubject());
-                }
-            } finally {
-                it.close();
-            }
-
-            con.commit();
-        } catch(RepositoryException ex) {
-            con.rollback();
-        } finally {
-            con.close();
-        }
-    }
-
-    /**
-     * Test storing and retrieving cache entries
-     *
-     * @throws Exception
-     */
-    @Test
-    public void testStoreEntries() throws Exception {
-        LDCachingConnection con = backend.getCacheConnection("http://localhost/resource/1");
-        try {
-            con.begin();
-
-            URI subject1     = con.getValueFactory().createURI("http://localhost/resource/"+ RandomStringUtils.randomAlphanumeric(8));
-            URI subject2     = con.getValueFactory().createURI("http://localhost/resource/"+ RandomStringUtils.randomAlphanumeric(8));
-            Literal object1  = con.getValueFactory().createLiteral(RandomStringUtils.random(64));
-            Literal object2  = con.getValueFactory().createLiteral(RandomStringUtils.random(64));
-            URI predicate    = con.getValueFactory().createURI("http://localhost/resource/"+ RandomStringUtils.randomAlphanumeric(8));
-
-            Statement stmt1 = con.getValueFactory().createStatement(subject1,predicate,object1);
-            Statement stmt2 = con.getValueFactory().createStatement(subject2,predicate,object2);
-
-            con.add(stmt1);
-            con.add(stmt2);
-
-            con.commit();
-
-            con.begin();
-            CacheEntry entry1 = new CacheEntry();
-            entry1.setExpiryDate(new Date(System.currentTimeMillis()+1000*60));
-            entry1.setLastRetrieved(new Date());
-            entry1.setUpdateCount(1);
-            entry1.setResource(subject1);
-            entry1.setTripleCount(1);
-            con.addCacheEntry(subject1, entry1);
-            con.commit();
-
-            Assert.assertTrue(backend.isCached(subject1.stringValue()));
-            Assert.assertFalse(backend.isCached(subject2.stringValue()));
-            Assert.assertEquals(1,asList(backend.listCacheEntries()).size());
-            Assert.assertEquals(0,asList(backend.listExpiredEntries()).size());
-
-            con.begin();
-            CacheEntry entry2 = new CacheEntry();
-            entry2.setExpiryDate(new Date(System.currentTimeMillis() - 1000 * 60));
-            entry2.setLastRetrieved(new Date());
-            entry2.setUpdateCount(1);
-            entry2.setResource(subject2);
-            entry2.setTripleCount(1);
-            con.addCacheEntry(subject2,entry2);
-
-            con.commit();
-
-            Assert.assertTrue(backend.isCached(subject1.stringValue()));
-            Assert.assertTrue(backend.isCached(subject2.stringValue()));
-            Assert.assertEquals(2,asList(backend.listCacheEntries()).size());
-            Assert.assertEquals(1,asList(backend.listExpiredEntries()).size());
-
-            con.begin();
-            con.removeCacheEntry(subject1);
-            con.commit();
-
-            Assert.assertFalse(backend.isCached(subject1.stringValue()));
-            Assert.assertTrue(backend.isCached(subject2.stringValue()));
-            Assert.assertEquals(1,asList(backend.listCacheEntries()).size());
-            Assert.assertEquals(1,asList(backend.listExpiredEntries()).size());
-        } catch(RepositoryException ex) {
-            con.rollback();
-        } finally {
-            con.close();
-        }
-    }
-
-
-    /**
-     * Workaround for https://openrdf.atlassian.net/browse/SES-1702 in Sesame 2.7.0-beta1
-     * @param <E>
-     * @return
-     */
-    public static <E,X extends Exception> List<E> asList(CloseableIteration<E,X> result) throws RepositoryException {
-        ArrayList<E> collection = new ArrayList<E>();
-        try {
-            try {
-                while (result.hasNext()) {
-                    collection.add(result.next());
-                }
-
-                return collection;
-            } finally {
-                result.close();
-            }
-        } catch(Throwable ex) {
-            throw new RepositoryException(ex);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-file/src/test/java/org/apache/marmotta/ldcache/backend/file/test/LDCacheFileNGTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-file/src/test/java/org/apache/marmotta/ldcache/backend/file/test/LDCacheFileNGTest.java b/libraries/ldcache/ldcache-backend-file/src/test/java/org/apache/marmotta/ldcache/backend/file/test/LDCacheFileNGTest.java
deleted file mode 100644
index 333057e..0000000
--- a/libraries/ldcache/ldcache-backend-file/src/test/java/org/apache/marmotta/ldcache/backend/file/test/LDCacheFileNGTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.marmotta.ldcache.backend.file.test;
-
-import com.google.common.io.Files;
-import org.apache.commons.io.FileUtils;
-import org.apache.marmotta.ldcache.api.LDCachingBackendNG;
-import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackendNG;
-import org.apache.marmotta.ldcache.services.test.ng.BaseLDCacheNGTest;
-import org.junit.internal.AssumptionViolatedException;
-import org.openrdf.repository.RepositoryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Add file description here!
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class LDCacheFileNGTest extends BaseLDCacheNGTest {
-
-    private static Logger log = LoggerFactory.getLogger(LDCacheFileNGTest.class);
-
-    /**
-     * Needs to be implemented by tests to provide the correct backend. Backend needs to be properly initialised.
-     *
-     * @return
-     */
-    @Override
-    protected LDCachingBackendNG createBackend() {
-        final File storageDir = Files.createTempDir();
-
-        LDCachingBackendNG backend = null;
-        try {
-            backend = new LDCachingFileBackendNG(storageDir) {
-                @Override
-                public void shutdown() {
-                    super.shutdown();
-
-                    try {
-                        FileUtils.deleteDirectory(storageDir);
-                    } catch (IOException e) {
-                    }
-                }
-            };
-            backend.initialize();
-
-            return backend;
-        } catch (RepositoryException e) {
-            throw new AssumptionViolatedException("could not initialise backend",e);
-        }
-    }
-
-
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-file/src/test/java/org/apache/marmotta/ldcache/backend/file/test/LDCacheFileTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-file/src/test/java/org/apache/marmotta/ldcache/backend/file/test/LDCacheFileTest.java b/libraries/ldcache/ldcache-backend-file/src/test/java/org/apache/marmotta/ldcache/backend/file/test/LDCacheFileTest.java
new file mode 100644
index 0000000..d08d866
--- /dev/null
+++ b/libraries/ldcache/ldcache-backend-file/src/test/java/org/apache/marmotta/ldcache/backend/file/test/LDCacheFileTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.marmotta.ldcache.backend.file.test;
+
+import com.google.common.io.Files;
+import org.apache.commons.io.FileUtils;
+import org.apache.marmotta.ldcache.api.LDCachingBackend;
+import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackend;
+import org.apache.marmotta.ldcache.services.test.ng.BaseLDCacheTest;
+import org.junit.internal.AssumptionViolatedException;
+import org.openrdf.repository.RepositoryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class LDCacheFileTest extends BaseLDCacheTest {
+
+    private static Logger log = LoggerFactory.getLogger(LDCacheFileTest.class);
+
+    /**
+     * Needs to be implemented by tests to provide the correct backend. Backend needs to be properly initialised.
+     *
+     * @return
+     */
+    @Override
+    protected LDCachingBackend createBackend() {
+        final File storageDir = Files.createTempDir();
+
+        LDCachingBackend backend = null;
+        try {
+            backend = new LDCachingFileBackend(storageDir) {
+                @Override
+                public void shutdown() {
+                    super.shutdown();
+
+                    try {
+                        FileUtils.deleteDirectory(storageDir);
+                    } catch (IOException e) {
+                    }
+                }
+            };
+            backend.initialize();
+
+            return backend;
+        } catch (RepositoryException e) {
+            throw new AssumptionViolatedException("could not initialise backend",e);
+        }
+    }
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-infinispan/src/main/java/org/apache/marmotta/ldcache/backend/infinispan/LDCachingInfinispanBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-infinispan/src/main/java/org/apache/marmotta/ldcache/backend/infinispan/LDCachingInfinispanBackend.java b/libraries/ldcache/ldcache-backend-infinispan/src/main/java/org/apache/marmotta/ldcache/backend/infinispan/LDCachingInfinispanBackend.java
index 686d11a..d112a32 100644
--- a/libraries/ldcache/ldcache-backend-infinispan/src/main/java/org/apache/marmotta/ldcache/backend/infinispan/LDCachingInfinispanBackend.java
+++ b/libraries/ldcache/ldcache-backend-infinispan/src/main/java/org/apache/marmotta/ldcache/backend/infinispan/LDCachingInfinispanBackend.java
@@ -14,14 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.marmotta.ldcache.backend.infinispan;
 
-import info.aduna.iteration.CloseableIteration;
-import info.aduna.iteration.CloseableIteratorIteration;
-import info.aduna.iteration.EmptyIteration;
 import org.apache.marmotta.ldcache.api.LDCachingBackend;
-import org.apache.marmotta.ldcache.api.LDCachingConnection;
-import org.apache.marmotta.ldcache.backend.infinispan.repository.LDCachingInfinispanRepositoryConnection;
 import org.apache.marmotta.ldcache.model.CacheEntry;
 import org.infinispan.Cache;
 import org.infinispan.configuration.cache.CacheMode;
@@ -34,8 +30,7 @@ import org.infinispan.distribution.ch.SyncConsistentHashFactory;
 import org.infinispan.eviction.EvictionStrategy;
 import org.infinispan.manager.DefaultCacheManager;
 import org.infinispan.manager.EmbeddedCacheManager;
-import org.openrdf.model.Model;
-import org.openrdf.repository.RepositoryException;
+import org.openrdf.model.URI;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -48,9 +43,10 @@ import java.util.concurrent.TimeUnit;
  */
 public class LDCachingInfinispanBackend implements LDCachingBackend {
 
+    private static Logger log = LoggerFactory.getLogger(LDCachingInfinispanBackend.class);
+
     public static final String LDCACHE_ENTRY_CACHE = "ldcache-entry-cache";
     public static final String LDCACHE_TRIPLE_CACHE = "ldcache-triple-cache";
-    private static Logger log = LoggerFactory.getLogger(LDCachingInfinispanBackend.class);
 
     private EmbeddedCacheManager cacheManager;
 
@@ -61,7 +57,6 @@ public class LDCachingInfinispanBackend implements LDCachingBackend {
     private boolean clustered;
 
     private Cache<String,CacheEntry> entryCache;
-    private Cache<String,Model>      tripleCache;
 
     /**
      * Create a non-clustered instance of the infinispan cache.
@@ -137,73 +132,59 @@ public class LDCachingInfinispanBackend implements LDCachingBackend {
     }
 
 
-    public Cache<String,CacheEntry> getEntryCache() {
-        if(entryCache == null) {
-            cacheManager.defineConfiguration(LDCACHE_ENTRY_CACHE, defaultConfiguration);
-
-            entryCache = cacheManager.<String,CacheEntry>getCache(LDCACHE_ENTRY_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
-        }
-
+    public synchronized Cache<String,CacheEntry> getEntryCache() {
         return entryCache;
 
     }
 
-    public Cache<String,Model> getTripleCache() {
-        if(tripleCache == null) {
-            cacheManager.defineConfiguration(LDCACHE_TRIPLE_CACHE, defaultConfiguration);
-
-            tripleCache = cacheManager.<String,Model>getCache(LDCACHE_TRIPLE_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
-        }
-
-        return tripleCache;
-
-    }
 
     /**
-     * Return a repository connection that can be used for caching. The LDCache will first remove all statements for
-     * the newly cached resources and then add retrieved statements as-is to this connection and properly commit and
-     * close it after use.
-     * <p/>
-     * Note that in case the statements should be rewritten this method must take care of providing the proper
-     * connection, e.g. by using a ContextAwareRepositoryConnection to add a context to all statements when adding them.
+     * Return the cache entry for the given resource, or null if this entry does not exist.
      *
-     * @param resource the resource that will be cached
-     * @return a repository connection that can be used for storing retrieved triples for caching
+     *
+     * @param resource the resource to retrieve the cache entry for
+     * @return
      */
     @Override
-    public LDCachingConnection getCacheConnection(String resource) throws RepositoryException {
-        return new LDCachingInfinispanRepositoryConnection(this, resource);
+    public CacheEntry getEntry(URI resource) {
+        CacheEntry entry = getEntryCache().get(resource.stringValue());
+
+        log.debug("retrieved entry for resource {}: {}", resource.stringValue(), entry);
+
+        return entry;
     }
 
     /**
-     * Return an iterator over all expired cache entries (can e.g. be used for refreshing).
+     * Update the cache entry for the given resource with the given entry.
      *
-     * @return
+     * @param resource the resource to update
+     * @param entry    the entry for the resource
      */
     @Override
-    public CloseableIteration<CacheEntry, RepositoryException> listExpiredEntries() throws RepositoryException {
-        return new EmptyIteration<>();  // Infinispan does not allow listing expired entries
+    public void putEntry(URI resource, CacheEntry entry) {
+        log.debug("updating entry for resource {} to {}", resource.stringValue(), entry);
+
+        getEntryCache().put(resource.stringValue(), entry);
     }
 
     /**
-     * Return an iterator over all cache entries (can e.g. be used for refreshing or expiring).
+     * Remove the cache entry for the given resource if it exists. Does nothing otherwise.
      *
-     * @return
+     * @param resource the resource to remove the entry for
      */
     @Override
-    public CloseableIteration<CacheEntry, RepositoryException> listCacheEntries() throws RepositoryException {
-        return new CloseableIteratorIteration<>(getEntryCache().values().iterator());
+    public void removeEntry(URI resource) {
+        log.debug("removing entry for resource {}", resource.stringValue());
+
+        getEntryCache().remove(resource.stringValue());
     }
 
     /**
-     * Return true in case the resource is a cached resource.
-     *
-     * @param resource the URI of the resource to check
-     * @return true in case the resource is a cached resource
+     * Clear all entries in the cache backend.
      */
     @Override
-    public boolean isCached(String resource) throws RepositoryException {
-        return getEntryCache().containsKey(resource);
+    public void clear() {
+        getEntryCache().clear();
     }
 
     /**
@@ -213,8 +194,12 @@ public class LDCachingInfinispanBackend implements LDCachingBackend {
     public void initialize() {
         cacheManager = new DefaultCacheManager(globalConfiguration, defaultConfiguration, true);
 
-        getEntryCache();
-        getTripleCache();
+        if(entryCache == null) {
+            cacheManager.defineConfiguration(LDCACHE_ENTRY_CACHE, defaultConfiguration);
+
+            entryCache = cacheManager.<String,CacheEntry>getCache(LDCACHE_ENTRY_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
+        }
+
 
         log.info("initialised cache manager ({})", globalConfiguration.isClustered() ? "cluster name: "+globalConfiguration.transport().clusterName() : "single host");
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-infinispan/src/main/java/org/apache/marmotta/ldcache/backend/infinispan/LDCachingInfinispanBackendNG.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-infinispan/src/main/java/org/apache/marmotta/ldcache/backend/infinispan/LDCachingInfinispanBackendNG.java b/libraries/ldcache/ldcache-backend-infinispan/src/main/java/org/apache/marmotta/ldcache/backend/infinispan/LDCachingInfinispanBackendNG.java
deleted file mode 100644
index 74c6c78..0000000
--- a/libraries/ldcache/ldcache-backend-infinispan/src/main/java/org/apache/marmotta/ldcache/backend/infinispan/LDCachingInfinispanBackendNG.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * 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.marmotta.ldcache.backend.infinispan;
-
-import org.apache.marmotta.ldcache.api.LDCachingBackendNG;
-import org.apache.marmotta.ldcache.model.CacheEntry;
-import org.infinispan.Cache;
-import org.infinispan.configuration.cache.CacheMode;
-import org.infinispan.configuration.cache.Configuration;
-import org.infinispan.configuration.cache.ConfigurationBuilder;
-import org.infinispan.configuration.global.GlobalConfiguration;
-import org.infinispan.configuration.global.GlobalConfigurationBuilder;
-import org.infinispan.context.Flag;
-import org.infinispan.distribution.ch.SyncConsistentHashFactory;
-import org.infinispan.eviction.EvictionStrategy;
-import org.infinispan.manager.DefaultCacheManager;
-import org.infinispan.manager.EmbeddedCacheManager;
-import org.openrdf.model.URI;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert (sschaffert@apache.org)
- */
-public class LDCachingInfinispanBackendNG implements LDCachingBackendNG {
-
-    private static Logger log = LoggerFactory.getLogger(LDCachingInfinispanBackendNG.class);
-
-    public static final String LDCACHE_ENTRY_CACHE = "ldcache-entry-cache";
-    public static final String LDCACHE_TRIPLE_CACHE = "ldcache-triple-cache";
-
-    private EmbeddedCacheManager cacheManager;
-
-    private GlobalConfiguration globalConfiguration;
-
-    private Configuration defaultConfiguration;
-
-    private boolean clustered;
-
-    private Cache<String,CacheEntry> entryCache;
-
-    /**
-     * Create a non-clustered instance of the infinispan cache.
-     */
-    public LDCachingInfinispanBackendNG() {
-        globalConfiguration = new GlobalConfigurationBuilder()
-                .classLoader(LDCachingInfinispanBackendNG.class.getClassLoader())
-                .globalJmxStatistics()
-                    .jmxDomain("org.apache.marmotta.ldcache")
-                    .allowDuplicateDomains(true)
-                .build();
-
-        defaultConfiguration = new ConfigurationBuilder()
-                .clustering()
-                    .cacheMode(CacheMode.LOCAL)
-                .eviction()
-                    .strategy(EvictionStrategy.LIRS)
-                    .maxEntries(100000)
-                .expiration()
-                    .lifespan(7, TimeUnit.DAYS)
-                    .maxIdle(1, TimeUnit.DAYS)
-                .build();
-
-        clustered = false;
-
-    }
-
-    /**
-     * Create a clustered instane of the infinispan cache backend using the provided cluster and machine name
-     * @param clusterName
-     * @param machineName
-     */
-    public LDCachingInfinispanBackendNG(String clusterName, String machineName) {
-        globalConfiguration = new GlobalConfigurationBuilder()
-                .classLoader(LDCachingInfinispanBackendNG.class.getClassLoader())
-                .transport()
-                    .defaultTransport()
-                    .clusterName(clusterName)
-                    .machineId(machineName)
-                    .addProperty("configurationFile", "jgroups-kiwi.xml")
-                .globalJmxStatistics()
-                    .jmxDomain("org.apache.marmotta.ldcache")
-                    .allowDuplicateDomains(true)
-                .build();
-
-
-
-        defaultConfiguration = new ConfigurationBuilder()
-                .clustering()
-                    .cacheMode(CacheMode.DIST_ASYNC)
-                        .async()
-                        .asyncMarshalling()
-                    .l1()
-                        .lifespan(5, TimeUnit.MINUTES)
-                    .hash()
-                        .numOwners(2)
-                        .numSegments(40)
-                        .consistentHashFactory(new SyncConsistentHashFactory())
-                .stateTransfer()
-                    .fetchInMemoryState(false)
-                .eviction()
-                    .strategy(EvictionStrategy.LIRS)
-                    .maxEntries(100000)
-                .expiration()
-                    .lifespan(7, TimeUnit.DAYS)
-                    .maxIdle(1, TimeUnit.DAYS)
-                .build();
-
-
-        clustered = true;
-
-
-    }
-
-
-    public synchronized Cache<String,CacheEntry> getEntryCache() {
-        return entryCache;
-
-    }
-
-
-    /**
-     * Return the cache entry for the given resource, or null if this entry does not exist.
-     *
-     *
-     * @param resource the resource to retrieve the cache entry for
-     * @return
-     */
-    @Override
-    public CacheEntry getEntry(URI resource) {
-        CacheEntry entry = getEntryCache().get(resource.stringValue());
-
-        log.debug("retrieved entry for resource {}: {}", resource.stringValue(), entry);
-
-        return entry;
-    }
-
-    /**
-     * Update the cache entry for the given resource with the given entry.
-     *
-     * @param resource the resource to update
-     * @param entry    the entry for the resource
-     */
-    @Override
-    public void putEntry(URI resource, CacheEntry entry) {
-        log.debug("updating entry for resource {} to {}", resource.stringValue(), entry);
-
-        getEntryCache().put(resource.stringValue(), entry);
-    }
-
-    /**
-     * Remove the cache entry for the given resource if it exists. Does nothing otherwise.
-     *
-     * @param resource the resource to remove the entry for
-     */
-    @Override
-    public void removeEntry(URI resource) {
-        log.debug("removing entry for resource {}", resource.stringValue());
-
-        getEntryCache().remove(resource.stringValue());
-    }
-
-    /**
-     * Clear all entries in the cache backend.
-     */
-    @Override
-    public void clear() {
-        getEntryCache().clear();
-    }
-
-    /**
-     * Carry out any initialization tasks that might be necessary
-     */
-    @Override
-    public void initialize() {
-        cacheManager = new DefaultCacheManager(globalConfiguration, defaultConfiguration, true);
-
-        if(entryCache == null) {
-            cacheManager.defineConfiguration(LDCACHE_ENTRY_CACHE, defaultConfiguration);
-
-            entryCache = cacheManager.<String,CacheEntry>getCache(LDCACHE_ENTRY_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
-        }
-
-
-        log.info("initialised cache manager ({})", globalConfiguration.isClustered() ? "cluster name: "+globalConfiguration.transport().clusterName() : "single host");
-
-    }
-
-    /**
-     * Shutdown the backend and free all runtime resources.
-     */
-    @Override
-    public void shutdown() {
-        log.warn("shutting down cache manager ...");
-        if(cacheManager.getTransport() != null) {
-            log.info("... shutting down transport ...");
-            cacheManager.getTransport().stop();
-        }
-        log.info("... shutting down main component ...");
-        cacheManager.stop();
-        log.info("... done!");
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-infinispan/src/main/java/org/apache/marmotta/ldcache/backend/infinispan/repository/LDCachingInfinispanRepositoryConnection.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-infinispan/src/main/java/org/apache/marmotta/ldcache/backend/infinispan/repository/LDCachingInfinispanRepositoryConnection.java b/libraries/ldcache/ldcache-backend-infinispan/src/main/java/org/apache/marmotta/ldcache/backend/infinispan/repository/LDCachingInfinispanRepositoryConnection.java
deleted file mode 100644
index 863c78d..0000000
--- a/libraries/ldcache/ldcache-backend-infinispan/src/main/java/org/apache/marmotta/ldcache/backend/infinispan/repository/LDCachingInfinispanRepositoryConnection.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * 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.marmotta.ldcache.backend.infinispan.repository;
-
-import org.apache.marmotta.ldcache.api.LDCachingConnection;
-import org.apache.marmotta.ldcache.backend.infinispan.LDCachingInfinispanBackend;
-import org.apache.marmotta.ldcache.model.CacheEntry;
-import org.openrdf.model.Model;
-import org.openrdf.model.Statement;
-import org.openrdf.model.URI;
-import org.openrdf.model.impl.TreeModel;
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.repository.RepositoryResult;
-import org.openrdf.repository.base.RepositoryConnectionWrapper;
-import org.openrdf.repository.sail.SailRepository;
-import org.openrdf.sail.memory.MemoryStore;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * Add file description here!
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class LDCachingInfinispanRepositoryConnection extends RepositoryConnectionWrapper implements LDCachingConnection {
-
-    private LDCachingInfinispanBackend backend;
-
-    private String resource;
-
-    public LDCachingInfinispanRepositoryConnection(LDCachingInfinispanBackend backend, String resource) throws RepositoryException {
-        super(getModelRepository(backend.getTripleCache().get(resource)));
-        setDelegate(getRepository().getConnection());
-        this.backend = backend;
-        this.resource = resource;
-    }
-
-
-    private static Repository getModelRepository(Model model) throws RepositoryException {
-        Repository repository = new SailRepository(new MemoryStore());
-        repository.initialize();
-
-        RepositoryConnection con = repository.getConnection();
-        try {
-            con.begin();
-
-            if(model != null) {
-                con.add(model);
-            }
-
-            con.commit();
-        } catch(RepositoryException ex) {
-            con.rollback();
-        } finally {
-            con.close();
-        }
-
-        return repository;
-    }
-
-
-    /**
-     * Get the cache entry for the passed resource, if any. Returns null in case there is no cache entry.
-     *
-     * @param resource the resource to look for
-     * @return the cache entry for the resource, or null if the resource has never been cached or is expired
-     */
-    @Override
-    public CacheEntry getCacheEntry(URI resource) throws RepositoryException {
-        return backend.getEntryCache().get(resource.stringValue());
-    }
-
-    /**
-     * Store a cache entry for the passed resource in the backend. Depending on the backend, this can be a
-     * persistent storage or an in-memory storage.
-     *
-     * @param resource
-     * @param entry
-     */
-    @Override
-    public void addCacheEntry(URI resource, CacheEntry entry) throws RepositoryException {
-        backend.getEntryCache().put(resource.stringValue(),entry,entry.getExpiryDate().getTime() - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
-
-        Model model = new TreeModel();
-
-        RepositoryResult<Statement> triples = getStatements(resource,null,null,true);
-        try {
-            while(triples.hasNext()) {
-                model.add(triples.next());
-            }
-        } finally {
-            triples.close();
-        }
-
-        backend.getTripleCache().put(resource.stringValue(),model,entry.getExpiryDate().getTime() - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
-    }
-
-    /**
-     * Remove the currently stored cache entry for the passed resource from the backend.
-     *
-     * @param resource
-     */
-    @Override
-    public void removeCacheEntry(URI resource) throws RepositoryException {
-        backend.getEntryCache().remove(resource.stringValue());
-        backend.getTripleCache().remove(resource.stringValue());
-    }
-
-    @Override
-    public void close() throws RepositoryException {
-        super.close();
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-infinispan/src/test/java/org/apache/marmotta/ldcache/infinispan/test/LDCacheInfinispanNGTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-infinispan/src/test/java/org/apache/marmotta/ldcache/infinispan/test/LDCacheInfinispanNGTest.java b/libraries/ldcache/ldcache-backend-infinispan/src/test/java/org/apache/marmotta/ldcache/infinispan/test/LDCacheInfinispanNGTest.java
deleted file mode 100644
index 5710042..0000000
--- a/libraries/ldcache/ldcache-backend-infinispan/src/test/java/org/apache/marmotta/ldcache/infinispan/test/LDCacheInfinispanNGTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.marmotta.ldcache.infinispan.test;
-
-import org.apache.marmotta.ldcache.api.LDCachingBackendNG;
-import org.apache.marmotta.ldcache.backend.infinispan.LDCachingInfinispanBackendNG;
-import org.apache.marmotta.ldcache.services.test.ng.BaseLDCacheNGTest;
-
-/**
- * Add file description here!
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class LDCacheInfinispanNGTest extends BaseLDCacheNGTest {
-
-    /**
-     * Needs to be implemented by tests to provide the correct backend. Backend needs to be properly initialised.
-     *
-     * @return
-     */
-    @Override
-    protected LDCachingBackendNG createBackend() {
-        LDCachingBackendNG backend = new LDCachingInfinispanBackendNG();
-        backend.initialize();
-
-        return backend;
-    }
-}


[3/4] MARMOTTA-418: removed old LDCache API

Posted by ss...@apache.org.
http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-infinispan/src/test/java/org/apache/marmotta/ldcache/infinispan/test/LDCacheInfinispanTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-infinispan/src/test/java/org/apache/marmotta/ldcache/infinispan/test/LDCacheInfinispanTest.java b/libraries/ldcache/ldcache-backend-infinispan/src/test/java/org/apache/marmotta/ldcache/infinispan/test/LDCacheInfinispanTest.java
index f26abf6..349651a 100644
--- a/libraries/ldcache/ldcache-backend-infinispan/src/test/java/org/apache/marmotta/ldcache/infinispan/test/LDCacheInfinispanTest.java
+++ b/libraries/ldcache/ldcache-backend-infinispan/src/test/java/org/apache/marmotta/ldcache/infinispan/test/LDCacheInfinispanTest.java
@@ -14,122 +14,30 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.marmotta.ldcache.infinispan.test;
 
-import info.aduna.iteration.CloseableIteration;
+import org.apache.marmotta.ldcache.api.LDCachingBackend;
 import org.apache.marmotta.ldcache.backend.infinispan.LDCachingInfinispanBackend;
-import org.apache.marmotta.ldcache.model.CacheConfiguration;
-import org.apache.marmotta.ldcache.services.LDCache;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.openrdf.model.ValueFactory;
-import org.openrdf.model.impl.ValueFactoryImpl;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class LDCacheInfinispanTest {
-
-
-    private LDCachingInfinispanBackend backend;
-
-    private LDCache ldcache;
-
-    private ValueFactory valueFactory;
-
-    @Before
-    public void initCache() throws RepositoryException {
-        backend = new LDCachingInfinispanBackend();
-        backend.initialize();
+import org.apache.marmotta.ldcache.services.test.ng.BaseLDCacheTest;
 
-        ldcache = new LDCache(new CacheConfiguration(),backend);
-
-        valueFactory = new ValueFactoryImpl();
-    }
-
-    @After
-    public void shutdownCache() throws RepositoryException, SQLException {
-        backend.shutdown();
-    }
-
-
-    /**
-     * Test retrieving and caching some resources (provided by DummyProvider).
-     */
-    @Test
-    public void testCacheResources() throws Exception {
-        String uri1 = "http://localhost/resource1";
-        String uri2 = "http://localhost/resource2";
-        String uri3 = "http://localhost/resource3";
-
-        ldcache.refreshResource(valueFactory.createURI(uri1),false);
-
-        Assert.assertEquals(1, asList(ldcache.listCacheEntries()).size());
-
-        RepositoryConnection con1 = ldcache.getCacheConnection(uri1);
-        try {
-            con1.begin();
-            Assert.assertEquals(3, asList(con1.getStatements(con1.getValueFactory().createURI(uri1), null, null, false)).size());
-            con1.commit();
-        } finally {
-            con1.close();
-        }
-
-        ldcache.refreshResource(valueFactory.createURI(uri2), false);
-
-        Assert.assertEquals(2, asList(ldcache.listCacheEntries()).size());
-
-        RepositoryConnection con2 = ldcache.getCacheConnection(uri2);
-        try {
-            con2.begin();
-            Assert.assertEquals(2, asList(con2.getStatements(con2.getValueFactory().createURI(uri2), null, null, false)).size());
-            con2.commit();
-        } finally {
-            con2.close();
-        }
-
-        ldcache.refreshResource(valueFactory.createURI(uri3), false);
-
-        Assert.assertEquals(3,asList(ldcache.listCacheEntries()).size());
-
-        RepositoryConnection con3 = ldcache.getCacheConnection(uri3);
-        try {
-            con3.begin();
-            Assert.assertEquals(2, asList(con3.getStatements(con3.getValueFactory().createURI(uri3), null, null, false)).size());
-            con3.commit();
-        } finally {
-            con3.close();
-        }
-    }
-
-
-    /*
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class LDCacheInfinispanTest extends BaseLDCacheTest {
 
     /**
-     * Workaround for https://openrdf.atlassian.net/browse/SES-1702 in Sesame 2.7.0-beta1
-     * @param <E>
+     * Needs to be implemented by tests to provide the correct backend. Backend needs to be properly initialised.
+     *
      * @return
      */
-    public static <E,X extends Exception> List<E> asList(CloseableIteration<E,X> result) throws RepositoryException {
-        ArrayList<E> collection = new ArrayList<E>();
-        try {
-            try {
-                while (result.hasNext()) {
-                    collection.add(result.next());
-                }
+    @Override
+    protected LDCachingBackend createBackend() {
+        LDCachingBackend backend = new LDCachingInfinispanBackend();
+        backend.initialize();
 
-                return collection;
-            } finally {
-                result.close();
-            }
-        } catch(Throwable ex) {
-            throw new RepositoryException(ex);
-        }
+        return backend;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackend.java b/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackend.java
index 0d7870b..1e22f9d 100644
--- a/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackend.java
+++ b/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackend.java
@@ -1,13 +1,12 @@
-/**
- * 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
+/*
+ * 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
+ *      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,
@@ -15,22 +14,29 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.marmotta.ldcache.backend.kiwi;
 
 import info.aduna.iteration.CloseableIteration;
-import info.aduna.iteration.ExceptionConvertingIteration;
+import org.apache.marmotta.commons.sesame.model.ModelCommons;
 import org.apache.marmotta.kiwi.sail.KiWiStore;
 import org.apache.marmotta.ldcache.api.LDCachingBackend;
-import org.apache.marmotta.ldcache.api.LDCachingConnection;
+import org.apache.marmotta.ldcache.backend.kiwi.model.KiWiCacheEntry;
 import org.apache.marmotta.ldcache.backend.kiwi.persistence.LDCachingKiWiPersistence;
 import org.apache.marmotta.ldcache.backend.kiwi.persistence.LDCachingKiWiPersistenceConnection;
-import org.apache.marmotta.ldcache.backend.kiwi.repository.LDCachingSailRepositoryConnection;
-import org.apache.marmotta.ldcache.backend.kiwi.sail.LDCachingKiWiSail;
-import org.apache.marmotta.ldcache.backend.kiwi.sail.LDCachingKiWiSailConnection;
 import org.apache.marmotta.ldcache.model.CacheEntry;
-import org.openrdf.repository.RepositoryException;
+import org.openrdf.model.Model;
+import org.openrdf.model.Resource;
+import org.openrdf.model.Statement;
+import org.openrdf.model.URI;
+import org.openrdf.model.impl.TreeModel;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.base.RepositoryWrapper;
 import org.openrdf.repository.sail.SailRepository;
+import org.openrdf.sail.Sail;
+import org.openrdf.sail.SailConnection;
 import org.openrdf.sail.SailException;
+import org.openrdf.sail.helpers.SailWrapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -38,8 +44,8 @@ import java.sql.SQLException;
 
 /**
  * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert (sschaffert@apache.org)
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
  */
 public class LDCachingKiWiBackend implements LDCachingBackend {
 
@@ -53,155 +59,221 @@ public class LDCachingKiWiBackend implements LDCachingBackend {
     private String cacheContext;
 
 
-    /**
-     * Direct access to the caching SAIL with its caching maintenance functionality.
-     */
-    private LDCachingKiWiSail sail;
-
 
-    private LDCachingKiWiPersistence persistence;
+    protected LDCachingKiWiPersistence persistence;
 
     /**
      * Repository API access to the cache data
      */
-    private SailRepository repository;
+    protected KiWiStore store;
+
 
     /**
      * Create a new LDCache KiWi backend using the given store and context for caching triples and storing cache
      * metadata via JDBC in the database.
      *
-     * @param store
      * @param cacheContext
      */
-    public LDCachingKiWiBackend(KiWiStore store, String cacheContext) {
+    public LDCachingKiWiBackend(Repository repository, String cacheContext) {
         this.cacheContext = cacheContext;
-        this.sail         = new LDCachingKiWiSail(store);
-        this.repository   = new SailRepository(sail);
-        this.persistence  = new LDCachingKiWiPersistence(store.getPersistence());
+        this.store   = getStore(repository);
+        this.persistence  = new LDCachingKiWiPersistence(getStore(repository).getPersistence());
     }
 
     /**
-     * Return a repository connection that can be used for caching. The LDCache will first remove all statements for
-     * the newly cached resources and then add retrieved statements as-is to this connection and properly commit and
-     * close it after use.
-     * <p/>
-     * Note that in case the statements should be rewritten this method must take care of providing the proper
-     * connection, e.g. by using a ContextAwareRepositoryConnection to add a context to all statements when adding them.
-     *
+     * Create a new LDCache KiWi backend using the given store and context for caching triples and storing cache
+     * metadata via JDBC in the database.
      *
-     * @param resource the resource that will be cached
-     * @return a repository connection that can be used for storing retrieved triples for caching
+     * @param cacheContext
      */
-    @Override
-    public LDCachingConnection getCacheConnection(String resource) throws RepositoryException {
-        try {
-            LDCachingKiWiSailConnection sailConnection = sail.getConnection();
+    public LDCachingKiWiBackend(Sail repository, String cacheContext) {
+        this.cacheContext = cacheContext;
+        this.store   = getStore(repository);
+        this.persistence  = new LDCachingKiWiPersistence(getStore(repository).getPersistence());
+    }
 
-            return new LDCachingSailRepositoryConnection(repository,sailConnection,cacheContext);
-        } catch (SailException e) {
-            throw new RepositoryException(e);
+
+    protected KiWiStore getStore(Repository repository) {
+        if(repository instanceof SailRepository) {
+            return getStore(((SailRepository) repository).getSail());
+        } else if(repository instanceof RepositoryWrapper) {
+            return getStore(((RepositoryWrapper) repository).getDelegate());
+        } else {
+            throw new IllegalArgumentException("the repository is not backed by a KiWiStore");
         }
     }
 
+
     /**
-     * Return an iterator over all expired cache entries (can e.g. be used for refreshing).
+     * Get the root sail in the wrapped sail stack
+     * @param sail
+     * @return
+     */
+    protected KiWiStore getStore(Sail sail) {
+        if(sail instanceof KiWiStore) {
+            return (KiWiStore) sail;
+        } else if(sail instanceof SailWrapper) {
+            return getStore(((SailWrapper) sail).getBaseSail());
+        } else {
+            throw new IllegalArgumentException("root sail is not a KiWiStore or could not be found");
+        }
+    }
+
+
+    /**
+     * Return the cache entry for the given resource, or null if this entry does not exist.
+     *
      *
+     * @param resource the resource to retrieve the cache entry for
      * @return
      */
     @Override
-    public CloseableIteration<CacheEntry, RepositoryException> listExpiredEntries()  throws RepositoryException {
+    public CacheEntry getEntry(URI resource) {
         try {
-            final LDCachingKiWiSailConnection sailConnection = sail.getConnection();
-            sailConnection.begin();
+            try(LDCachingKiWiPersistenceConnection dbcon = persistence.getConnection()) {
 
-            return new ExceptionConvertingIteration<CacheEntry, RepositoryException>(sailConnection.listExpired()) {
-                @Override
-                protected RepositoryException convert(Exception e) {
-                    return new RepositoryException(e);
-                }
+                // load cache entry from database
+                CacheEntry ce = dbcon.getCacheEntry(resource.stringValue());
 
-                /**
-                 * Closes this Iteration as well as the wrapped Iteration if it happens to be
-                 * a {@link info.aduna.iteration.CloseableIteration}.
-                 */
-                @Override
-                protected void handleClose() throws RepositoryException {
-                    super.handleClose();
+                // if entry exists, load triples for the resource from the cache context of the repository
+                if(ce != null) {
+                    SailConnection con = store.getConnection();
                     try {
-                        sailConnection.commit();
-                        sailConnection.close();
-                    } catch (SailException ex) {
-                        throw new RepositoryException(ex);
+                        con.begin();
+
+                        Model triples = new TreeModel();
+                        ModelCommons.add(triples,con.getStatements(resource,null,null,true,store.getValueFactory().createURI(cacheContext)));
+                        ce.setTriples(triples);
+
+                        con.commit();
+                    } catch(SailException ex) {
+                        con.rollback();
+                    } finally {
+                        con.close();
                     }
                 }
-            };
-        } catch (SailException e) {
-            throw new RepositoryException(e);
+                return ce;
+
+            }
+
+        } catch (SailException | SQLException e) {
+            log.error("could not retrieve cached triples from repository",e);
         }
+
+        return null;
     }
 
     /**
-     * Return an iterator over all cache entries (can e.g. be used for refreshing or expiring).
+     * Update the cache entry for the given resource with the given entry.
      *
-     * @return
+     * @param resource the resource to update
+     * @param entry    the entry for the resource
      */
     @Override
-    public CloseableIteration<CacheEntry, RepositoryException> listCacheEntries()  throws RepositoryException {
+    public void putEntry(URI resource, CacheEntry entry) {
         try {
-            final LDCachingKiWiSailConnection sailConnection = sail.getConnection();
-            sailConnection.begin();
+            try(LDCachingKiWiPersistenceConnection dbcon = persistence.getConnection()) {
 
-            return new ExceptionConvertingIteration<CacheEntry, RepositoryException>(sailConnection.listAll()) {
-                @Override
-                protected RepositoryException convert(Exception e) {
-                    return new RepositoryException(e);
-                }
+                // store cache entry in database
+                dbcon.removeCacheEntry(resource.stringValue());
 
-                /**
-                 * Closes this Iteration as well as the wrapped Iteration if it happens to be
-                 * a {@link info.aduna.iteration.CloseableIteration}.
-                 */
-                @Override
-                protected void handleClose() throws RepositoryException {
-                    super.handleClose();
-                    try {
-                        sailConnection.commit();
-                        sailConnection.close();
-                    } catch (SailException ex) {
-                        throw new RepositoryException(ex);
+                // update triples in cache
+                SailConnection con = store.getConnection();
+                try {
+                    con.begin();
+
+                    con.removeStatements(resource, null, null, store.getValueFactory().createURI(cacheContext));
+                    for(Statement stmt : entry.getTriples()) {
+                        con.addStatement(stmt.getSubject(), stmt.getPredicate(), stmt.getObject(), store.getValueFactory().createURI(cacheContext));
                     }
+
+                    con.commit();
+
+                    entry.setResource(store.getValueFactory().createURI(resource.stringValue()));
+
+                    dbcon.storeCacheEntry(entry);
+                } catch(SailException ex) {
+                    con.rollback();
+                } finally {
+                    con.close();
                 }
-            };
-        } catch (SailException e) {
-            throw new RepositoryException(e);
+
+            }
+
+        } catch (SailException | SQLException e) {
+            log.error("could not retrieve cached triples from repository",e);
         }
-    }
 
+    }
 
     /**
-     * Return true in case the resource is a cached resource.
+     * Remove the cache entry for the given resource if it exists. Does nothing otherwise.
      *
-     * @param resource the URI of the resource to check
-     * @return true in case the resource is a cached resource
+     * @param resource the resource to remove the entry for
      */
     @Override
-    public boolean isCached(String resource) throws RepositoryException {
+    public void removeEntry(URI resource) {
         try {
-            LDCachingKiWiPersistenceConnection con = persistence.getConnection();
-            try {
-                CacheEntry entry = con.getCacheEntry(resource);
-                return  entry != null && entry.getTripleCount() > 0;
-            } finally {
-                con.commit();
-                con.close();
+            try(LDCachingKiWiPersistenceConnection dbcon = persistence.getConnection()) {
+
+                // store cache entry in database
+                dbcon.removeCacheEntry(resource.stringValue());
+
+                // update triples in cache
+                SailConnection con = store.getConnection();
+                try {
+                    con.begin();
+
+                    con.removeStatements(resource, null, null, store.getValueFactory().createURI(cacheContext));
+
+                    con.commit();
+                } catch(SailException ex) {
+                    con.rollback();
+                } finally {
+                    con.close();
+                }
+
             }
-        } catch (SQLException e) {
-            throw new RepositoryException(e);
+
+        } catch (SailException | SQLException e) {
+            log.error("could not remove cached triples from repository",e);
         }
     }
 
-    public LDCachingKiWiPersistence getPersistence() {
-        return persistence;
+    /**
+     * Clear all entries in the cache backend.
+     */
+    @Override
+    public void clear() {
+        try {
+            try(LDCachingKiWiPersistenceConnection dbcon = persistence.getConnection()) {
+
+                // list all entries and remove them
+                CloseableIteration<KiWiCacheEntry, SQLException> entries = dbcon.listAll();
+                while (entries.hasNext()) {
+                    dbcon.removeCacheEntry(entries.next());
+                }
+
+                // update triples in cache
+                SailConnection con = store.getConnection();
+                try {
+                    con.begin();
+
+                    con.removeStatements((Resource) null, null, null, store.getValueFactory().createURI(cacheContext));
+
+                    con.commit();
+                } catch(SailException ex) {
+                    con.rollback();
+                } finally {
+                    con.close();
+                }
+
+            }
+
+        } catch (SailException | SQLException e) {
+            log.error("could not remove cached triples from repository",e);
+        }
+
     }
 
     /**
@@ -210,19 +282,13 @@ public class LDCachingKiWiBackend implements LDCachingBackend {
     @Override
     public void initialize() {
         try {
-            repository.initialize();
-        } catch (RepositoryException e) {
-            log.error("error initializing secondary repository",e);
-        }
-
-        try {
             persistence.initDatabase();
         } catch (SQLException e) {
             log.error("error initializing LDCache database tables",e);
         }
 
         // register cache context in database
-        repository.getValueFactory().createURI(cacheContext);
+        store.getValueFactory().createURI(cacheContext);
 
     }
 
@@ -231,12 +297,9 @@ public class LDCachingKiWiBackend implements LDCachingBackend {
      */
     @Override
     public void shutdown() {
-        try {
-            repository.shutDown();
-        } catch (RepositoryException e) {
-            log.error("error shutting down secondary repository",e);
-        }
     }
 
-
+    public LDCachingKiWiPersistence getPersistence() {
+        return persistence;
+    }
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackendNG.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackendNG.java b/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackendNG.java
deleted file mode 100644
index dd5082c..0000000
--- a/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackendNG.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * 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.marmotta.ldcache.backend.kiwi;
-
-import info.aduna.iteration.CloseableIteration;
-import org.apache.marmotta.commons.sesame.model.ModelCommons;
-import org.apache.marmotta.kiwi.sail.KiWiStore;
-import org.apache.marmotta.ldcache.api.LDCachingBackendNG;
-import org.apache.marmotta.ldcache.backend.kiwi.model.KiWiCacheEntry;
-import org.apache.marmotta.ldcache.backend.kiwi.persistence.LDCachingKiWiPersistence;
-import org.apache.marmotta.ldcache.backend.kiwi.persistence.LDCachingKiWiPersistenceConnection;
-import org.apache.marmotta.ldcache.model.CacheEntry;
-import org.openrdf.model.Model;
-import org.openrdf.model.Resource;
-import org.openrdf.model.Statement;
-import org.openrdf.model.URI;
-import org.openrdf.model.impl.TreeModel;
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.base.RepositoryWrapper;
-import org.openrdf.repository.sail.SailRepository;
-import org.openrdf.sail.Sail;
-import org.openrdf.sail.SailConnection;
-import org.openrdf.sail.SailException;
-import org.openrdf.sail.helpers.SailWrapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.SQLException;
-
-/**
- * Add file description here!
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class LDCachingKiWiBackendNG implements LDCachingBackendNG {
-
-    private static Logger log = LoggerFactory.getLogger(LDCachingKiWiBackendNG.class);
-
-
-
-    /**
-     * URI used as cache context in the central triple store
-     */
-    private String cacheContext;
-
-
-
-    protected LDCachingKiWiPersistence persistence;
-
-    /**
-     * Repository API access to the cache data
-     */
-    protected KiWiStore store;
-
-
-    /**
-     * Create a new LDCache KiWi backend using the given store and context for caching triples and storing cache
-     * metadata via JDBC in the database.
-     *
-     * @param cacheContext
-     */
-    public LDCachingKiWiBackendNG(Repository repository, String cacheContext) {
-        this.cacheContext = cacheContext;
-        this.store   = getStore(repository);
-        this.persistence  = new LDCachingKiWiPersistence(getStore(repository).getPersistence());
-    }
-
-    /**
-     * Create a new LDCache KiWi backend using the given store and context for caching triples and storing cache
-     * metadata via JDBC in the database.
-     *
-     * @param cacheContext
-     */
-    public LDCachingKiWiBackendNG(Sail repository, String cacheContext) {
-        this.cacheContext = cacheContext;
-        this.store   = getStore(repository);
-        this.persistence  = new LDCachingKiWiPersistence(getStore(repository).getPersistence());
-    }
-
-
-    protected KiWiStore getStore(Repository repository) {
-        if(repository instanceof SailRepository) {
-            return getStore(((SailRepository) repository).getSail());
-        } else if(repository instanceof RepositoryWrapper) {
-            return getStore(((RepositoryWrapper) repository).getDelegate());
-        } else {
-            throw new IllegalArgumentException("the repository is not backed by a KiWiStore");
-        }
-    }
-
-
-    /**
-     * Get the root sail in the wrapped sail stack
-     * @param sail
-     * @return
-     */
-    protected KiWiStore getStore(Sail sail) {
-        if(sail instanceof KiWiStore) {
-            return (KiWiStore) sail;
-        } else if(sail instanceof SailWrapper) {
-            return getStore(((SailWrapper) sail).getBaseSail());
-        } else {
-            throw new IllegalArgumentException("root sail is not a KiWiStore or could not be found");
-        }
-    }
-
-
-    /**
-     * Return the cache entry for the given resource, or null if this entry does not exist.
-     *
-     *
-     * @param resource the resource to retrieve the cache entry for
-     * @return
-     */
-    @Override
-    public CacheEntry getEntry(URI resource) {
-        try {
-            try(LDCachingKiWiPersistenceConnection dbcon = persistence.getConnection()) {
-
-                // load cache entry from database
-                CacheEntry ce = dbcon.getCacheEntry(resource.stringValue());
-
-                // if entry exists, load triples for the resource from the cache context of the repository
-                if(ce != null) {
-                    SailConnection con = store.getConnection();
-                    try {
-                        con.begin();
-
-                        Model triples = new TreeModel();
-                        ModelCommons.add(triples,con.getStatements(resource,null,null,true,store.getValueFactory().createURI(cacheContext)));
-                        ce.setTriples(triples);
-
-                        con.commit();
-                    } catch(SailException ex) {
-                        con.rollback();
-                    } finally {
-                        con.close();
-                    }
-                }
-                return ce;
-
-            }
-
-        } catch (SailException | SQLException e) {
-            log.error("could not retrieve cached triples from repository",e);
-        }
-
-        return null;
-    }
-
-    /**
-     * Update the cache entry for the given resource with the given entry.
-     *
-     * @param resource the resource to update
-     * @param entry    the entry for the resource
-     */
-    @Override
-    public void putEntry(URI resource, CacheEntry entry) {
-        try {
-            try(LDCachingKiWiPersistenceConnection dbcon = persistence.getConnection()) {
-
-                // store cache entry in database
-                dbcon.removeCacheEntry(resource.stringValue());
-
-                // update triples in cache
-                SailConnection con = store.getConnection();
-                try {
-                    con.begin();
-
-                    con.removeStatements(resource, null, null, store.getValueFactory().createURI(cacheContext));
-                    for(Statement stmt : entry.getTriples()) {
-                        con.addStatement(stmt.getSubject(), stmt.getPredicate(), stmt.getObject(), store.getValueFactory().createURI(cacheContext));
-                    }
-
-                    con.commit();
-
-                    entry.setResource(store.getValueFactory().createURI(resource.stringValue()));
-
-                    dbcon.storeCacheEntry(entry);
-                } catch(SailException ex) {
-                    con.rollback();
-                } finally {
-                    con.close();
-                }
-
-            }
-
-        } catch (SailException | SQLException e) {
-            log.error("could not retrieve cached triples from repository",e);
-        }
-
-    }
-
-    /**
-     * Remove the cache entry for the given resource if it exists. Does nothing otherwise.
-     *
-     * @param resource the resource to remove the entry for
-     */
-    @Override
-    public void removeEntry(URI resource) {
-        try {
-            try(LDCachingKiWiPersistenceConnection dbcon = persistence.getConnection()) {
-
-                // store cache entry in database
-                dbcon.removeCacheEntry(resource.stringValue());
-
-                // update triples in cache
-                SailConnection con = store.getConnection();
-                try {
-                    con.begin();
-
-                    con.removeStatements(resource, null, null, store.getValueFactory().createURI(cacheContext));
-
-                    con.commit();
-                } catch(SailException ex) {
-                    con.rollback();
-                } finally {
-                    con.close();
-                }
-
-            }
-
-        } catch (SailException | SQLException e) {
-            log.error("could not remove cached triples from repository",e);
-        }
-    }
-
-    /**
-     * Clear all entries in the cache backend.
-     */
-    @Override
-    public void clear() {
-        try {
-            try(LDCachingKiWiPersistenceConnection dbcon = persistence.getConnection()) {
-
-                // list all entries and remove them
-                CloseableIteration<KiWiCacheEntry, SQLException> entries = dbcon.listAll();
-                while (entries.hasNext()) {
-                    dbcon.removeCacheEntry(entries.next());
-                }
-
-                // update triples in cache
-                SailConnection con = store.getConnection();
-                try {
-                    con.begin();
-
-                    con.removeStatements((Resource) null, null, null, store.getValueFactory().createURI(cacheContext));
-
-                    con.commit();
-                } catch(SailException ex) {
-                    con.rollback();
-                } finally {
-                    con.close();
-                }
-
-            }
-
-        } catch (SailException | SQLException e) {
-            log.error("could not remove cached triples from repository",e);
-        }
-
-    }
-
-    /**
-     * Carry out any initialization tasks that might be necessary
-     */
-    @Override
-    public void initialize() {
-        try {
-            persistence.initDatabase();
-        } catch (SQLException e) {
-            log.error("error initializing LDCache database tables",e);
-        }
-
-        // register cache context in database
-        store.getValueFactory().createURI(cacheContext);
-
-    }
-
-    /**
-     * Shutdown the backend and free all runtime resources.
-     */
-    @Override
-    public void shutdown() {
-    }
-
-    public LDCachingKiWiPersistence getPersistence() {
-        return persistence;
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/repository/LDCachingSailRepositoryConnection.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/repository/LDCachingSailRepositoryConnection.java b/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/repository/LDCachingSailRepositoryConnection.java
deleted file mode 100644
index 6907145..0000000
--- a/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/repository/LDCachingSailRepositoryConnection.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * 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.marmotta.ldcache.backend.kiwi.repository;
-
-import org.apache.marmotta.commons.sesame.contextaware.ContextAwareSailConnection;
-import org.apache.marmotta.ldcache.api.LDCachingConnection;
-import org.apache.marmotta.ldcache.backend.kiwi.sail.LDCachingKiWiSailConnection;
-import org.apache.marmotta.ldcache.model.CacheEntry;
-import org.apache.marmotta.ldcache.sail.LDCachingSailConnection;
-import org.openrdf.model.URI;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.repository.sail.SailRepository;
-import org.openrdf.repository.sail.SailRepositoryConnection;
-
-/**
- * This is an extension wrapper around sail repository connections that allows delegating the additional cache entry
- * methods to the underlying SAIL repository. Otherwise it behaves like any SailRepositoryConnection.
- * <p/>
- * Author: Sebastian Schaffert (sschaffert@apache.org)
- */
-public class LDCachingSailRepositoryConnection extends SailRepositoryConnection implements LDCachingConnection {
-
-    private LDCachingSailConnection cacheConnection;
-
-    public LDCachingSailRepositoryConnection(SailRepository repository, LDCachingKiWiSailConnection sailConnection, String cacheContext) {
-        super(repository, new ContextAwareSailConnection(sailConnection, sailConnection.getValueFactory().createURI(cacheContext)));
-        cacheConnection = sailConnection;
-    }
-
-    /**
-     * Store a cache entry for the passed resource in the backend. Depending on the backend, this can be a
-     * persistent storage or an in-memory storage.
-     *
-     * @param resource
-     * @param entry
-     */
-    @Override
-    public void addCacheEntry(URI resource, CacheEntry entry) throws RepositoryException {
-        try {
-            cacheConnection.addCacheEntry(resource,entry);
-        } catch (org.openrdf.sail.SailException e) {
-            throw new RepositoryException(e);
-        }
-    }
-
-    /**
-     * Get the cache entry for the passed resource, if any. Returns null in case there is no cache entry.
-     *
-     *
-     * @param resource the resource to look for
-     * @return the cache entry for the resource, or null if the resource has never been cached or is expired
-     */
-    @Override
-    public CacheEntry getCacheEntry(URI resource) throws RepositoryException {
-        try {
-            return cacheConnection.getCacheEntry(resource);
-        } catch (org.openrdf.sail.SailException e) {
-            throw new RepositoryException(e);
-        }
-    }
-
-    /**
-     * Remove the currently stored cache entry for the passed resource from the backend.
-     *
-     * @param resource
-     */
-    @Override
-    public void removeCacheEntry(URI resource) throws RepositoryException {
-        try {
-            cacheConnection.removeCacheEntry(resource);
-        } catch (org.openrdf.sail.SailException e) {
-            throw new RepositoryException(e);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/sail/LDCachingKiWiSail.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/sail/LDCachingKiWiSail.java b/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/sail/LDCachingKiWiSail.java
deleted file mode 100644
index a8b1086..0000000
--- a/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/sail/LDCachingKiWiSail.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * 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.marmotta.ldcache.backend.kiwi.sail;
-
-import org.apache.marmotta.kiwi.sail.KiWiSailConnection;
-import org.apache.marmotta.kiwi.sail.KiWiStore;
-import org.openrdf.sail.SailException;
-import org.openrdf.sail.helpers.SailWrapper;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert (sschaffert@apache.org)
- */
-public class LDCachingKiWiSail extends SailWrapper {
-
-    private KiWiStore store;
-
-    /**
-     * Creates a new SailWrapper that wraps the supplied Sail.
-     */
-    public LDCachingKiWiSail(KiWiStore baseSail) {
-        super(baseSail);
-
-        this.store = baseSail;
-    }
-
-    @Override
-    public LDCachingKiWiSailConnection getConnection() throws SailException {
-        return new LDCachingKiWiSailConnection((KiWiSailConnection) store.getConnection());
-    }
-
-    @Override
-    public void initialize() throws SailException {
-        // ignore, because we assume that the wrapped store is already initialized
-        if(!store.isInitialized()) {
-            throw new SailException("the LDCachingKiWiSail is a secondary sail and requires an already initialized store!");
-        }
-    }
-
-    @Override
-    public void shutDown() throws SailException {
-        // ignore, because we assume that the wrapped store will be shutdown by another sail
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/sail/LDCachingKiWiSailConnection.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/sail/LDCachingKiWiSailConnection.java b/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/sail/LDCachingKiWiSailConnection.java
deleted file mode 100644
index 5ce66bf..0000000
--- a/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/sail/LDCachingKiWiSailConnection.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- * 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.marmotta.ldcache.backend.kiwi.sail;
-
-import info.aduna.iteration.CloseableIteration;
-import org.apache.marmotta.kiwi.sail.KiWiSailConnection;
-import org.apache.marmotta.kiwi.sail.KiWiValueFactory;
-import org.apache.marmotta.ldcache.backend.kiwi.model.KiWiCacheEntry;
-import org.apache.marmotta.ldcache.backend.kiwi.persistence.LDCachingKiWiPersistenceConnection;
-import org.apache.marmotta.ldcache.model.CacheEntry;
-import org.apache.marmotta.ldcache.sail.LDCachingSailConnection;
-import org.openrdf.model.URI;
-import org.openrdf.sail.SailException;
-import org.openrdf.sail.helpers.SailConnectionWrapper;
-
-import java.sql.SQLException;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert (sschaffert@apache.org)
- */
-public class LDCachingKiWiSailConnection extends SailConnectionWrapper implements LDCachingSailConnection {
-
-    private LDCachingKiWiPersistenceConnection persistence;
-
-    private KiWiSailConnection wrapped;
-
-    public LDCachingKiWiSailConnection(KiWiSailConnection wrappedCon) throws SailException {
-        super(wrappedCon);
-
-        this.wrapped = wrappedCon;
-        try {
-            this.persistence = new LDCachingKiWiPersistenceConnection(wrappedCon.getDatabaseConnection());
-        } catch (SQLException e) {
-            throw new SailException(e);
-        }
-    }
-
-    public KiWiValueFactory getValueFactory() {
-        return wrapped.getValueFactory();
-    }
-
-    /**
-     * Store a cache entry for the passed resource in the backend. Depending on the backend, this can be a
-     * persistent storage or an in-memory storage.
-     *
-     * @param resource
-     * @param entry
-     */
-    @Override
-    public void addCacheEntry(URI resource, CacheEntry entry) throws SailException {
-        try {
-            persistence.storeCacheEntry(entry);
-        } catch (SQLException e) {
-            throw new SailException(e);
-        }
-    }
-
-    /**
-     * Get the cache entry for the passed resource, if any. Returns null in case there is no cache entry.
-     *
-     *
-     * @param resource the resource to look for
-     * @return the cache entry for the resource, or null if the resource has never been cached or is expired
-     */
-    @Override
-    public CacheEntry getCacheEntry(URI resource) throws SailException {
-        try {
-            return persistence.getCacheEntry(resource.stringValue());
-        } catch (SQLException e) {
-            throw new SailException(e);
-        }
-    }
-
-    /**
-     * Remove the currently stored cache entry for the passed resource from the backend.
-     *
-     * @param resource
-     */
-    @Override
-    public void removeCacheEntry(URI resource) throws SailException {
-        try {
-            persistence.removeCacheEntry(resource.stringValue());
-        } catch (SQLException e) {
-            throw new SailException(e);
-        }
-    }
-
-    /**
-     * List all cache entries with an expiry date older than the current time.
-     *
-     * @return a closeable iteration with KiWiCacheEntries; needs to be released by the caller
-     * @throws SQLException
-     */
-    public CloseableIteration<KiWiCacheEntry,SQLException> listExpired() throws SailException {
-        try {
-            return persistence.listExpired();
-        } catch (SQLException e) {
-            throw new SailException(e);
-        }
-    }
-
-
-    /**
-     * List all cache entries in the database, regardless of expiry date.
-     *
-     * @return a closeable iteration with KiWiCacheEntries; needs to be released by the caller
-     * @throws SQLException
-     */
-    public CloseableIteration<KiWiCacheEntry,SQLException> listAll() throws SailException {
-        try {
-            return persistence.listAll();
-        } catch (SQLException e) {
-            throw new SailException(e);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/backend/kiwi/test/LDCacheBackendTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/backend/kiwi/test/LDCacheBackendTest.java b/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/backend/kiwi/test/LDCacheBackendTest.java
deleted file mode 100644
index e0ab3e8..0000000
--- a/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/backend/kiwi/test/LDCacheBackendTest.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/**
- * 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.marmotta.ldcache.backend.kiwi.test;
-
-import info.aduna.iteration.CloseableIteration;
-import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.marmotta.kiwi.persistence.KiWiDialect;
-import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
-import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
-import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
-import org.apache.marmotta.kiwi.sail.KiWiStore;
-import org.apache.marmotta.ldcache.api.LDCachingConnection;
-import org.apache.marmotta.ldcache.backend.kiwi.LDCachingKiWiBackend;
-import org.apache.marmotta.ldcache.model.CacheEntry;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.openrdf.model.Literal;
-import org.openrdf.model.Statement;
-import org.openrdf.model.URI;
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.repository.RepositoryResult;
-import org.openrdf.repository.sail.SailRepository;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-/**
- * This test checks if the ldcache backend works, i.e. the system properly stores cache entries and cached triples.
- * It will try running over all available databases. Except for in-memory databases like
- * H2 or Derby, database URLs must be passed as system property, or otherwise the test is skipped for this database.
- * Available system properties:
- * <ul>
- *     <li>PostgreSQL:
- *     <ul>
- *         <li>postgresql.url, e.g. jdbc:postgresql://localhost:5433/kiwitest?prepareThreshold=3</li>
- *         <li>postgresql.user (default: lmf)</li>
- *         <li>postgresql.pass (default: lmf)</li>
- *     </ul>
- *     </li>
- *     <li>MySQL:
- *     <ul>
- *         <li>mysql.url, e.g. jdbc:mysql://localhost:3306/kiwitest?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull</li>
- *         <li>mysql.user (default: lmf)</li>
- *         <li>mysql.pass (default: lmf</li>
- *     </ul>
- *     </li>
- *     <li>H2:
- *     <ul>
- *         <li>h2.url, e.g. jdbc:h2:mem;MVCC=true;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=10</li>
- *         <li>h2.user (default: lmf)</li>
- *         <li>h2.pass (default: lmf</li>
- *     </ul>
- *     </li>
- * </ul>
- *
- * <p/>
- * Author: Sebastian Schaffert
- */
-@RunWith(Parameterized.class)
-public class LDCacheBackendTest {
-
-
-    public static final String CACHE_CONTEXT = "http://localhost/context/cache";
-
-    /**
-     * Return database configurations if the appropriate parameters have been set.
-     *
-     * @return an array (database name, url, user, password)
-     */
-    @Parameterized.Parameters(name="Database Test {index}: {0} at {1}")
-    public static Iterable<Object[]> databases() {
-        String[] databases = {"H2", "PostgreSQL", "MySQL"};
-
-        List<Object[]> result = new ArrayList<Object[]>(databases.length);
-        for(String database : databases) {
-            if(System.getProperty(database.toLowerCase()+".url") != null) {
-                result.add(new Object[] {
-                        database,
-                        System.getProperty(database.toLowerCase()+".url"),
-                        System.getProperty(database.toLowerCase()+".user","lmf"),
-                        System.getProperty(database.toLowerCase()+".pass","lmf")
-                });
-            }
-        }
-        return result;
-    }
-
-
-    private KiWiDialect dialect;
-
-    private String jdbcUrl;
-
-    private String jdbcUser;
-
-    private String jdbcPass;
-
-    private KiWiStore store;
-
-    private LDCachingKiWiBackend backend;
-
-    private Repository repository;
-
-    public LDCacheBackendTest(String database, String jdbcUrl, String jdbcUser, String jdbcPass) {
-        this.jdbcPass = jdbcPass;
-        this.jdbcUrl = jdbcUrl;
-        this.jdbcUser = jdbcUser;
-
-        if("H2".equals(database)) {
-            this.dialect = new H2Dialect();
-        } else if("MySQL".equals(database)) {
-            this.dialect = new MySQLDialect();
-        } else if("PostgreSQL".equals(database)) {
-            this.dialect = new PostgreSQLDialect();
-        }
-    }
-
-
-    @Before
-    public void initDatabase() throws RepositoryException {
-        store = new KiWiStore("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred");
-        repository = new SailRepository(store);
-        repository.initialize();
-
-        backend = new LDCachingKiWiBackend(store, CACHE_CONTEXT);
-        backend.initialize();
-    }
-
-    @After
-    public void dropDatabase() throws RepositoryException, SQLException {
-        backend.getPersistence().dropDatabase();
-        store.getPersistence().dropDatabase();
-        repository.shutDown();
-    }
-
-
-    final Logger logger =
-            LoggerFactory.getLogger(this.getClass());
-
-    @Rule
-    public TestWatcher watchman = new TestWatcher() {
-        /**
-         * Invoked when a test is about to start
-         */
-        @Override
-        protected void starting(Description description) {
-            logger.info("{} being run...", description.getMethodName());
-        }
-    };
-
-    /**
-     * This test verifies if triples are added to the correct context using the repository connection obtained from the backend
-     * @throws Exception
-     */
-    @Test
-    public void testStoreTriples() throws Exception {
-
-        RepositoryConnection con = backend.getCacheConnection("http://localhost/resource/1");
-        try {
-            con.begin();
-
-            URI subject    = con.getValueFactory().createURI("http://localhost/resource/"+ RandomStringUtils.randomAlphanumeric(8));
-            URI predicate  = con.getValueFactory().createURI("http://localhost/resource/"+ RandomStringUtils.randomAlphanumeric(8));
-            Literal object1 = con.getValueFactory().createLiteral(RandomStringUtils.random(64));
-            Literal object2 = con.getValueFactory().createLiteral(RandomStringUtils.random(64));
-            URI context    = con.getValueFactory().createURI("http://localhost/resource/"+ RandomStringUtils.randomAlphanumeric(8));
-
-            Statement stmt1 = con.getValueFactory().createStatement(subject,predicate,object1);
-            Statement stmt2 = con.getValueFactory().createStatement(subject,predicate,object2,context);
-
-            con.add(stmt1);
-            con.add(stmt2);
-
-            con.commit();
-
-            RepositoryResult<Statement> it = con.getStatements(subject,predicate,null,true);
-            try {
-                while(it.hasNext()) {
-                    Statement next =  it.next();
-                    Assert.assertEquals(CACHE_CONTEXT, next.getContext().stringValue());
-                }
-            } finally {
-                it.close();
-            }
-
-            con.commit();
-        } catch(RepositoryException ex) {
-            con.rollback();
-        } finally {
-            con.close();
-        }
-    }
-
-    /**
-     * Test storing and retrieving cache entries
-     *
-     * @throws Exception
-     */
-    @Test
-    public void testStoreEntries() throws Exception {
-        LDCachingConnection con = backend.getCacheConnection("http://localhost/resource/1");
-        try {
-            con.begin();
-
-            URI subject1     = con.getValueFactory().createURI("http://localhost/resource/"+ RandomStringUtils.randomAlphanumeric(8));
-            URI subject2     = con.getValueFactory().createURI("http://localhost/resource/"+ RandomStringUtils.randomAlphanumeric(8));
-            Literal object1  = con.getValueFactory().createLiteral(RandomStringUtils.random(64));
-            Literal object2  = con.getValueFactory().createLiteral(RandomStringUtils.random(64));
-            URI predicate    = con.getValueFactory().createURI("http://localhost/resource/"+ RandomStringUtils.randomAlphanumeric(8));
-
-            Statement stmt1 = con.getValueFactory().createStatement(subject1,predicate,object1);
-            Statement stmt2 = con.getValueFactory().createStatement(subject2,predicate,object2);
-
-            con.add(stmt1);
-            con.add(stmt2);
-
-            con.commit();
-
-            con.begin();
-            CacheEntry entry1 = new CacheEntry();
-            entry1.setExpiryDate(new Date(System.currentTimeMillis()+1000*60));
-            entry1.setLastRetrieved(new Date());
-            entry1.setUpdateCount(1);
-            entry1.setResource(subject1);
-            entry1.setTripleCount(1);
-            con.addCacheEntry(subject1, entry1);
-            con.commit();
-
-            Assert.assertTrue(backend.isCached(subject1.stringValue()));
-            Assert.assertFalse(backend.isCached(subject2.stringValue()));
-            Assert.assertEquals(1,asList(backend.listCacheEntries()).size());
-            Assert.assertEquals(0,asList(backend.listExpiredEntries()).size());
-
-            con.begin();
-            CacheEntry entry2 = new CacheEntry();
-            entry2.setExpiryDate(new Date(System.currentTimeMillis() - 1000 * 60));
-            entry2.setLastRetrieved(new Date());
-            entry2.setUpdateCount(1);
-            entry2.setResource(subject2);
-            entry2.setTripleCount(1);
-            con.addCacheEntry(subject2,entry2);
-
-            con.commit();
-
-            Assert.assertTrue(backend.isCached(subject1.stringValue()));
-            Assert.assertTrue(backend.isCached(subject2.stringValue()));
-            Assert.assertEquals(2,asList(backend.listCacheEntries()).size());
-            Assert.assertEquals(1,asList(backend.listExpiredEntries()).size());
-
-            con.begin();
-            con.removeCacheEntry(subject1);
-            con.commit();
-
-            Assert.assertFalse(backend.isCached(subject1.stringValue()));
-            Assert.assertTrue(backend.isCached(subject2.stringValue()));
-            Assert.assertEquals(1,asList(backend.listCacheEntries()).size());
-            Assert.assertEquals(1,asList(backend.listExpiredEntries()).size());
-        } catch(RepositoryException ex) {
-            con.rollback();
-        } finally {
-            con.close();
-        }
-    }
-
-
-    /**
-     * Workaround for https://openrdf.atlassian.net/browse/SES-1702 in Sesame 2.7.0-beta1
-     * @param <E>
-     * @return
-     */
-    public static <E,X extends Exception> List<E> asList(CloseableIteration<E,X> result) throws RepositoryException {
-        ArrayList<E> collection = new ArrayList<E>();
-        try {
-            try {
-                while (result.hasNext()) {
-                    collection.add(result.next());
-                }
-
-                return collection;
-            } finally {
-                result.close();
-            }
-        } catch(Throwable ex) {
-            throw new RepositoryException(ex);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiNGTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiNGTest.java b/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiNGTest.java
deleted file mode 100644
index 4b822bc..0000000
--- a/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiNGTest.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * 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.marmotta.ldcache.services.test;
-
-import org.apache.marmotta.kiwi.persistence.KiWiDialect;
-import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
-import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
-import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
-import org.apache.marmotta.kiwi.sail.KiWiStore;
-import org.apache.marmotta.ldcache.api.LDCachingBackendNG;
-import org.apache.marmotta.ldcache.backend.kiwi.LDCachingKiWiBackendNG;
-import org.apache.marmotta.ldcache.services.test.ng.BaseLDCacheNGTest;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryException;
-import org.openrdf.repository.sail.SailRepository;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This test checks if the ldcache main class works, i.e. the system properly stores cache entries and cached triples.
- * It will try running over all available databases. Except for in-memory databases like
- * H2 or Derby, database URLs must be passed as system property, or otherwise the test is skipped for this database.
- * Available system properties:
- * <ul>
- *     <li>PostgreSQL:
- *     <ul>
- *         <li>postgresql.url, e.g. jdbc:postgresql://localhost:5433/kiwitest?prepareThreshold=3</li>
- *         <li>postgresql.user (default: lmf)</li>
- *         <li>postgresql.pass (default: lmf)</li>
- *     </ul>
- *     </li>
- *     <li>MySQL:
- *     <ul>
- *         <li>mysql.url, e.g. jdbc:mysql://localhost:3306/kiwitest?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull</li>
- *         <li>mysql.user (default: lmf)</li>
- *         <li>mysql.pass (default: lmf</li>
- *     </ul>
- *     </li>
- *     <li>H2:
- *     <ul>
- *         <li>h2.url, e.g. jdbc:h2:mem;MVCC=true;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=10</li>
- *         <li>h2.user (default: lmf)</li>
- *         <li>h2.pass (default: lmf</li>
- *     </ul>
- *     </li>
- * </ul>
- *
- * <p/>
- * Author: Sebastian Schaffert
- */
-@RunWith(Parameterized.class)
-public class LDCacheKiWiNGTest extends BaseLDCacheNGTest {
-
-    public static final String CACHE_CONTEXT = "http://localhost/context/cache";
-
-    /**
-     * Return database configurations if the appropriate parameters have been set.
-     *
-     * @return an array (database name, url, user, password)
-     */
-    @Parameterized.Parameters(name="Database Test {index}: {0} at {1}")
-    public static Iterable<Object[]> databases() {
-        String[] databases = {"H2", "PostgreSQL", "MySQL"};
-
-        List<Object[]> result = new ArrayList<Object[]>(databases.length);
-        for(String database : databases) {
-            if(System.getProperty(database.toLowerCase()+".url") != null) {
-                result.add(new Object[] {
-                        database,
-                        System.getProperty(database.toLowerCase()+".url"),
-                        System.getProperty(database.toLowerCase()+".user","lmf"),
-                        System.getProperty(database.toLowerCase()+".pass","lmf")
-                });
-            }
-        }
-        return result;
-    }
-
-
-    private KiWiDialect dialect;
-
-    private String jdbcUrl;
-
-    private String jdbcUser;
-
-    private String jdbcPass;
-
-
-    public LDCacheKiWiNGTest(String database, String jdbcUrl, String jdbcUser, String jdbcPass) {
-        this.jdbcPass = jdbcPass;
-        this.jdbcUrl = jdbcUrl;
-        this.jdbcUser = jdbcUser;
-
-        if("H2".equals(database)) {
-            this.dialect = new H2Dialect();
-        } else if("MySQL".equals(database)) {
-            this.dialect = new MySQLDialect();
-        } else if("PostgreSQL".equals(database)) {
-            this.dialect = new PostgreSQLDialect();
-        }
-    }
-
-
-    /**
-     * Needs to be implemented by tests to provide the correct backend. Backend needs to be properly initialised.
-     *
-     * @return
-     */
-    @Override
-    protected LDCachingBackendNG createBackend() {
-        try {
-            KiWiStore store = new KiWiStore("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred");
-            final Repository repository = new SailRepository(store);
-            repository.initialize();
-
-            LDCachingKiWiBackendNG backend = new LDCachingKiWiBackendNG(repository, CACHE_CONTEXT) {
-                /**
-                 * Shutdown the backend and free all runtime resources.
-                 */
-                @Override
-                public void shutdown() {
-
-                    try {
-                        persistence.dropDatabase();
-                        store.getPersistence().dropDatabase();
-
-                        super.shutdown();
-
-                        repository.shutDown();
-                    } catch (Exception e) { }
-                }
-            };
-            backend.initialize();
-
-
-            return backend;
-        } catch (RepositoryException e) {
-            throw new AssertionError(e);
-        }
-    }
-
-
-
-    @Override
-    @Test
-    @Ignore("does not work due to a bug in Sesame (SES-1993)")
-    public void testGeonames() throws Exception {
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/8941574c/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiTest.java b/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiTest.java
index b22b600..7d3a297 100644
--- a/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiTest.java
+++ b/libraries/ldcache/ldcache-backend-kiwi/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiTest.java
@@ -1,13 +1,12 @@
-/**
- * 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
+/*
+ * 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
+ *      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,
@@ -17,27 +16,22 @@
  */
 package org.apache.marmotta.ldcache.services.test;
 
-import info.aduna.iteration.CloseableIteration;
 import org.apache.marmotta.kiwi.persistence.KiWiDialect;
 import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
 import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
 import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
 import org.apache.marmotta.kiwi.sail.KiWiStore;
+import org.apache.marmotta.ldcache.api.LDCachingBackend;
 import org.apache.marmotta.ldcache.backend.kiwi.LDCachingKiWiBackend;
-import org.apache.marmotta.ldcache.model.CacheConfiguration;
-import org.apache.marmotta.ldcache.services.LDCache;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
+import org.apache.marmotta.ldcache.services.test.ng.BaseLDCacheTest;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryConnection;
 import org.openrdf.repository.RepositoryException;
 import org.openrdf.repository.sail.SailRepository;
 
-import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -74,7 +68,7 @@ import java.util.List;
  * Author: Sebastian Schaffert
  */
 @RunWith(Parameterized.class)
-public class LDCacheKiWiTest {
+public class LDCacheKiWiTest extends BaseLDCacheTest {
 
     public static final String CACHE_CONTEXT = "http://localhost/context/cache";
 
@@ -110,13 +104,6 @@ public class LDCacheKiWiTest {
 
     private String jdbcPass;
 
-    private KiWiStore store;
-
-    private LDCachingKiWiBackend backend;
-
-    private Repository repository;
-
-    private LDCache ldcache;
 
     public LDCacheKiWiTest(String database, String jdbcUrl, String jdbcUser, String jdbcPass) {
         this.jdbcPass = jdbcPass;
@@ -133,175 +120,49 @@ public class LDCacheKiWiTest {
     }
 
 
-    @Before
-    public void initDatabase() throws RepositoryException {
-        store = new KiWiStore("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred");
-        repository = new SailRepository(store);
-        repository.initialize();
-
-        backend = new LDCachingKiWiBackend(store, CACHE_CONTEXT);
-        backend.initialize();
-
-        ldcache = new LDCache(new CacheConfiguration(),backend);
-    }
-
-    @After
-    public void dropDatabase() throws RepositoryException, SQLException {
-        backend.getPersistence().dropDatabase();
-        store.getPersistence().dropDatabase();
-        backend.shutdown();
-        repository.shutDown();
-    }
-
-
     /**
-     * Test retrieving and caching some resources (provided by DummyProvider).
+     * Needs to be implemented by tests to provide the correct backend. Backend needs to be properly initialised.
+     *
+     * @return
      */
-    @Test
-    public void textCacheResources() throws Exception {
-        String uri1 = "http://localhost/resource1";
-        String uri2 = "http://localhost/resource2";
-        String uri3 = "http://localhost/resource3";
-
-        ldcache.refreshResource(repository.getValueFactory().createURI(uri1),false);
-
-        Assert.assertEquals(1,asList(ldcache.listCacheEntries()).size());
-
-        RepositoryConnection con1 = ldcache.getCacheConnection(uri1);
+    @Override
+    protected LDCachingBackend createBackend() {
         try {
-            con1.begin();
-            Assert.assertEquals(3, asList(con1.getStatements(con1.getValueFactory().createURI(uri1), null, null, false)).size());
-            con1.commit();
-        } finally {
-            con1.close();
-        }
+            KiWiStore store = new KiWiStore("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred");
+            final Repository repository = new SailRepository(store);
+            repository.initialize();
 
-        ldcache.refreshResource(repository.getValueFactory().createURI(uri2),false);
+            LDCachingKiWiBackend backend = new LDCachingKiWiBackend(repository, CACHE_CONTEXT) {
+                /**
+                 * Shutdown the backend and free all runtime resources.
+                 */
+                @Override
+                public void shutdown() {
 
-        Assert.assertEquals(2,asList(ldcache.listCacheEntries()).size());
+                    try {
+                        persistence.dropDatabase();
+                        store.getPersistence().dropDatabase();
 
-        RepositoryConnection con2 = ldcache.getCacheConnection(uri2);
-        try {
-            con2.begin();
-            Assert.assertEquals(2, asList(con2.getStatements(con2.getValueFactory().createURI(uri2), null, null, false)).size());
-            con2.commit();
-        } finally {
-            con2.close();
-        }
+                        super.shutdown();
 
-        ldcache.refreshResource(repository.getValueFactory().createURI(uri3),false);
+                        repository.shutDown();
+                    } catch (Exception e) { }
+                }
+            };
+            backend.initialize();
 
-        Assert.assertEquals(3,asList(ldcache.listCacheEntries()).size());
 
-        RepositoryConnection con3 = ldcache.getCacheConnection(uri3);
-        try {
-            con3.begin();
-            Assert.assertEquals(2, asList(con3.getStatements(con3.getValueFactory().createURI(uri3), null, null, false)).size());
-            con3.commit();
-        } finally {
-            con3.close();
+            return backend;
+        } catch (RepositoryException e) {
+            throw new AssertionError(e);
         }
     }
 
 
-    /**
-     * Test retrieving and caching some resources (provided by DummyProvider).
-     */
-    @Test
-    public void textExpire() throws Exception {
-        String uri1 = "http://localhost/resource1";
-        String uri2 = "http://localhost/resource2";
-        String uri3 = "http://localhost/resource3";
-
-        ldcache.refreshResource(repository.getValueFactory().createURI(uri1),false);
-        ldcache.refreshResource(repository.getValueFactory().createURI(uri2),false);
-        ldcache.refreshResource(repository.getValueFactory().createURI(uri3),false);
-
-        Assert.assertEquals(3,asList(ldcache.listCacheEntries()).size());
-        Assert.assertEquals(0,asList(ldcache.listExpiredEntries()).size());
-
-        ldcache.expire(repository.getValueFactory().createURI(uri1));
-
-        mysqlSleep();
-
-        Assert.assertEquals(1,asList(ldcache.listExpiredEntries()).size());
-
-        ldcache.refreshExpired();
-
-        mysqlSleep();
 
-        Assert.assertEquals(0,asList(ldcache.listExpiredEntries()).size());
-
-    }
-
-    /**
-     * Test retrieving and caching some resources (provided by DummyProvider).
-     */
+    @Override
     @Test
-    public void textExpireAll() throws Exception {
-        String uri1 = "http://localhost/resource1";
-        String uri2 = "http://localhost/resource2";
-        String uri3 = "http://localhost/resource3";
-
-        ldcache.refreshResource(repository.getValueFactory().createURI(uri1),false);
-        ldcache.refreshResource(repository.getValueFactory().createURI(uri2),false);
-        ldcache.refreshResource(repository.getValueFactory().createURI(uri3),false);
-
-        Assert.assertEquals(3,asList(ldcache.listCacheEntries()).size());
-        Assert.assertEquals(0,asList(ldcache.listExpiredEntries()).size());
-
-        ldcache.expireAll();
-
-        mysqlSleep();
-
-        Assert.assertEquals(3,asList(ldcache.listExpiredEntries()).size());
-
-        ldcache.refreshExpired();
-
-        mysqlSleep();
-
-        Assert.assertEquals(0,asList(ldcache.listExpiredEntries()).size());
-
-    }
-
-
-    /*
-     * MYSQL rounds timestamps to the second, so it is sometimes necessary to sleep before doing a test
-     */
-    private  void mysqlSleep() {
-        if(this.dialect instanceof MySQLDialect) {
-            try {
-                Thread.sleep(1000);
-            } catch (InterruptedException e) {
-            }
-        } else {
-            try {
-                Thread.sleep(100);
-            } catch (InterruptedException e) {
-            }
-        }
-    }
-
-    /**
-     * Workaround for https://openrdf.atlassian.net/browse/SES-1702 in Sesame 2.7.0-beta1
-     * @param <E>
-     * @return
-     */
-    public static <E,X extends Exception> List<E> asList(CloseableIteration<E,X> result) throws RepositoryException {
-        ArrayList<E> collection = new ArrayList<E>();
-        try {
-            try {
-                while (result.hasNext()) {
-                    collection.add(result.next());
-                }
-
-                return collection;
-            } finally {
-                result.close();
-            }
-        } catch(Throwable ex) {
-            throw new RepositoryException(ex);
-        }
+    @Ignore("does not work due to a bug in Sesame (SES-1993)")
+    public void testGeonames() throws Exception {
     }
-
 }