marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sschaff...@apache.org
Subject [18/32] git commit: fix the remaining triple store components so they properly use the modularized caching system
Date Mon, 17 Mar 2014 10:23:09 GMT
fix the remaining triple store components so they properly use the modularized caching system


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

Branch: refs/heads/develop
Commit: b25a254972dd86edef57e7d1ff78a73b26818e39
Parents: d46c684
Author: Sebastian Schaffert <sschaffert@apache.org>
Authored: Tue Mar 4 21:04:56 2014 +0100
Committer: Sebastian Schaffert <sschaffert@apache.org>
Committed: Tue Mar 4 21:04:56 2014 +0100

----------------------------------------------------------------------
 libraries/kiwi/kiwi-caching/pom.xml             | 197 --------
 .../config/KiWiQueryCacheConfiguration.java     |  69 ---
 .../caching/iteration/BufferingIteration.java   | 118 -----
 .../caching/iteration/CachingIteration.java     | 136 -----
 .../kiwi/caching/sail/KiWiCachingSail.java      | 164 ------
 .../caching/sail/KiWiCachingSailConnection.java | 503 -------------------
 .../GeronimoTransactionManagerLookup.java       |  46 --
 .../KiWiCachingRepositoryConnectionTest.java    |  64 ---
 .../caching/test/KiWiCachingRepositoryTest.java |  61 ---
 .../persistence/KiWiReasoningConnection.java    |   7 +-
 .../persistence/KiWiVersioningConnection.java   |   4 +-
 libraries/kiwi/pom.xml                          |   1 -
 12 files changed, 5 insertions(+), 1365 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/b25a2549/libraries/kiwi/kiwi-caching/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching/pom.xml b/libraries/kiwi/kiwi-caching/pom.xml
deleted file mode 100644
index d7bd8e0..0000000
--- a/libraries/kiwi/kiwi-caching/pom.xml
+++ /dev/null
@@ -1,197 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ 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.
-  -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-
-    <parent>
-        <groupId>org.apache.marmotta</groupId>
-        <artifactId>kiwi-parent</artifactId>
-        <version>3.2.0-SNAPSHOT</version>
-        <relativePath>../</relativePath>
-    </parent>
-
-    <artifactId>kiwi-caching</artifactId>
-    <packaging>jar</packaging>
-
-    <name>KiWi Triplestore: Caching</name>
-    <description>
-        Provides transparent query caching on top of the KiWi triplestore. Queries are cached using the Infinispan
-        distributed caching system using the EmbeddedCacheManager used by the triplestore itself.
-    </description>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.marmotta</groupId>
-            <artifactId>kiwi-triplestore</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.infinispan</groupId>
-            <artifactId>infinispan-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.geronimo.components</groupId>
-            <artifactId>geronimo-transaction</artifactId>
-            <version>3.1.1</version>
-
-            <exclusions>
-                <exclusion>
-                    <groupId>org.apache.geronimo.ext.tomcat</groupId>
-                    <artifactId>juli</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.geronimo.ext.tomcat</groupId>
-                    <artifactId>util</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.geronimo.specs</groupId>
-                    <artifactId>geronimo-servlet_3.0_spec</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.geronimo.specs</groupId>
-                    <artifactId>geronimo-jta_1.1_spec</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-
-
-        <!-- Logging -->
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>log4j-over-slf4j</artifactId>
-        </dependency>
-
-        <!-- Sesame dependencies -->
-        <dependency>
-            <groupId>org.openrdf.sesame</groupId>
-            <artifactId>sesame-model</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.openrdf.sesame</groupId>
-            <artifactId>sesame-sail-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.openrdf.sesame</groupId>
-            <artifactId>sesame-repository-sail</artifactId>
-        </dependency>
-
-        <!-- Utilities -->
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.marmotta</groupId>
-            <artifactId>marmotta-commons</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.marmotta</groupId>
-            <artifactId>marmotta-util-filter</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-        </dependency>
-
-
-        <!-- Testing -->
-        <dependency>
-            <artifactId>junit</artifactId>
-            <groupId>junit</groupId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.marmotta</groupId>
-            <artifactId>kiwi-triplestore</artifactId>
-            <type>test-jar</type>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <artifactId>hamcrest-core</artifactId>
-            <groupId>org.hamcrest</groupId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <artifactId>hamcrest-library</artifactId>
-            <groupId>org.hamcrest</groupId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-core</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-classic</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.h2database</groupId>
-            <artifactId>h2</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.postgresql</groupId>
-            <artifactId>postgresql</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-            <scope>test</scope>
-            <optional>true</optional> <!-- GPL licensed, no dependency -->
-        </dependency>
-        <dependency>
-            <groupId>org.openrdf.sesame</groupId>
-            <artifactId>sesame-rio-api</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.openrdf.sesame</groupId>
-            <artifactId>sesame-rio-rdfxml</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.openrdf.sesame</groupId>
-            <artifactId>sesame-queryparser-api</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.openrdf.sesame</groupId>
-            <artifactId>sesame-queryparser-sparql</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.openrdf.sesame</groupId>
-            <artifactId>sesame-store-testsuite</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-    </dependencies>
-    
-</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/marmotta/blob/b25a2549/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/config/KiWiQueryCacheConfiguration.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/config/KiWiQueryCacheConfiguration.java b/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/config/KiWiQueryCacheConfiguration.java
deleted file mode 100644
index 518e82e..0000000
--- a/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/config/KiWiQueryCacheConfiguration.java
+++ /dev/null
@@ -1,69 +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.kiwi.caching.config;
-
-/**
- * Configuration object for all query caching options that are configurable.
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class KiWiQueryCacheConfiguration {
-
-
-    /**
-     * Maximum size of results to cache. Results bigger than this value will not be cached.
-     */
-    private int maxEntrySize = 150;
-
-
-    /**
-     * Maximum number of entries to keep in the cache.
-     */
-    private int maxCacheSize = 100000;
-
-    public KiWiQueryCacheConfiguration() {
-    }
-
-    /**
-     * Maximum size of results to cache. Results bigger than this value will not be cached.
-     */
-    public int getMaxEntrySize() {
-        return maxEntrySize;
-    }
-
-    /**
-     * Maximum size of results to cache. Results bigger than this value will not be cached.
-     */
-    public void setMaxEntrySize(int maxEntrySize) {
-        this.maxEntrySize = maxEntrySize;
-    }
-
-    /**
-     * Maximum number of entries to keep in the cache.
-     */
-    public int getMaxCacheSize() {
-        return maxCacheSize;
-    }
-
-    /**
-     * Maximum number of entries to keep in the cache.
-     */
-    public void setMaxCacheSize(int maxCacheSize) {
-        this.maxCacheSize = maxCacheSize;
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/b25a2549/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/iteration/BufferingIteration.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/iteration/BufferingIteration.java b/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/iteration/BufferingIteration.java
deleted file mode 100644
index a0d02ff..0000000
--- a/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/iteration/BufferingIteration.java
+++ /dev/null
@@ -1,118 +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.kiwi.caching.iteration;
-
-import info.aduna.iteration.CloseableIteration;
-import info.aduna.iteration.CloseableIterationBase;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * An iterator that buffers iteration results up to a configurable limit.
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class BufferingIteration<E,X extends Exception> extends CloseableIterationBase<E,X> implements CloseableIteration<E,X> {
-
-    private int limit = 150;
-
-    private List<E> buffer;
-
-    private CloseableIteration<? extends E,X> wrapped;
-
-    public BufferingIteration(int limit, CloseableIteration<? extends E, X> wrapped) {
-        this.limit = limit;
-
-        this.wrapped = wrapped;
-        this.buffer  = new ArrayList<>(limit);
-    }
-
-    /**
-     * Returns <tt>true</tt> if the iteration has more elements. (In other
-     * words, returns <tt>true</tt> if {@link #next} would return an element
-     * rather than throwing a <tt>NoSuchElementException</tt>.)
-     *
-     * @return <tt>true</tt> if the iteration has more elements.
-     * @throws X
-     */
-    @Override
-    public boolean hasNext() throws X {
-        return wrapped.hasNext();
-    }
-
-    /**
-     * Returns the next element in the iteration.
-     *
-     * @return the next element in the iteration.
-     */
-    @Override
-    public E next() throws X {
-        E n = wrapped.next();
-
-        if(buffer != null && buffer.size() < limit) {
-            buffer.add(n);
-        } else {
-            buffer = null;
-        }
-
-        return n;
-    }
-
-    /**
-     * Removes from the underlying collection the last element returned by the
-     * iteration (optional operation). This method can be called only once per
-     * call to next.
-     *
-     * @throws UnsupportedOperationException if the remove operation is not supported by this Iteration.
-     * @throws IllegalStateException         If the Iteration has been closed, or if <tt>next()</tt> has not
-     *                                       yet been called, or <tt>remove()</tt> has already been called
-     *                                       after the last call to <tt>next()</tt>.
-     */
-    @Override
-    public void remove() throws X {
-        wrapped.remove();
-        buffer.remove(buffer.size() - 1);
-    }
-
-    /**
-     * Called by {@link #close} when it is called for the first time. This method
-     * is only called once on each iteration. By default, this method does
-     * nothing.
-     *
-     * @throws X
-     */
-    @Override
-    protected void handleClose() throws X {
-
-        super.handleClose();
-    }
-
-    /**
-     * Return the buffer contents (or null if the buffer has reached its limit)
-     *
-     * @return
-     */
-    public List<E> getBuffer() {
-        return buffer;
-    }
-
-    public int getLimit() {
-        return limit;
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/b25a2549/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/iteration/CachingIteration.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/iteration/CachingIteration.java b/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/iteration/CachingIteration.java
deleted file mode 100644
index 255ac00..0000000
--- a/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/iteration/CachingIteration.java
+++ /dev/null
@@ -1,136 +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.kiwi.caching.iteration;
-
-import info.aduna.iteration.CloseableIteration;
-import info.aduna.iteration.CloseableIterationBase;
-import info.aduna.iteration.CloseableIteratorIteration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
-/**
- * Add file description here!
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class CachingIteration<E,X extends Exception> extends CloseableIterationBase<E,X> implements CloseableIteration<E,X> {
-
-    private static Logger log = LoggerFactory.getLogger(CachingIteration.class);
-
-    private CloseableIteration<E,X> wrapped;
-
-    private CacheFunction<E> cacheFunction;
-
-    public CachingIteration(CacheFunction<E> cacheFunction,BufferingIterationProducer<E, X> producer) throws X {
-
-        this.cacheFunction = cacheFunction;
-
-        List<E> cached = cacheFunction.getResult();
-        if(cached != null) {
-            log.debug("cache hit, using iterator over cached result (size={})!", cached.size());
-            this.wrapped = new CloseableIteratorIteration<>(cached.iterator());
-        } else {
-            log.debug("cache miss, querying backend!");
-            this.wrapped = producer.getIteration();
-        }
-    }
-
-    /**
-     * Returns <tt>true</tt> if the iteration has more elements. (In other
-     * words, returns <tt>true</tt> if {@link #next} would return an element
-     * rather than throwing a <tt>NoSuchElementException</tt>.)
-     *
-     * @return <tt>true</tt> if the iteration has more elements.
-     * @throws X
-     */
-    @Override
-    public boolean hasNext() throws X {
-        return wrapped.hasNext();
-    }
-
-    /**
-     * Returns the next element in the iteration.
-     *
-     * @return the next element in the iteration.
-     */
-    @Override
-    public E next() throws X {
-        return wrapped.next();
-    }
-
-    /**
-     * Removes from the underlying collection the last element returned by the
-     * iteration (optional operation). This method can be called only once per
-     * call to next.
-     *
-     * @throws UnsupportedOperationException if the remove operation is not supported by this Iteration.
-     * @throws IllegalStateException         If the Iteration has been closed, or if <tt>next()</tt> has not
-     *                                       yet been called, or <tt>remove()</tt> has already been called
-     *                                       after the last call to <tt>next()</tt>.
-     */
-    @Override
-    public void remove() throws X {
-        wrapped.remove();
-    }
-
-    /**
-     * Called by {@link #close} when it is called for the first time. This method
-     * is only called once on each iteration. By default, this method does
-     * nothing.
-     *
-     * @throws X
-     */
-    @Override
-    protected void handleClose() throws X {
-        if(wrapped instanceof BufferingIteration && ((BufferingIteration) wrapped).getBuffer() != null) {
-            cacheFunction.cacheResult(((BufferingIteration) wrapped).getBuffer());
-        }
-
-        super.handleClose();
-    }
-
-
-    public static interface BufferingIterationProducer<E,X extends Exception> {
-
-        /**
-         * This method should lazily create the iteration wrapped by this caching iteration.
-         * @return
-         */
-        public BufferingIteration<E,X> getIteration() throws X;
-
-    }
-
-
-    public static interface CacheFunction<E> {
-
-        /**
-         * Return the cached result for this iteration (or null in case there is no cached result)
-         */
-        public List<E> getResult();
-
-        /**
-         * Cache the result of this iteration.
-         *
-         * @param buffer
-         */
-        public void cacheResult(List<E> buffer);
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/b25a2549/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/sail/KiWiCachingSail.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/sail/KiWiCachingSail.java b/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/sail/KiWiCachingSail.java
deleted file mode 100644
index fbc7289..0000000
--- a/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/sail/KiWiCachingSail.java
+++ /dev/null
@@ -1,164 +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.kiwi.caching.sail;
-
-import org.apache.marmotta.kiwi.caching.config.KiWiQueryCacheConfiguration;
-import org.apache.marmotta.kiwi.caching.transaction.GeronimoTransactionManagerLookup;
-import org.apache.marmotta.kiwi.sail.KiWiStore;
-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.cache.VersioningScheme;
-import org.infinispan.context.Flag;
-import org.infinispan.distribution.ch.SyncConsistentHashFactory;
-import org.infinispan.manager.EmbeddedCacheManager;
-import org.infinispan.transaction.TransactionMode;
-import org.infinispan.util.concurrent.IsolationLevel;
-import org.openrdf.sail.NotifyingSail;
-import org.openrdf.sail.NotifyingSailConnection;
-import org.openrdf.sail.Sail;
-import org.openrdf.sail.SailException;
-import org.openrdf.sail.helpers.NotifyingSailWrapper;
-import org.openrdf.sail.helpers.SailWrapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * A sail wrapper for KiWi stores that introduces transparent query caching using Infinispan distributed caches.
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class KiWiCachingSail extends NotifyingSailWrapper {
-
-    public static final String QUERY_CACHE = "query-cache";
-
-    private static Logger log = LoggerFactory.getLogger(KiWiCachingSail.class);
-
-    private KiWiStore parent;
-
-
-    private EmbeddedCacheManager cacheManager;
-
-    private KiWiQueryCacheConfiguration configuration;
-
-    /**
-     * Creates a new SailWrapper that wraps the supplied Sail.
-     *
-     * @param baseSail
-     */
-    public KiWiCachingSail(NotifyingSail baseSail, KiWiQueryCacheConfiguration configuration) {
-        super(baseSail);
-
-        this.parent = getRootSail(baseSail);
-        this.configuration = configuration;
-    }
-
-
-    @Override
-    public void initialize() throws SailException {
-        super.initialize();
-
-        this.cacheManager = parent.getPersistence().getCacheManager().getCacheManager();
-    }
-
-    @Override
-    public NotifyingSailConnection getConnection() throws SailException {
-        return new KiWiCachingSailConnection(super.getConnection(), getQueryCache(), configuration.getMaxEntrySize());
-    }
-
-
-
-    /**
-     * Return the query key -> query result cache from the cache manager. This cache is used for speeding up the
-     * listing of query results.
-     *
-     * @return
-     */
-    private Cache getQueryCache() {
-        if(!cacheManager.cacheExists(QUERY_CACHE)) {
-            if(parent.getPersistence().getConfiguration().isClustered()) {
-                Configuration tripleConfiguration = new ConfigurationBuilder()
-                        .clustering()
-                            .cacheMode(CacheMode.DIST_SYNC)
-                            .sync()
-                                .replTimeout(60, TimeUnit.SECONDS)
-                            .hash()
-                                .numOwners(2)
-                                .numSegments(40)
-                                .consistentHashFactory(new SyncConsistentHashFactory())
-                        .transaction()
-                            .transactionMode(TransactionMode.TRANSACTIONAL)
-                            .transactionManagerLookup(new GeronimoTransactionManagerLookup())
-                            .cacheStopTimeout(1, TimeUnit.SECONDS)
-                        .locking()
-                            .isolationLevel(IsolationLevel.READ_COMMITTED)
-                            .concurrencyLevel(5)
-                        .versioning()
-                            .enabled(true)
-                            .scheme(VersioningScheme.SIMPLE)
-                        .eviction()
-                            .maxEntries(configuration.getMaxCacheSize())
-                        .expiration()
-                            .lifespan(60, TimeUnit.MINUTES)
-                            .maxIdle(30, TimeUnit.MINUTES)
-                        .build();
-                cacheManager.defineConfiguration(QUERY_CACHE, tripleConfiguration);
-            } else {
-                Configuration tripleConfiguration = new ConfigurationBuilder().read(cacheManager.getDefaultCacheConfiguration())
-                        .transaction()
-                            .transactionMode(TransactionMode.TRANSACTIONAL)
-                            .transactionManagerLookup(new GeronimoTransactionManagerLookup())
-                            .cacheStopTimeout(1, TimeUnit.SECONDS)
-                        .locking()
-                            .isolationLevel(IsolationLevel.READ_COMMITTED)
-                            .concurrencyLevel(5)
-                        .versioning()
-                            .enabled(true)
-                            .scheme(VersioningScheme.SIMPLE)
-                        .eviction()
-                            .maxEntries(configuration.getMaxCacheSize())
-                        .expiration()
-                            .lifespan(60, TimeUnit.MINUTES)
-                            .maxIdle(30, TimeUnit.MINUTES)
-                        .build();
-                cacheManager.defineConfiguration(QUERY_CACHE, tripleConfiguration);
-            }
-        }
-        return cacheManager.getCache(QUERY_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP);
-    }
-
-
-    /**
-     * Get the root sail in the wrapped sail stack
-     * @param sail
-     * @return
-     */
-    private KiWiStore getRootSail(Sail sail) {
-        if(sail instanceof KiWiStore) {
-            return (KiWiStore) sail;
-        } else if(sail instanceof SailWrapper) {
-            return getRootSail(((SailWrapper) sail).getBaseSail());
-        } else {
-            throw new IllegalArgumentException("root sail is not a KiWiStore or could not be found");
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/b25a2549/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/sail/KiWiCachingSailConnection.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/sail/KiWiCachingSailConnection.java b/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/sail/KiWiCachingSailConnection.java
deleted file mode 100644
index d1dc908..0000000
--- a/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/sail/KiWiCachingSailConnection.java
+++ /dev/null
@@ -1,503 +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.kiwi.caching.sail;
-
-import com.google.common.base.Function;
-import com.google.common.collect.Lists;
-import info.aduna.iteration.CloseableIteration;
-import info.aduna.iteration.Iteration;
-import info.aduna.iteration.UnionIteration;
-import org.apache.geronimo.transaction.manager.TransactionImpl;
-import org.apache.marmotta.commons.sesame.tripletable.IntArray;
-import org.apache.marmotta.kiwi.caching.iteration.BufferingIteration;
-import org.apache.marmotta.kiwi.caching.iteration.CachingIteration;
-import org.apache.marmotta.kiwi.model.rdf.KiWiTriple;
-import org.apache.marmotta.kiwi.persistence.KiWiConnection;
-import org.apache.marmotta.kiwi.sail.KiWiSailConnection;
-import org.infinispan.Cache;
-import org.openrdf.model.Resource;
-import org.openrdf.model.Statement;
-import org.openrdf.model.URI;
-import org.openrdf.model.Value;
-import org.openrdf.model.impl.URIImpl;
-import org.openrdf.sail.NotifyingSailConnection;
-import org.openrdf.sail.SailConnection;
-import org.openrdf.sail.SailConnectionListener;
-import org.openrdf.sail.SailException;
-import org.openrdf.sail.helpers.NotifyingSailConnectionWrapper;
-import org.openrdf.sail.helpers.SailConnectionWrapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.transaction.*;
-import java.nio.IntBuffer;
-import java.sql.SQLException;
-import java.util.*;
-
-/**
- * A sail connection with Infinispan caching support. It will dynamically cache getStatements results up to a certain
- * result size and invalidate the cache on updates.
- *
- * <p/>
- * Since Infinispan uses JTA for transaction management, we need to align Sesame transactions with JTA. JTA transactions
- * are associated per-thread, while Sesame transactions are per-connection. This makes this combination a bit tricky:
- * every time a relevant method on the sesame connection is called we need to suspend the existing thread transaction
- * and resume the connection that is associated with the connection.
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class KiWiCachingSailConnection extends NotifyingSailConnectionWrapper implements SailConnectionListener {
-
-    private static Logger log = LoggerFactory.getLogger(KiWiCachingSailConnection.class);
-
-    private Cache<Long,long[]> queryCache;
-
-    // a dummy default context to work around the double meaning of the null value
-    private final static URI defaultContext = new URIImpl("http://marmotta.apache.org/contexts/default");
-
-    private int limit = 150;
-
-    private Transaction tx;
-
-    private long connectionId;
-
-    private static long connectionIdCounter = 0;
-
-    private KiWiConnection kiWiConnection;
-
-    public KiWiCachingSailConnection(NotifyingSailConnection wrappedCon, Cache<Long, long[]> queryCache, int limit) {
-        super(wrappedCon);
-
-        this.queryCache = queryCache;
-        this.limit      = limit;
-        this.kiWiConnection = getKiWiConnection(wrappedCon);
-
-        this.addConnectionListener(this);
-
-        connectionId = ++connectionIdCounter;
-
-    }
-
-
-    @Override
-    public CloseableIteration<? extends Statement, SailException> getStatements(final Resource subj, final URI pred, final Value obj, final boolean includeInferred, final Resource... contexts) throws SailException {
-        if(tx != null) {
-            log.debug("CONN({}) LIST: listing statements for transaction: {}", connectionId, ((TransactionImpl) tx).getTransactionKey());
-        } else {
-            log.debug("CONN({}) LIST: listing statements (no transaction)", connectionId);
-        }
-        List<Iteration<? extends Statement, SailException>> cResults = new ArrayList<>(contexts.length + 1);
-        for(final Resource context : resolveContexts(contexts)) {
-            cResults.add(new CachingIteration<>(
-                    new CachingIteration.CacheFunction<Statement>() {
-                        @Override
-                        public List<Statement> getResult() {
-                            return listTriples(subj,pred,obj,context, includeInferred);
-                        }
-
-                        @Override
-                        public void cacheResult(List<Statement> buffer) {
-                            log.debug("CONN({}) CACHE: caching result for query ({},{},{},{},{}): {}", connectionId, subj, pred, obj, context, includeInferred, buffer);
-                            cacheTriples(subj, pred, obj, context, includeInferred, buffer);
-                        }
-                    },
-                    new CachingIteration.BufferingIterationProducer<Statement, SailException>() {
-                        @Override
-                        public BufferingIteration<Statement, SailException> getIteration() throws SailException {
-                            return new BufferingIteration<>(limit, KiWiCachingSailConnection.super.getStatements(subj, pred, obj, includeInferred, contexts));
-                        }
-                    }
-            ));
-        }
-
-        return new UnionIteration<Statement, SailException>(cResults);
-
-    }
-
-
-    /**
-     * Notifies the listener that a statement has been added in a transaction
-     * that it has registered itself with.
-     *
-     * @param st The statement that was added.
-     */
-    @Override
-    public void statementAdded(Statement st) {
-        resumeTransaction();
-        log.debug("CONN({}) ADD: updating cache for statement {} (transaction: {})", connectionId, st, ((TransactionImpl) tx).getTransactionKey());
-        if(st.getContext() == null) {
-            tripleUpdated(st.getSubject(), st.getPredicate(), st.getObject(), Collections.singleton((Resource)defaultContext));
-        } else {
-            tripleUpdated(st.getSubject(), st.getPredicate(), st.getObject(), Collections.singleton(st.getContext()));
-        }
-    }
-
-    /**
-     * Notifies the listener that a statement has been removed in a transaction
-     * that it has registered itself with.
-     *
-     * @param st The statement that was removed.
-     */
-    @Override
-    public void statementRemoved(Statement st) {
-        log.debug("CONN({}) DEL: updating cache for statement {} (transaction: {})", connectionId, st, ((TransactionImpl)tx).getTransactionKey());
-        resumeTransaction();
-        if(st.getContext() == null) {
-            tripleUpdated(st.getSubject(), st.getPredicate(), st.getObject(), Collections.singleton((Resource)defaultContext));
-        } else {
-            tripleUpdated(st.getSubject(), st.getPredicate(), st.getObject(), Collections.singleton(st.getContext()));
-        }
-    }
-
-    @Override
-    public void begin() throws SailException {
-        super.begin();
-
-        resumeTransaction();
-    }
-
-    @Override
-    public void commit() throws SailException {
-        TransactionManager txmgr = queryCache.getAdvancedCache().getTransactionManager();
-        try {
-            resumeTransaction();
-            log.debug("CONN({}) COMMIT: transaction: {}", connectionId, ((TransactionImpl) tx).getTransactionKey());
-            txmgr.commit();
-            closeTransaction();
-        } catch (RollbackException | HeuristicMixedException | HeuristicRollbackException | SystemException e) {
-            log.error("error committing cache transaction: ", e);
-        }
-
-        super.commit();
-    }
-
-    @Override
-    public void rollback() throws SailException {
-        TransactionManager txmgr = queryCache.getAdvancedCache().getTransactionManager();
-        try {
-            resumeTransaction();
-            txmgr.rollback();
-            closeTransaction();
-        } catch (SystemException e) {
-            log.error("error rolling back cache transaction: ",e);
-        }
-
-        super.rollback();
-    }
-
-    @Override
-    public void close() throws SailException {
-        closeTransaction();
-
-        super.close();
-    }
-
-    private void resumeTransaction() {
-        TransactionManager txmgr = queryCache.getAdvancedCache().getTransactionManager();
-        try {
-            // cases:
-            // 1. there is a transaction in this connection, the transaction is active, and associated with the current
-            //    thread -> nothing to do
-            // 2. there is a transaction in this connection, the transaction is active, bit another transactionis 
-            //    associated with the current thread -> suspend thread transaction, resume connection transaction
-            // 3. there is no transaction in this connection, or the transaction in this connection is invalid
-            //    -> create and start new transaction
-            if(tx != null && tx.getStatus() == Status.STATUS_ACTIVE && txmgr.getTransaction() == tx) {
-                log.debug("CONN({}) RESUME: using active transaction: {}, status {}", connectionId, ((TransactionImpl)tx).getTransactionKey(), tx.getStatus());
-            } else if(tx != null && tx.getStatus() == Status.STATUS_ACTIVE && txmgr.getTransaction() != tx) {
-                txmgr.suspend();
-                txmgr.resume(tx);
-
-                log.debug("CONN({}) RESUME: resumed transaction: {}, status {}", connectionId, ((TransactionImpl)tx).getTransactionKey(), tx.getStatus());
-            } else {
-                if(txmgr.getTransaction() != null) {
-                    Transaction old = txmgr.suspend();
-                    log.debug("CONN({}) BEGIN: suspended transaction not belonging to this connection: {}", connectionId, ((TransactionImpl)old).getTransactionKey());
-                }
-                txmgr.begin();
-                tx = txmgr.getTransaction();
-
-                log.debug("CONN({}) BEGIN: created and started new transaction: {}", connectionId, ((TransactionImpl)tx).getTransactionKey());
-
-            }
-
-
-        } catch (NotSupportedException | SystemException | InvalidTransactionException e) {
-            log.error("error resuming transaction");
-        }
-    }
-
-    private void closeTransaction() {
-        TransactionManager txmgr = queryCache.getAdvancedCache().getTransactionManager();
-        try {
-            if(tx != null && txmgr.getTransaction() == tx) {
-                log.debug("CONN({}) CLOSE: closing transaction: {}", connectionId, ((TransactionImpl)tx).getTransactionKey());
-                if(tx.getStatus() == Status.STATUS_ACTIVE) {
-                    tx.commit();
-                }
-                txmgr.suspend();
-                tx = null;
-            }
-        } catch (RollbackException | HeuristicMixedException | HeuristicRollbackException | SystemException e) {
-            log.error("error while closing transaction", e);
-        }
-    }
-
-    private List<Resource> resolveContexts(Resource... contexts) {
-        if(contexts.length == 0) {
-            return Collections.singletonList((Resource) defaultContext);
-        } else  {
-            return Lists.newArrayList(contexts);
-        }
-    }
-
-    /**
-     * Look up a triple query in the query cache. Returns the result set if the query is found in the cache, returns
-     * null if the query is not found.
-     *
-     * @param subject  the subject of the triples to list or null for wildcard
-     * @param property the property of the triples to list or null for wildcard
-     * @param object   the object of the triples to list or null for wildcard
-     * @param context  the context/knowledge space of the triples to list or null for all spaces
-     * @param inferred if true, inferred triples are included in the result; if false not
-     * @return the result set if the query is found in the cache, returns null if the query is not found
-     */
-    @SuppressWarnings("unchecked")
-    private List<Statement> listTriples(Resource subject, URI property, Value object, Resource context, boolean inferred) {
-        boolean implicitTx = tx == null;
-        resumeTransaction();
-
-        IntArray key = createCacheKey(subject,property,object,context,inferred);
-        try {
-            long[] ids = queryCache.get(key.longHashCode());
-            if(ids == null) {
-                return null;
-            } else {
-                ArrayList<Statement> statements = new ArrayList<>(ids.length);
-                for(long id : ids) {
-                    try {
-                        statements.add(kiWiConnection.loadTripleById(id));
-                    } catch (SQLException e) {
-                        log.warn("could not load triple from database: {}",id);
-                    }
-                }
-                return statements;
-            }
-        } finally {
-            if(implicitTx) {
-                closeTransaction();
-            }
-        }
-    }
-
-
-    /**
-     * Cache the result of a triple query in the query cache.
-     *
-     * @param subject  the subject of the triples to list or null for wildcard
-     * @param property the property of the triples to list or null for wildcard
-     * @param object   the object of the triples to list or null for wildcard
-     * @param context  the context/knowledge space of the triples to list or null for all spaces
-     * @param inferred if true, inferred triples are included in the result; if false not
-     * @param result   the result of the triple query to cache
-     */
-    private void cacheTriples(final Resource subject, final URI property, final Value object, final Resource context, boolean inferred, List<Statement> result) {
-        boolean implicitTx = tx == null;
-
-        resumeTransaction();
-
-        try {
-            // cache the query result
-            IntArray key = createCacheKey(subject,property,object,context,inferred);
-            long[] data = new long[result.size()];
-            for(int i=0; i<result.size(); i++) {
-                Statement stmt = result.get(i);
-                if(stmt instanceof KiWiTriple) {
-                    data[i] = ((KiWiTriple) stmt).getId();
-                }
-            }
-            queryCache.put(key.longHashCode(), data);
-
-            // cache the nodes of the triples and the triples themselves
-            Set<Value> nodes = new HashSet<Value>();
-            for(Statement stmt : result) {
-                if(stmt instanceof KiWiTriple) {
-                    KiWiTriple triple = (KiWiTriple)stmt;
-                    Collections.addAll(nodes, new Value[]{triple.getSubject(), triple.getObject(), triple.getPredicate(), triple.getContext()});
-                    queryCache.put(createCacheKey(triple.getSubject(), triple.getPredicate(), triple.getObject(), triple.getContext(), triple.isInferred()).longHashCode(), new long[] {triple.getId()});
-                }
-            }
-
-            // special optimisation: when only the subject (and optionally context) is given, we also fill the caches for
-            // all property values
-            if(subject != null && property == null && object == null) {
-                HashMap<URI,ArrayList<Long>> properties = new HashMap<>();
-                for(Statement triple : result) {
-                    ArrayList<Long> values = properties.get(triple.getPredicate());
-                    if(values == null) {
-                        values = new ArrayList<>();
-                        properties.put(triple.getPredicate(),values);
-                    }
-                    if(triple instanceof KiWiTriple) {
-                        values.add(((KiWiTriple) triple).getId());
-                    }
-                }
-                for(Map.Entry<URI,ArrayList<Long>> entry : properties.entrySet()) {
-                    IntArray key2 = createCacheKey(subject,entry.getKey(),null,context,inferred);
-                    long[] dvalues = new long[entry.getValue().size()];
-                    for(int i=0; i<entry.getValue().size(); i++) {
-                        dvalues[i] = entry.getValue().get(i);
-                    }
-                    queryCache.put(key2.longHashCode(), dvalues);
-                }
-            }
-
-        } finally {
-            if(implicitTx) {
-                closeTransaction();
-            }
-        }
-
-    }
-
-
-
-
-    /**
-     * Clear all contents of the query cache.
-     */
-    private void clearAll() {
-        queryCache.clear();
-    }
-
-
-    /**
-     * Notify the cache that the triple passed as argument has been updated and that all cache entries affected by
-     * the triple update need to be cleared.
-     *
-     */
-    private void tripleUpdated(Resource subject, URI predicate, Value object, Iterable<Resource> contexts) {
-        queryCache.remove(createCacheKey(null, null, null, null, false).longHashCode());
-        queryCache.remove(createCacheKey(null,null,null,null,true).longHashCode());
-
-        queryCache.remove(createCacheKey(null,null,null,defaultContext,false).longHashCode());
-        queryCache.remove(createCacheKey(null,null,null,defaultContext,true).longHashCode());
-
-
-        // remove all possible combinations of this triple as they may appear in the cache
-        queryCache.remove(createCacheKey(subject,null,null,null,false).longHashCode());
-        queryCache.remove(createCacheKey(subject,null,null,null,true).longHashCode());
-        queryCache.remove(createCacheKey(null,predicate,null,null,false).longHashCode());
-        queryCache.remove(createCacheKey(null,predicate,null,null,true).longHashCode());
-        queryCache.remove(createCacheKey(null,null,object,null,false).longHashCode());
-        queryCache.remove(createCacheKey(null,null,object,null,true).longHashCode());
-
-        queryCache.remove(createCacheKey(subject,predicate,null,null,false).longHashCode());
-        queryCache.remove(createCacheKey(subject,predicate,null,null,true).longHashCode());
-        queryCache.remove(createCacheKey(subject,null,object,null,false).longHashCode());
-        queryCache.remove(createCacheKey(subject,null,object,null,true).longHashCode());
-        queryCache.remove(createCacheKey(null,predicate,object,null,false).longHashCode());
-        queryCache.remove(createCacheKey(null,predicate,object,null,true).longHashCode());
-
-
-        queryCache.remove(createCacheKey(subject,predicate,object,null,false).longHashCode());
-        queryCache.remove(createCacheKey(subject,predicate,object,null,true).longHashCode());
-
-        for(Resource context : contexts) {
-            queryCache.remove(createCacheKey(null,null,null,context,false).longHashCode());
-            queryCache.remove(createCacheKey(null,null,null,context,true).longHashCode());
-            queryCache.remove(createCacheKey(subject,null,null,context,false).longHashCode());
-            queryCache.remove(createCacheKey(subject,null,null,context,true).longHashCode());
-            queryCache.remove(createCacheKey(null,predicate,null,context,false).longHashCode());
-            queryCache.remove(createCacheKey(null,predicate,null,context,true).longHashCode());
-            queryCache.remove(createCacheKey(null,null,object,context,false).longHashCode());
-            queryCache.remove(createCacheKey(null,null,object,context,true).longHashCode());
-
-            queryCache.remove(createCacheKey(subject,predicate,null,context,false).longHashCode());
-            queryCache.remove(createCacheKey(subject,predicate,null,context,true).longHashCode());
-            queryCache.remove(createCacheKey(subject,null,object,context,false).longHashCode());
-            queryCache.remove(createCacheKey(subject,null,object,context,true).longHashCode());
-            queryCache.remove(createCacheKey(null,predicate,object,context,false).longHashCode());
-            queryCache.remove(createCacheKey(null,predicate,object,context,true).longHashCode());
-
-            queryCache.remove(createCacheKey(subject,predicate,object,context,false).longHashCode());
-            queryCache.remove(createCacheKey(subject,predicate,object,context,true).longHashCode());
-        }
-    }
-
-
-    private static IntArray createCacheKey(Resource subject, URI property, Value object, Resource context, boolean inferred){
-
-        // the cache key is generated by appending the bytes of the hashcodes of subject, property, object, context and inferred and
-        // storing them as a BigInteger; generating the cache key should thus be very efficient
-
-        int s = subject != null ? subject.hashCode() : Integer.MIN_VALUE;
-        int p = property != null ? property.hashCode() : Integer.MIN_VALUE;
-        int o = object != null ? object.hashCode() : Integer.MIN_VALUE;
-        int c = context != null ? context.hashCode() : Integer.MIN_VALUE;
-
-        IntBuffer bb = IntBuffer.allocate(5);
-        bb.put(s);
-        bb.put(p);
-        bb.put(o);
-        bb.put(c);
-        bb.put( (byte) (inferred ? 1 : 0) );
-
-        return new IntArray(bb.array());
-
-    }
-
-
-    /**
-     * Get the root sail in the wrapped sail stack
-     * @param sail
-     * @return
-     */
-    private KiWiConnection getKiWiConnection(SailConnection sail) {
-        if(sail instanceof KiWiSailConnection) {
-            return ((KiWiSailConnection) sail).getDatabaseConnection();
-        } else if(sail instanceof SailConnectionWrapper) {
-            return getKiWiConnection(((SailConnectionWrapper) sail).getWrappedConnection());
-        } else {
-            throw new IllegalArgumentException("root sail connection is not a KiWiSailConnection or could not be found");
-        }
-    }
-
-    private class IDTripleLoader implements Function<Long,Statement> {
-        @Override
-        public Statement apply(Long input) {
-            try {
-                return kiWiConnection.loadTripleById(input);
-            } catch (SQLException e) {
-                log.error("could not load triple with ID {}", input);
-                throw new RuntimeException(e);
-            }
-        }
-    }
-
-    private class IDTripleExtractor implements Function<Statement,Long> {
-        @Override
-        public Long apply(Statement input) {
-            if(input instanceof KiWiTriple) {
-                return ((KiWiTriple) input).getId();
-            } else {
-                return -1L;
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/b25a2549/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/transaction/GeronimoTransactionManagerLookup.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/transaction/GeronimoTransactionManagerLookup.java b/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/transaction/GeronimoTransactionManagerLookup.java
deleted file mode 100644
index ad35473..0000000
--- a/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/transaction/GeronimoTransactionManagerLookup.java
+++ /dev/null
@@ -1,46 +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.kiwi.caching.transaction;
-
-import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
-import org.infinispan.transaction.lookup.TransactionManagerLookup;
-
-import javax.transaction.TransactionManager;
-
-/**
- * Add file description here!
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class GeronimoTransactionManagerLookup implements TransactionManagerLookup {
-
-    private TransactionManager manager;
-
-    /**
-     * Returns a new TransactionManager.
-     *
-     * @throws Exception if lookup failed
-     */
-    @Override
-    public TransactionManager getTransactionManager() throws Exception {
-        if(manager == null) {
-            manager = new GeronimoTransactionManager();
-        }
-        return manager;
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/b25a2549/libraries/kiwi/kiwi-caching/src/test/java/org/apache/marmotta/kiwi/caching/test/KiWiCachingRepositoryConnectionTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching/src/test/java/org/apache/marmotta/kiwi/caching/test/KiWiCachingRepositoryConnectionTest.java b/libraries/kiwi/kiwi-caching/src/test/java/org/apache/marmotta/kiwi/caching/test/KiWiCachingRepositoryConnectionTest.java
deleted file mode 100644
index bce1eb4..0000000
--- a/libraries/kiwi/kiwi-caching/src/test/java/org/apache/marmotta/kiwi/caching/test/KiWiCachingRepositoryConnectionTest.java
+++ /dev/null
@@ -1,64 +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.kiwi.caching.test;
-
-import org.apache.marmotta.kiwi.caching.config.KiWiQueryCacheConfiguration;
-import org.apache.marmotta.kiwi.caching.sail.KiWiCachingSail;
-import org.apache.marmotta.kiwi.config.KiWiConfiguration;
-import org.apache.marmotta.kiwi.sail.KiWiStore;
-import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
-import org.junit.Ignore;
-import org.junit.runner.RunWith;
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryConnectionTest;
-import org.openrdf.repository.sail.SailRepository;
-
-/**
- * Run the {@link RepositoryConnectionTest}s.
- * @author Jakob Frank <jakob@apache.org>
- *
- */
-@RunWith(KiWiDatabaseRunner.class)
-public class KiWiCachingRepositoryConnectionTest extends RepositoryConnectionTest {
-
-    private final KiWiConfiguration config;
-
-    public KiWiCachingRepositoryConnectionTest(KiWiConfiguration config) {
-        this.config = config;
-    }
-    
-    /* (non-Javadoc)
-     * @see org.openrdf.repository.RepositoryConnectionTest#createRepository()
-     */
-    @Override
-    protected Repository createRepository() throws Exception {
-        config.setDefaultContext(null);
-        KiWiStore store = new KiWiStore(config);
-        store.setDropTablesOnShutdown(true);
-
-        KiWiCachingSail cache = new KiWiCachingSail(store, new KiWiQueryCacheConfiguration());
-        return new SailRepository(cache);
-    }
-
-
-    @Override
-    @Ignore
-    public void testGetStatementsInMultipleContexts() throws Exception {
-        // this test is not working, because the cache can return duplicates
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/b25a2549/libraries/kiwi/kiwi-caching/src/test/java/org/apache/marmotta/kiwi/caching/test/KiWiCachingRepositoryTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-caching/src/test/java/org/apache/marmotta/kiwi/caching/test/KiWiCachingRepositoryTest.java b/libraries/kiwi/kiwi-caching/src/test/java/org/apache/marmotta/kiwi/caching/test/KiWiCachingRepositoryTest.java
deleted file mode 100644
index 9b13279..0000000
--- a/libraries/kiwi/kiwi-caching/src/test/java/org/apache/marmotta/kiwi/caching/test/KiWiCachingRepositoryTest.java
+++ /dev/null
@@ -1,61 +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.kiwi.caching.test;
-
-import org.apache.marmotta.kiwi.caching.config.KiWiQueryCacheConfiguration;
-import org.apache.marmotta.kiwi.caching.sail.KiWiCachingSail;
-import org.apache.marmotta.kiwi.config.KiWiConfiguration;
-import org.apache.marmotta.kiwi.sail.KiWiStore;
-import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
-import org.junit.runner.RunWith;
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryTest;
-import org.openrdf.repository.sail.SailRepository;
-
-/**
- * Run the {@link RepositoryTest}s.
- * @author Jakob Frank <jakob@apache.org>
- *
- */
-@RunWith(KiWiDatabaseRunner.class)
-public class KiWiCachingRepositoryTest extends RepositoryTest {
-
-    private final KiWiConfiguration config;
-
-    private KiWiStore store;
-
-    public KiWiCachingRepositoryTest(KiWiConfiguration config) {
-        this.config = config;
-    }
-
-    /* (non-Javadoc)
-     * @see org.openrdf.repository.RepositoryTest#createRepository()
-     */
-    @Override
-    protected Repository createRepository() throws Exception {
-        store = new KiWiStore(config);
-        KiWiCachingSail cache = new KiWiCachingSail(store, new KiWiQueryCacheConfiguration());
-        return new SailRepository(cache);
-    }
-
-    @Override
-    public void tearDown() throws Exception {
-        store.getPersistence().dropDatabase();
-        super.tearDown();
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/b25a2549/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/persistence/KiWiReasoningConnection.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/persistence/KiWiReasoningConnection.java b/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/persistence/KiWiReasoningConnection.java
index 67459e5..4688696 100644
--- a/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/persistence/KiWiReasoningConnection.java
+++ b/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/persistence/KiWiReasoningConnection.java
@@ -18,7 +18,7 @@
 package org.apache.marmotta.kiwi.reasoner.persistence;
 
 import info.aduna.iteration.*;
-import org.apache.marmotta.kiwi.caching.KiWiCacheManager;
+import org.apache.marmotta.kiwi.caching.CacheManager;
 import org.apache.marmotta.kiwi.model.rdf.KiWiNode;
 import org.apache.marmotta.kiwi.model.rdf.KiWiTriple;
 import org.apache.marmotta.kiwi.persistence.KiWiConnection;
@@ -30,7 +30,6 @@ import org.apache.marmotta.kiwi.reasoner.model.program.*;
 import org.apache.marmotta.kiwi.reasoner.model.query.QueryResult;
 import org.apache.marmotta.kiwi.reasoner.parser.KWRLProgramParser;
 import org.apache.marmotta.kiwi.reasoner.parser.ParseException;
-import org.infinispan.Cache;
 import org.openrdf.model.ValueFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -53,9 +52,9 @@ public class KiWiReasoningConnection extends KiWiConnection {
 
     private ValueFactory valueFactory;
 
-    private Cache<Long,Rule> ruleIdCache;
+    private Map<Long,Rule> ruleIdCache;
 
-    public KiWiReasoningConnection(KiWiPersistence persistence, KiWiDialect dialect, KiWiCacheManager cacheManager, ValueFactory valueFactory) throws SQLException {
+    public KiWiReasoningConnection(KiWiPersistence persistence, KiWiDialect dialect, CacheManager cacheManager, ValueFactory valueFactory) throws SQLException {
         super(persistence, dialect, cacheManager);
 
         this.valueFactory = valueFactory;

http://git-wip-us.apache.org/repos/asf/marmotta/blob/b25a2549/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/persistence/KiWiVersioningConnection.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/persistence/KiWiVersioningConnection.java b/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/persistence/KiWiVersioningConnection.java
index 844a0be..49716e9 100644
--- a/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/persistence/KiWiVersioningConnection.java
+++ b/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/persistence/KiWiVersioningConnection.java
@@ -21,7 +21,7 @@ import com.google.common.base.Preconditions;
 import info.aduna.iteration.CloseableIteration;
 import info.aduna.iteration.EmptyIteration;
 import info.aduna.iteration.ExceptionConvertingIteration;
-import org.apache.marmotta.kiwi.caching.KiWiCacheManager;
+import org.apache.marmotta.kiwi.caching.CacheManager;
 import org.apache.marmotta.kiwi.model.rdf.KiWiNode;
 import org.apache.marmotta.kiwi.model.rdf.KiWiResource;
 import org.apache.marmotta.kiwi.model.rdf.KiWiTriple;
@@ -53,7 +53,7 @@ public class KiWiVersioningConnection extends KiWiConnection {
 
     private static Logger log = LoggerFactory.getLogger(KiWiVersioningConnection.class);
 
-    public KiWiVersioningConnection(KiWiPersistence persistence, KiWiDialect dialect, KiWiCacheManager cacheManager) throws SQLException {
+    public KiWiVersioningConnection(KiWiPersistence persistence, KiWiDialect dialect, CacheManager cacheManager) throws SQLException {
         super(persistence, dialect, cacheManager);
     }
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/b25a2549/libraries/kiwi/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/kiwi/pom.xml b/libraries/kiwi/pom.xml
index c244567..f47b8de 100644
--- a/libraries/kiwi/pom.xml
+++ b/libraries/kiwi/pom.xml
@@ -117,7 +117,6 @@
         <module>kiwi-reasoner</module>
         <module>kiwi-sparql</module>
         <module>kiwi-loader</module>
-        <module>kiwi-caching</module>
     </modules>
 
 </project>


Mime
View raw message