You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2015/03/19 15:53:47 UTC

[3/3] clerezza git commit: CLEREZZA-961: using rdf-commons from clerezza-rdf-core repository

CLEREZZA-961: using rdf-commons from clerezza-rdf-core repository

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

Branch: refs/heads/rdf-commons
Commit: e5531d9645632eff5b0ee897828ae6b57e3fbf9f
Parents: 9ae0a1b
Author: Reto Gmuer <re...@apache.org>
Authored: Thu Mar 19 14:52:41 2015 +0000
Committer: Reto Gmuer <re...@apache.org>
Committed: Thu Mar 19 14:52:41 2015 +0000

----------------------------------------------------------------------
 rdf.core/pom.xml                                |   9 +-
 .../clerezza/rdf/core/LiteralFactory.java       |   2 +-
 .../access/ImmutableGraphServiceFactory.java    |   3 +-
 .../rdf/core/access/LockableMGraph.java         |  41 --
 .../rdf/core/access/LockableMGraphWrapper.java  | 274 --------------
 .../rdf/core/access/LockingIterator.java        |  73 ----
 .../rdf/core/access/MGraphServiceFactory.java   |   2 +-
 .../clerezza/rdf/core/access/SecuredGraph.java  |  25 +-
 .../clerezza/rdf/core/access/SecuredMGraph.java |  72 ----
 .../clerezza/rdf/core/access/TcManager.java     |  19 +-
 .../rdf/core/access/TcProviderMultiplexer.java  |  56 ++-
 .../rdf/core/access/debug/ReadLockDebug.java    |  85 -----
 .../debug/ReentrantReadWriteLockTracker.java    | 133 -------
 .../rdf/core/access/debug/WriteLockDebug.java   |  89 -----
 .../access/security/TcAccessController.java     |  22 +-
 .../clerezza/rdf/core/impl/AbstractGraph.java   | 251 ------------
 .../rdf/core/impl/AbstractImmutableGraph.java   | 112 ------
 .../clerezza/rdf/core/impl/AbstractMGraph.java  |  36 --
 .../rdf/core/impl/DelayedNotificator.java       | 112 ------
 .../rdf/core/impl/PlainLiteralImpl.java         | 103 -----
 .../clerezza/rdf/core/impl/SimpleGraph.java     | 220 -----------
 .../rdf/core/impl/SimpleImmutableGraph.java     |  78 ----
 .../rdf/core/impl/SimpleLiteralFactory.java     | 312 ---------------
 .../clerezza/rdf/core/impl/SimpleMGraph.java    |  55 ---
 .../clerezza/rdf/core/impl/TripleImpl.java      | 100 -----
 .../rdf/core/impl/TypedLiteralImpl.java         |  97 -----
 .../rdf/core/impl/WriteBlockedGraph.java        |  24 +-
 .../rdf/core/impl/WriteBlockedMGraph.java       |  52 ---
 .../core/impl/graphmatching/GraphMatcher.java   | 143 -------
 .../GraphNotIsomorphicException.java            |  28 --
 .../graphmatching/GroupMappingIterator.java     | 102 -----
 .../core/impl/graphmatching/HashMatching.java   | 268 -------------
 .../impl/graphmatching/MappingIterator.java     |  76 ----
 .../impl/graphmatching/PermutationIterator.java | 107 ------
 .../rdf/core/impl/graphmatching/Utils.java      |  82 ----
 .../graphmatching/collections/IntHashMap.java   | 377 -------------------
 .../graphmatching/collections/IntHashSet.java   |  62 ---
 .../graphmatching/collections/IntIterator.java  |  30 --
 .../impl/graphmatching/collections/IntSet.java  |  35 --
 .../core/impl/util/PrivilegedGraphWrapper.java  |  17 +-
 .../core/impl/util/SimpleLiteralFactory.java    | 313 +++++++++++++++
 .../rdf/core/serializedform/Parser.java         |   2 +-
 .../core/sparql/JavaCCGeneratedQueryParser.jj   |   4 +-
 .../sparql/JavaCCGeneratedSparqlPreParser.jj    |   4 +-
 .../clerezza/rdf/core/access/SecurityTest.java  |   4 +-
 .../clerezza/rdf/core/access/TcManagerTest.java |   4 +-
 .../rdf/core/access/providers/WeightedA.java    |   6 +-
 .../rdf/core/access/providers/WeightedA1.java   |   6 +-
 .../core/access/providers/WeightedAHeavy.java   |   9 +-
 .../core/access/providers/WeightedBlight.java   |   6 +-
 .../core/access/providers/WeightedDummy.java    |   4 +-
 .../rdf/core/events/NotificationTest.java       |  99 -----
 .../rdf/core/impl/PlainLiteralImplTest.java     |  70 ----
 .../clerezza/rdf/core/impl/SimpleGraphTest.java | 107 ------
 .../rdf/core/impl/SimpleLiteralFactoryTest.java |  62 ---
 .../clerezza/rdf/core/impl/TripleImplTest.java  |  57 ---
 .../rdf/core/impl/TypedLiteralImplTest.java     |  66 ----
 .../impl/graphmatching/GraphMatcherTest.java    | 210 -----------
 .../impl/graphmatching/HashMatchingTest.java    |  50 ---
 .../graphmatching/PermutationIteratorTest.java  |  77 ----
 .../core/impl/graphmatching/Utils4Testing.java  |  51 ---
 .../impl/util/SimpleLiteralFactoryTest.java     |  63 ++++
 .../rdf/core/sparql/QueryParserTest.java        |   2 +-
 .../rdf/core/sparql/QuerySerializerTest.java    |   6 +
 .../rdf/core/sparql/SparqlPreParserTest.java    |  46 +--
 65 files changed, 498 insertions(+), 4614 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/pom.xml
----------------------------------------------------------------------
diff --git a/rdf.core/pom.xml b/rdf.core/pom.xml
index f150df9..134f93f 100644
--- a/rdf.core/pom.xml
+++ b/rdf.core/pom.xml
@@ -33,8 +33,13 @@
     <description>Interfaces and utilities to access RDF Graphs</description>
     <dependencies>
         <dependency>
-            <groupId>commons-rdf</groupId>
-            <artifactId>commons-rdf</artifactId>
+            <groupId>org.apache.clerezza.commons-rdf</groupId>
+            <artifactId>commons-rdf-api</artifactId>
+            <version>0.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza.commons-rdf</groupId>
+            <artifactId>commons-rdf-impl-utils</artifactId>
             <version>0.1-SNAPSHOT</version>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/LiteralFactory.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/LiteralFactory.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/LiteralFactory.java
index a7c6104..fafb854 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/LiteralFactory.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/LiteralFactory.java
@@ -18,7 +18,7 @@
  */
 package org.apache.clerezza.rdf.core;
 
-import org.apache.clerezza.rdf.core.impl.SimpleLiteralFactory;
+import org.apache.clerezza.rdf.core.impl.util.SimpleLiteralFactory;
 import org.apache.commons.rdf.Literal;
 
 /**

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/ImmutableGraphServiceFactory.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/ImmutableGraphServiceFactory.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/ImmutableGraphServiceFactory.java
index 23ba3f2..900c8d8 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/ImmutableGraphServiceFactory.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/ImmutableGraphServiceFactory.java
@@ -24,7 +24,6 @@ import org.osgi.framework.ServiceRegistration;
 import org.apache.commons.rdf.Graph;
 import org.apache.commons.rdf.Iri;
 import org.apache.clerezza.rdf.core.access.security.TcAccessController;
-import org.apache.clerezza.rdf.core.impl.SimpleImmutableGraph;
 
 /**
  * @see <a href="http://www.osgi.org/javadoc/r4v41/org/osgi/framework/ServiceFactory.html">
@@ -50,7 +49,7 @@ public class ImmutableGraphServiceFactory implements ServiceFactory {
         Graph tc = 
                 new SecuredGraph(tcManager.getGraph(name), name,
                 tcAccessController);
-        return new SimpleImmutableGraph(tc);
+        return tc.getImmutableGraph();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraph.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraph.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraph.java
deleted file mode 100644
index 64b6fdf..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraph.java
+++ /dev/null
@@ -1,41 +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.clerezza.rdf.core.access;
-
-import java.util.concurrent.locks.ReadWriteLock;
-import org.apache.commons.rdf.Graph;
-
-/**
- *
- * Represents an <code>Graph</code> that can be locked for reading/writing.
- *
- * @author rbn
- */
-public interface  LockableMGraph extends Graph {
-
-    /**
-     * The lock provided by this methods allows to create read- and write-locks
-     * that span individual method calls. Having a read locks prevents other
-     * threads from writing to this Graph, having a write-lock prevents other
-     * threads from reading and writing.
-     *
-     * @return the lock of this Graph
-     */
-    ReadWriteLock getLock();
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraphWrapper.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraphWrapper.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraphWrapper.java
deleted file mode 100644
index 59d97fa..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockableMGraphWrapper.java
+++ /dev/null
@@ -1,274 +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.clerezza.rdf.core.access;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Iri;
-import org.apache.clerezza.rdf.core.access.debug.ReentrantReadWriteLockTracker;
-import org.apache.commons.rdf.event.FilterTriple;
-import org.apache.commons.rdf.event.GraphListener;
-
-/**
- * Wrappes an Graph as a LockableMGraph, this class is used by TcManager to
- * support TcProviders that do not privide <code>LockableMGraph</code>.
- *
- * @author rbn
- */
-public class LockableMGraphWrapper implements LockableMGraph {
-
-    private static final String DEBUG_MODE = "rdfLocksDebugging";
-    private final ReadWriteLock lock;
-
-    private final Lock readLock;
-    private final Lock writeLock;
-    private final Graph wrapped;
-
-    /**
-     * Constructs a LocalbleMGraph for an Graph.
-     *
-     * @param providedMGraph a non-lockable graph
-     */
-    public LockableMGraphWrapper(final Graph providedMGraph) {
-        this.wrapped = providedMGraph;
-        {
-            String debugMode = System.getProperty(DEBUG_MODE);
-            if (debugMode != null && debugMode.toLowerCase().equals("true")) {
-                lock = new ReentrantReadWriteLockTracker();
-            } else {
-                lock = new ReentrantReadWriteLock();
-            }
-        }
-        readLock = lock.readLock();
-        writeLock = lock.writeLock();
-    }
-    
-    public LockableMGraphWrapper(final Graph providedMGraph, final ReadWriteLock lock) {
-        this.wrapped = providedMGraph;
-        this.lock = lock;
-        readLock = lock.readLock();
-        writeLock = lock.writeLock();
-    }
-
-    @Override
-    public ReadWriteLock getLock() {
-        return lock;
-    }
-
-    @Override
-    public ImmutableGraph getImmutableGraph() {
-        readLock.lock();
-        try {
-            return wrapped.getImmutableGraph();
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public Iterator<Triple> filter(BlankNodeOrIri subject, Iri predicate, RdfTerm object) {
-        readLock.lock();
-        try {
-            return new LockingIterator(wrapped.filter(subject, predicate, object), lock);
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public int size() {
-        readLock.lock();
-        try {
-            return wrapped.size();
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public boolean isEmpty() {
-        readLock.lock();
-        try {
-            return wrapped.isEmpty();
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    @SuppressWarnings("element-type-mismatch")
-    public boolean contains(Object o) {
-        readLock.lock();
-        try {
-            return wrapped.contains(o);
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public Iterator<Triple> iterator() {
-        readLock.lock();
-        try {
-            return new LockingIterator(wrapped.iterator(), lock);
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public Object[] toArray() {
-        readLock.lock();
-        try {
-            return wrapped.toArray();
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public <T> T[] toArray(T[] a) {
-        readLock.lock();
-        try {
-            return wrapped.toArray(a);
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public boolean containsAll(Collection<?> c) {
-        readLock.lock();
-        try {
-            return wrapped.containsAll(c);
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public boolean add(Triple e) {
-        writeLock.lock();
-        try {
-            return wrapped.add(e);
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-    @Override
-    public boolean remove(Object o) {
-        writeLock.lock();
-        try {
-            return wrapped.remove(o);
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-    @Override
-    public boolean addAll(Collection<? extends Triple> c) {
-        writeLock.lock();
-        try {
-            return wrapped.addAll(c);
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-    @Override
-    public boolean removeAll(Collection<?> c) {
-        writeLock.lock();
-        try {
-            return wrapped.removeAll(c);
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-    @Override
-    public boolean retainAll(Collection<?> c) {
-        writeLock.lock();
-        try {
-            return wrapped.retainAll(c);
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-    @Override
-    public void clear() {
-        writeLock.lock();
-        try {
-            wrapped.clear();
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-    @Override
-    public void addGraphListener(GraphListener listener, FilterTriple filter, long delay) {
-        wrapped.addGraphListener(listener, filter, delay);
-    }
-
-    @Override
-    public void addGraphListener(GraphListener listener, FilterTriple filter) {
-        wrapped.addGraphListener(listener, filter);
-    }
-
-    @Override
-    public void removeGraphListener(GraphListener listener) {
-        wrapped.removeGraphListener(listener);
-    }
-
-    @Override
-    public int hashCode() {
-        return wrapped.hashCode();
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (obj == this) {
-            return true;
-        }
-        if (obj.getClass() != getClass()) {
-            return false;
-        }
-
-        LockableMGraphWrapper other = (LockableMGraphWrapper) obj;
-        return wrapped.equals(other.wrapped);
-    }
-
-    @Override
-    public String toString() {
-        return wrapped.toString();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockingIterator.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockingIterator.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockingIterator.java
deleted file mode 100644
index defb966..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/LockingIterator.java
+++ /dev/null
@@ -1,73 +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.clerezza.rdf.core.access;
-
-import java.util.Iterator;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import org.apache.commons.rdf.Triple;
-
-/**
- * Wrapps an iterator<Triple> reading entering a read-lock on every invocation
- * of hasNext and next
- * @author reto
- */
-class LockingIterator implements Iterator<Triple> {
-
-    private Iterator<Triple> base;
-    private Lock readLock;
-    private Lock writeLock;
-
-    public LockingIterator(Iterator<Triple> iterator, ReadWriteLock lock) {
-        base = iterator;
-        readLock = lock.readLock();
-        writeLock = lock.writeLock();
-    }
-
-    @Override
-    public boolean hasNext() {
-        readLock.lock();
-        try {
-            return base.hasNext();
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public Triple next() {
-        readLock.lock();
-        try {
-            return base.next();
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public void remove() {
-        writeLock.lock();
-        try {
-            base.remove();
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/MGraphServiceFactory.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/MGraphServiceFactory.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/MGraphServiceFactory.java
index 7774177..a231733 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/MGraphServiceFactory.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/MGraphServiceFactory.java
@@ -45,7 +45,7 @@ public class MGraphServiceFactory implements ServiceFactory {
 
     @Override
     public Object getService(Bundle arg0, ServiceRegistration arg1) {
-        return new SecuredMGraph(tcManager.getMGraph(name), name, tcAccessController);
+        return new SecuredGraph(tcManager.getMGraph(name), name, tcAccessController);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredGraph.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredGraph.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredGraph.java
index 3c35497..8620563 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredGraph.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredGraph.java
@@ -20,14 +20,16 @@ package org.apache.clerezza.rdf.core.access;
 
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.concurrent.locks.ReadWriteLock;
 import org.apache.commons.rdf.BlankNodeOrIri;
 import org.apache.commons.rdf.RdfTerm;
 import org.apache.commons.rdf.Triple;
 import org.apache.commons.rdf.Graph;
 import org.apache.commons.rdf.Iri;
 import org.apache.clerezza.rdf.core.access.security.TcAccessController;
-import org.apache.clerezza.rdf.core.impl.SimpleImmutableGraph;
+import org.apache.commons.rdf.impl.utils.simple.SimpleImmutableGraph;
 import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.WatchableGraph;
 import org.apache.commons.rdf.event.FilterTriple;
 import org.apache.commons.rdf.event.GraphListener;
 
@@ -150,22 +152,6 @@ public class SecuredGraph implements Graph {
         return wrapped.contains((Triple) o);
     }
 
-    @Override
-    public void addGraphListener(GraphListener listener, FilterTriple filter, long delay) {
-        checkRead();
-        wrapped.addGraphListener(listener, filter, delay);
-    }
-
-    @Override
-    public void addGraphListener(GraphListener listener, FilterTriple filter) {
-        checkRead();
-        wrapped.addGraphListener(listener, filter);
-    }
-
-    @Override
-    public void removeGraphListener(GraphListener listener) {
-        wrapped.removeGraphListener(listener);
-    }
 
     @Override
     public Iterator<Triple> iterator() {
@@ -182,4 +168,9 @@ public class SecuredGraph implements Graph {
     public ImmutableGraph getImmutableGraph() {
         return new SimpleImmutableGraph(this);
     }
+
+    @Override
+    public ReadWriteLock getLock() {
+        return wrapped.getLock();
+    }
 }

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredMGraph.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredMGraph.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredMGraph.java
deleted file mode 100644
index 77b6d6a..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/SecuredMGraph.java
+++ /dev/null
@@ -1,72 +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.clerezza.rdf.core.access;
-
-import java.security.AccessControlException;
-import java.util.concurrent.locks.ReadWriteLock;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.Iri;
-import org.apache.clerezza.rdf.core.access.security.TcAccessController;
-import org.apache.clerezza.rdf.core.impl.SimpleImmutableGraph;
-import org.apache.clerezza.rdf.core.impl.WriteBlockedMGraph;
-
-/**
- * A SecuredMGraph is a LockableMGraph that wraps a LockableMGraph checking each
- * access for the rights on a the ImmutableGraph for which the uri is passed to the 
- * constructor.
- *
- * @author mir
- */
-public class SecuredMGraph extends SecuredGraph implements LockableMGraph {
-
-    private LockableMGraph wrapped;
-
-    public SecuredMGraph(LockableMGraph wrapped, Iri name,
-            TcAccessController tcAccessController) {
-        super(wrapped, name,  tcAccessController);
-        this.wrapped = wrapped;
-    }
-
-
-    @Override
-    public ReadWriteLock getLock() {
-        return wrapped.getLock();
-    }
-
-    /**
-     * Returns the wrapped LockableMGraph if the caller has all access rights.
-     * If the caller has only the read access right, then a write-blocked
-     * LockableMGraph is returned. If the caller has neither the read nor the write
-     * access right then an AccessControlException is thrown.
-     *
-     * @return the wrapped LockableMGraph or a write-block LockableMGraph depending
-     *        on the access rights of the caller.
-     */
-    public LockableMGraph getUnsecuredMGraph() {
-        try {
-            checkWrite();
-            return wrapped;
-        } catch (AccessControlException ex) {
-            checkRead();
-            return new WriteBlockedMGraph(wrapped);
-        }
-        
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java
index 4a977d8..6e56479 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java
@@ -19,7 +19,6 @@
 package org.apache.clerezza.rdf.core.access;
 
 import java.security.AccessControlException;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Dictionary;
 import java.util.HashMap;
@@ -34,11 +33,9 @@ import java.util.TreeSet;
 
 import org.apache.commons.rdf.ImmutableGraph;
 import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Graph;
 import org.apache.commons.rdf.Iri;
 import org.apache.clerezza.rdf.core.access.security.TcAccessController;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.impl.WriteBlockedMGraph;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
 import org.apache.clerezza.rdf.core.impl.WriteBlockedGraph;
 import org.apache.clerezza.rdf.core.sparql.NoQueryEngineException;
 import org.apache.clerezza.rdf.core.sparql.ParseException;
@@ -53,8 +50,6 @@ import org.apache.clerezza.rdf.core.sparql.query.SelectQuery;
 import org.apache.felix.scr.annotations.Properties;
 import org.apache.felix.scr.annotations.Property;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.component.ComponentContext;
 import org.osgi.service.component.annotations.Component;
@@ -84,7 +79,7 @@ import org.osgi.service.component.annotations.ReferencePolicy;
  * injects them the instance.
  *
  * This class returns
- * <code>LockableMGraph</code>s a subtype of
+ * <code>Graph</code>s a subtype of
  * <code>Graph</code> that allows read/write locks.
  *
  * This class also registers all Graphs as services with the property
@@ -217,12 +212,12 @@ public class TcManager extends TcProviderMultiplexer {
     }
 
     @Override
-    public LockableMGraph getMGraph(Iri name) {
+    public Graph getMGraph(Iri name) {
         try {
             tcAccessController.checkReadWritePermission(name);
         } catch (AccessControlException e) {
             tcAccessController.checkReadPermission(name);
-            return new WriteBlockedMGraph(super.getMGraph(name));
+            return new WriteBlockedGraph(super.getMGraph(name));
         }
         return super.getMGraph(name);
     }
@@ -240,7 +235,7 @@ public class TcManager extends TcProviderMultiplexer {
     }
 
     @Override
-    public LockableMGraph createMGraph(Iri name)
+    public Graph createMGraph(Iri name)
             throws UnsupportedOperationException {
         tcAccessController.checkReadWritePermission(name);
         return super.createMGraph(name);
@@ -355,7 +350,7 @@ public class TcManager extends TcProviderMultiplexer {
         }
         final QueryEngine queryEngine = this.queryEngine;
         if (queryEngine != null) {
-            return queryEngine.execute(this, new SimpleMGraph(), query);
+            return queryEngine.execute(this, new SimpleGraph(), query);
         } else {
             throw new NoQueryEngineException();
         }
@@ -586,7 +581,7 @@ public class TcManager extends TcProviderMultiplexer {
         if (isMGraph) {
             interfaceNames = new String[]{
                 Graph.class.getName(),
-                LockableMGraph.class.getName()
+                Graph.class.getName()
             };
             service = new MGraphServiceFactory(this, name, tcAccessController);
         } else {

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcProviderMultiplexer.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcProviderMultiplexer.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcProviderMultiplexer.java
index a8e4da6..2d2ca96 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcProviderMultiplexer.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcProviderMultiplexer.java
@@ -47,9 +47,9 @@ public class TcProviderMultiplexer implements TcProvider {
     protected SortedSet<WeightedTcProvider> providerList = new TreeSet<WeightedTcProvider>(
             new WeightedProviderComparator());
     /**
-     * Mapping to LockableMGraph's and ServiceRegistration using their URI's as key.
-     * Makes sure that per URI only one instance of the LockableMGraph is used,
-     * otherwise the locks in the <code>LockableMGraph</code>s would have no effect
+     * Mapping to Graph's and ServiceRegistration using their URI's as key.
+     * Makes sure that per URI only one instance of the Graph is used,
+     * otherwise the locks in the <code>Graph</code>s would have no effect
      * between different instances and concurrency issues could occur.
      */
     private Map<Iri, MGraphHolder> mGraphCache = Collections.synchronizedMap(new HashMap<Iri, MGraphHolder>());
@@ -68,7 +68,7 @@ public class TcProviderMultiplexer implements TcProvider {
      */
     public void addWeightedTcProvider(WeightedTcProvider provider) {
         providerList.add(provider);
-        updateLockableMGraphCache(provider, true);
+        updateGraphCache(provider, true);
     }
 
     /**
@@ -80,7 +80,7 @@ public class TcProviderMultiplexer implements TcProvider {
     public void removeWeightedTcProvider(
             WeightedTcProvider provider) {
         providerList.remove(provider);
-        updateLockableMGraphCache(provider, false);
+        updateGraphCache(provider, false);
     }
 
     /**
@@ -133,7 +133,7 @@ public class TcProviderMultiplexer implements TcProvider {
      *            <code>org.apache.clerezza.rdf.core.TcManager.providerList</code>
      *            otherwise <code>false</code>
      */
-    private void updateLockableMGraphCache(WeightedTcProvider provider,
+    private void updateGraphCache(WeightedTcProvider provider,
             boolean providerAdded) {
         Set<Iri> uriSet = provider.listGraphs();
         if (!(uriSet == null || uriSet.isEmpty())) {
@@ -232,9 +232,9 @@ public class TcProviderMultiplexer implements TcProvider {
     }
 
     @Override
-    public LockableMGraph getMGraph(Iri name)
+    public Graph getMGraph(Iri name)
             throws NoSuchEntityException {
-        LockableMGraph result = getMGraphFromCache(name);
+        Graph result = getMGraphFromCache(name);
         if (result == null) {
             synchronized (this) {
                 result = getMGraphFromCache(name);
@@ -246,7 +246,7 @@ public class TcProviderMultiplexer implements TcProvider {
         return result;
     }
 
-    private LockableMGraph getMGraphFromCache(Iri name) {
+    private Graph getMGraphFromCache(Iri name) {
         MGraphHolder holder = mGraphCache.get(name);
         if (holder == null) {
             return null;
@@ -254,12 +254,12 @@ public class TcProviderMultiplexer implements TcProvider {
         return holder.getMGraph();
     }
 
-    private LockableMGraph getUnsecuredMGraphAndAddToCache(Iri name)
+    private Graph getUnsecuredMGraphAndAddToCache(Iri name)
             throws NoSuchEntityException {
         for (WeightedTcProvider provider : providerList) {
             try {
                 Graph providedMGraph = provider.getMGraph(name);
-                LockableMGraph result = ensureLockable(providedMGraph);
+                Graph result = ensureLockable(providedMGraph);
 
                 if (isCachingEnabled()) {
 	                mGraphCache.put(name, new MGraphHolder(
@@ -282,7 +282,7 @@ public class TcProviderMultiplexer implements TcProvider {
         for (WeightedTcProvider provider : providerList) {
             try {
                 result = provider.getTriples(name);
-                if (!(result instanceof Graph)) {
+                if (result instanceof ImmutableGraph) {
                     return result;
                 } else {
                     // This is to ensure the Graph gets added to the cache
@@ -298,19 +298,12 @@ public class TcProviderMultiplexer implements TcProvider {
     }
 
     @Override
-    public LockableMGraph createMGraph(Iri name)
+    public Graph createMGraph(Iri name)
             throws UnsupportedOperationException {
 
         for (WeightedTcProvider provider : providerList) {
             try {
-                Graph providedMGraph = provider.createMGraph(name);
-                LockableMGraph result;
-                if (providedMGraph instanceof LockableMGraph) {
-                    result = (LockableMGraph) providedMGraph;
-                } else {
-                    result = new LockableMGraphWrapper(providedMGraph);
-                }
-
+                Graph result = provider.createMGraph(name);
                 // unregisters a possible ImmutableGraph or Graph service under this name
                 // provided by a WeightedTcProvider with a lower weight.
                 tcDisappears(name);
@@ -417,31 +410,26 @@ public class TcProviderMultiplexer implements TcProvider {
         return result;
     }
 
-    private LockableMGraph ensureLockable(Graph providedMGraph) {
-        LockableMGraph result;
-        if (providedMGraph instanceof LockableMGraph) {
-            result = (LockableMGraph) providedMGraph;
-        } else {
-            result = new LockableMGraphWrapper(providedMGraph);
-        }
-        return result;
+    private Graph ensureLockable(Graph providedMGraph) {
+        //Graphs are alway locable now
+        return providedMGraph;
     }
 
     /**
-     * Contains an unsecured LockableMGraph, a ServiceRegistration and
+     * Contains an unsecured Graph, a ServiceRegistration and
      * the WeightedTcProvider that generated the ImmutableGraph
      */
     private static class MGraphHolder {
 
         private WeightedTcProvider tcProvider;
-        private WeakReference<LockableMGraph> mGraphReference;
+        private WeakReference<Graph> mGraphReference;
 
-        MGraphHolder(WeightedTcProvider tcProvider, LockableMGraph graph) {
+        MGraphHolder(WeightedTcProvider tcProvider, Graph graph) {
             this.tcProvider = tcProvider;
-            this.mGraphReference = new WeakReference<LockableMGraph>(graph);
+            this.mGraphReference = new WeakReference<Graph>(graph);
         }
 
-        LockableMGraph getMGraph() {
+        Graph getMGraph() {
             return this.mGraphReference.get();
         }
 

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/debug/ReadLockDebug.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/debug/ReadLockDebug.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/debug/ReadLockDebug.java
deleted file mode 100644
index 80cb6d0..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/debug/ReadLockDebug.java
+++ /dev/null
@@ -1,85 +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.clerezza.rdf.core.access.debug;
-
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
-
-/**
- *
- * @author mir
- */
-public class ReadLockDebug extends ReadLock {
-
-    ReentrantReadWriteLockTracker lock;
-    StackTraceElement[] stackTrace;
-
-    ReadLock readLock;
-    public ReadLockDebug(ReentrantReadWriteLockTracker lock) {
-        super(lock);
-        this.lock = lock;
-        this.readLock = lock.realReadLock();
-    }
-
-    @Override
-    public void lock() {
-        readLock.lock();
-        lock.addLockedReadLock(this);
-        stackTrace = Thread.currentThread().getStackTrace();
-    }
-
-    @Override
-    public void lockInterruptibly() throws InterruptedException {
-        readLock.lockInterruptibly();
-    }
-
-    @Override
-    public Condition newCondition() {
-        return readLock.newCondition();
-    }
-
-    @Override
-    public String toString() {
-        return readLock.toString();
-    }
-
-    @Override
-    public boolean tryLock() {
-        return readLock.tryLock();
-    }
-
-    @Override
-    public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException {
-        return readLock.tryLock(timeout, unit);
-    }
-
-    @Override
-    public void unlock() {
-        readLock.unlock();
-        lock.removeReadLock(this);
-        stackTrace = null;
-    }
-
-    public StackTraceElement[] getStackTrace() {
-        return stackTrace;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/debug/ReentrantReadWriteLockTracker.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/debug/ReentrantReadWriteLockTracker.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/debug/ReentrantReadWriteLockTracker.java
deleted file mode 100644
index 75b06d8..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/debug/ReentrantReadWriteLockTracker.java
+++ /dev/null
@@ -1,133 +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.clerezza.rdf.core.access.debug;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-/**
- *
- * @author mir
- */
-public class ReentrantReadWriteLockTracker extends ReentrantReadWriteLock {
-
-
-    private Set<ReadLockDebug> lockedReadLocks = Collections.synchronizedSet(new HashSet<ReadLockDebug>());
-    private final WriteLockDebug writeLock = new WriteLockDebug(this);
-    @Override
-    protected Thread getOwner() {
-        return super.getOwner();
-    }
-
-    @Override
-    protected Collection<Thread> getQueuedReaderThreads() {
-        return super.getQueuedReaderThreads();
-    }
-
-    @Override
-    protected Collection<Thread> getQueuedThreads() {
-        return super.getQueuedThreads();
-    }
-
-    @Override
-    protected Collection<Thread> getQueuedWriterThreads() {
-        return super.getQueuedWriterThreads();
-    }
-
-    @Override
-    public int getReadHoldCount() {
-        return super.getReadHoldCount();
-    }
-
-    @Override
-    public int getReadLockCount() {
-        return super.getReadLockCount();
-    }
-
-    @Override
-    public int getWaitQueueLength(Condition condition) {
-        return super.getWaitQueueLength(condition);
-    }
-
-    @Override
-    protected Collection<Thread> getWaitingThreads(Condition condition) {
-        return super.getWaitingThreads(condition);
-    }
-
-    @Override
-    public int getWriteHoldCount() {
-        return super.getWriteHoldCount();
-    }
-
-    @Override
-    public boolean hasWaiters(Condition condition) {
-        return super.hasWaiters(condition);
-    }
-
-    @Override
-    public boolean isWriteLocked() {
-        return super.isWriteLocked();
-    }
-
-    @Override
-    public boolean isWriteLockedByCurrentThread() {
-        return super.isWriteLockedByCurrentThread();
-    }
-
-    @Override
-    public ReadLock readLock() {
-        return new ReadLockDebug(this);
-    }
-
-    ReadLock realReadLock() {
-        return super.readLock();
-    }
-
-    WriteLock realWriteLock() {
-        return super.writeLock();
-    }
-
-    @Override
-    public String toString() {
-        return super.toString();
-    }
-
-    @Override
-    public WriteLockDebug writeLock() {
-        return writeLock;
-    }
-
-    void addLockedReadLock(ReadLockDebug lock) {
-        lockedReadLocks.add(lock);
-    }
-
-    void removeReadLock(ReadLockDebug lock) {
-        lockedReadLocks.remove(lock);
-    }
-
-    public Set<ReadLockDebug> getLockedReadLocks() {
-        return lockedReadLocks;
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/debug/WriteLockDebug.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/debug/WriteLockDebug.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/debug/WriteLockDebug.java
deleted file mode 100644
index 5bbbfeb..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/debug/WriteLockDebug.java
+++ /dev/null
@@ -1,89 +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.clerezza.rdf.core.access.debug;
-
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
-
-/**
- *
- * @author mir
- */
-public class WriteLockDebug extends WriteLock {
-
-    private ReentrantReadWriteLockTracker lock;
-    private WriteLock writeLock;
-    private StackTraceElement[] stackTrace;
-
-    public WriteLockDebug(ReentrantReadWriteLockTracker lock) {
-        super(lock);
-        this.lock = lock;
-        this.writeLock = lock.realWriteLock();
-    }
-
-    @Override
-    public int getHoldCount() {
-        return writeLock.getHoldCount();
-    }
-
-    @Override
-    public boolean isHeldByCurrentThread() {
-        return writeLock.isHeldByCurrentThread();
-    }
-
-    @Override
-    public void lock() {
-        writeLock.lock();
-        stackTrace = Thread.currentThread().getStackTrace();
-    }
-
-    @Override
-    public void lockInterruptibly() throws InterruptedException {
-        writeLock.lockInterruptibly();
-    }
-
-    @Override
-    public Condition newCondition() {
-        return writeLock.newCondition();
-    }
-
-    @Override
-    public boolean tryLock() {
-        return writeLock.tryLock();
-    }
-
-    @Override
-    public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException {
-        return writeLock.tryLock(timeout, unit);
-    }
-
-    @Override
-    public void unlock() {
-        writeLock.unlock();
-        stackTrace = null;
-    }
-
-    public StackTraceElement[] getStackTrace() {
-        return stackTrace;
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcAccessController.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcAccessController.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcAccessController.java
index 405cfbd..155cccb 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcAccessController.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/security/TcAccessController.java
@@ -31,17 +31,17 @@ import java.util.LinkedList;
 import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.concurrent.locks.Lock;
-import org.apache.commons.rdf.BlankNode;
 import org.apache.clerezza.rdf.core.LiteralFactory;
+import org.apache.commons.rdf.BlankNode;
 import org.apache.commons.rdf.BlankNodeOrIri;
 import org.apache.commons.rdf.RdfTerm;
 import org.apache.commons.rdf.Triple;
 import org.apache.commons.rdf.Iri;
-import org.apache.clerezza.rdf.core.access.LockableMGraph;
 import org.apache.clerezza.rdf.core.access.NoSuchEntityException;
 import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
 import org.apache.clerezza.utils.security.PermissionParser;
+import org.apache.commons.rdf.Graph;
 import org.apache.commons.rdf.Literal;
 
 /**
@@ -146,7 +146,7 @@ public abstract class TcAccessController {
     public void setRequiredReadPermissionStrings(Iri GraphUri,
             Collection<String> permissionDescriptions) {
         readPermissionCache.remove(GraphUri);
-        final LockableMGraph permissionMGraph = getOrCreatePermisionGraph();
+        final Graph permissionMGraph = getOrCreatePermisionGraph();
         Lock l = permissionMGraph.getLock().writeLock();
         l.lock();
         try {
@@ -186,7 +186,7 @@ public abstract class TcAccessController {
     public void setRequiredReadWritePermissionStrings(Iri GraphUri,
             Collection<String> permissionDescriptions) {
         readWritePermissionCache.remove(GraphUri);
-        final LockableMGraph permissionMGraph = getOrCreatePermisionGraph();
+        final Graph permissionMGraph = getOrCreatePermisionGraph();
         Lock l = permissionMGraph.getLock().writeLock();
         l.lock();
         try {
@@ -258,7 +258,7 @@ public abstract class TcAccessController {
         return result;
     }
 
-    private BlankNodeOrIri createList(Iterator<String> iterator, LockableMGraph permissionMGraph) {
+    private BlankNodeOrIri createList(Iterator<String> iterator, Graph permissionMGraph) {
         if (!iterator.hasNext()) {
             return rdfNil;
         }
@@ -273,7 +273,7 @@ public abstract class TcAccessController {
 
     //called withiong write-lock
     private void removeExistingRequiredReadPermissions(Iri GraphUri,
-            LockableMGraph permissionMGraph) {
+            Graph permissionMGraph) {
         try {
             Triple t = permissionMGraph.filter(GraphUri, readPermissionListProperty, null).next();
             RdfTerm list = t.getObject();
@@ -284,7 +284,7 @@ public abstract class TcAccessController {
         }
     }
 
-    private void removeList(BlankNodeOrIri list, LockableMGraph permissionMGraph) {
+    private void removeList(BlankNodeOrIri list, Graph permissionMGraph) {
         try {
             Triple t = permissionMGraph.filter(list, rest, null).next();
             RdfTerm restList = t.getObject();
@@ -306,7 +306,7 @@ public abstract class TcAccessController {
     }
     private Collection<String> getRequiredPermissionStrings(final Iri GraphUri, Iri property) {
         try {
-            final LockableMGraph permissionMGraph = tcManager.getMGraph(permissionGraphName);
+            final Graph permissionMGraph = tcManager.getMGraph(permissionGraphName);
             Lock l = permissionMGraph.getLock().readLock();
             l.lock();
             try {
@@ -325,7 +325,7 @@ public abstract class TcAccessController {
         }
     }
 
-    private void readList(BlankNodeOrIri list, LockableMGraph permissionMGraph, LinkedList<String> target) {
+    private void readList(BlankNodeOrIri list, Graph permissionMGraph, LinkedList<String> target) {
         if (list.equals(rdfNil)) {
             return;
         }
@@ -338,7 +338,7 @@ public abstract class TcAccessController {
         target.addFirst(value);
     }
 
-    private LockableMGraph getOrCreatePermisionGraph() {
+    private Graph getOrCreatePermisionGraph() {
         try {
             return tcManager.getMGraph(permissionGraphName);
         } catch (NoSuchEntityException e) {

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/AbstractGraph.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/AbstractGraph.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/AbstractGraph.java
deleted file mode 100644
index 86f000b..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/AbstractGraph.java
+++ /dev/null
@@ -1,251 +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.clerezza.rdf.core.impl;
-
-import java.lang.ref.WeakReference;
-import java.util.AbstractCollection;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-
-import java.util.Set;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.event.AddEvent;
-import org.apache.commons.rdf.event.FilterTriple;
-import org.apache.commons.rdf.event.GraphEvent;
-import org.apache.commons.rdf.event.GraphListener;
-import org.apache.commons.rdf.event.RemoveEvent;
-
-/**
- * An abstract implementation of <code>Graph</code> implementing
- * <code>iterator</code> and <code>contains</code> calling <code>filter</code>.
- *
- * @author reto
- */
-public abstract class AbstractGraph extends AbstractCollection<Triple>
-        implements Graph {
-
-    //all listeners
-    private final Set<ListenerConfiguration> listenerConfigs = Collections.synchronizedSet(
-            new HashSet<ListenerConfiguration>());
-    private DelayedNotificator delayedNotificator = new DelayedNotificator();
-
-    @Override
-    public Iterator<Triple> iterator() {
-        return filter(null, null, null);
-    }
-
-    @Override
-    public boolean contains(Object o) {
-        if (!(o instanceof Triple)) {
-            return false;
-        }
-        Triple t = (Triple) o;
-        return filter(t.getSubject(), t.getPredicate(), t.getObject()).hasNext();
-    }
-
-    @Override
-    public Iterator<Triple> filter(BlankNodeOrIri subject, Iri predicate,
-            RdfTerm object) {
-        final Iterator<Triple> baseIter = performFilter(subject, predicate, object);
-        return new Iterator<Triple>() {
-
-            Triple currentTriple = null;
-
-            @Override
-            public boolean hasNext() {
-                return baseIter.hasNext();
-            }
-
-            @Override
-            public Triple next() {
-                currentTriple = baseIter.next();
-                return currentTriple;
-            }
-
-            @Override
-            public void remove() {
-                baseIter.remove();
-                dispatchEvent(new RemoveEvent(AbstractGraph.this, currentTriple));
-            }
-        };
-    }
-
-    /**
-     * A subclass of <code>AbstractGraph</code> should override 
-     * this method instead of <code>filter</code> for ImmutableGraph event support to be
-     * added. The Iterator returned by <code>filter</code> will dispatch a
-     * GraphEvent after invoking the remove method of the iterator returned by
-     * this method.
-     * 
-     * @param subject
-     * @param predicate
-     * @param object
-     * @return
-     */
-    protected abstract Iterator<Triple> performFilter(BlankNodeOrIri subject, Iri predicate,
-            RdfTerm object);
-
-    @Override
-    public boolean add(Triple triple) {
-        boolean success = performAdd(triple);
-        if (success) {
-            dispatchEvent(new AddEvent(this, triple));
-        }
-        return success;
-    }
-
-    /**
-     * A subclass of <code>AbstractGraph</code> should override 
-     * this method instead of <code>add</code> for ImmutableGraph event support to be
-     * added.
-     * 
-     * @param e The triple to be added to the triple collection
-     * @return
-     */
-    protected boolean performAdd(Triple e) {
-        return super.add(e);
-    }
-
-    @Override
-    public boolean remove(Object o) {
-        Triple triple = (Triple) o;
-        boolean success = performRemove(triple);
-        if (success) {
-            dispatchEvent(new RemoveEvent(this, triple));
-        }
-        return success;
-    }
-
-    @Override
-    public boolean removeAll(Collection<?> c) {
-        boolean modified = false;
-        for (Iterator<? extends Object> it = c.iterator(); it.hasNext();) {
-            Object object = it.next();
-            if (remove(object)) {
-                modified = true;
-            }
-        }
-        return modified;
-    }
-
-    /**
-     * A subclass of <code>AbstractGraph</code> should override 
-     * this method instead of <code>remove</code> for ImmutableGraph event support to be
-     * added.
-     * 
-     * @param o The triple to be removed from the triple collection
-     * @return
-     */
-    protected boolean performRemove(Triple triple) {
-        Iterator<Triple> e = performFilter(null, null, null);
-        while (e.hasNext()) {
-            if (triple.equals(e.next())) {
-                e.remove();
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Dispatches a <code>GraphEvent</code> to all registered listeners for which
-     * the specified <code>Triple</code> matches the <code>FilterTriple</code>s
-     * of the listeners.
-     * 
-     * @param triple The Triple that was modified
-     * @param type The type of modification
-     */
-    protected void dispatchEvent(GraphEvent event) {
-        synchronized(listenerConfigs) {
-            Iterator<ListenerConfiguration> iter = listenerConfigs.iterator();
-            while (iter.hasNext()) {
-                ListenerConfiguration config = iter.next();
-                GraphListener registeredListener = config.getListener();
-                if (registeredListener == null) {
-                    iter.remove();
-                    continue;
-                }
-                if (config.getFilter().match(event.getTriple())) {
-                    delayedNotificator.sendEventToListener(registeredListener, event);
-                }
-            }
-        }
-    }
-
-    @Override
-    public void addGraphListener(GraphListener listener, FilterTriple filter) {
-        addGraphListener(listener, filter, 0);
-    }
-
-    @Override
-    public void addGraphListener(GraphListener listener, FilterTriple filter,
-            long delay) {
-        listenerConfigs.add(new ListenerConfiguration(listener, filter));
-        if (delay > 0) {
-            delayedNotificator.addDelayedListener(listener, delay);
-        }
-    }
-
-    @Override
-    public void removeGraphListener(GraphListener listener) {
-        synchronized(listenerConfigs) {
-            Iterator<ListenerConfiguration> iter = listenerConfigs.iterator();
-            while (iter.hasNext()) {
-                ListenerConfiguration listenerConfig = iter.next();
-                GraphListener registeredListener = listenerConfig.getListener();
-                if ((registeredListener == null) || (registeredListener.equals(listener))) {
-                    iter.remove();
-                }
-            }
-        }
-        delayedNotificator.removeDelayedListener(listener);
-    }
-
-    private static class ListenerConfiguration {
-
-        private WeakReference<GraphListener> listenerRef;
-        private FilterTriple filter;
-
-        private ListenerConfiguration(GraphListener listener, FilterTriple filter) {
-            this.listenerRef = new WeakReference<GraphListener>(listener);
-            this.filter = filter;
-        }
-
-        /**
-         * @return the listener
-         */
-        GraphListener getListener() {
-            GraphListener listener = listenerRef.get();
-            return listener;
-        }
-
-        /**
-         * @return the filter
-         */
-        FilterTriple getFilter() {
-            return filter;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/AbstractImmutableGraph.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/AbstractImmutableGraph.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/AbstractImmutableGraph.java
deleted file mode 100644
index 9a52c88..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/AbstractImmutableGraph.java
+++ /dev/null
@@ -1,112 +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.clerezza.rdf.core.impl;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.clerezza.rdf.core.impl.graphmatching.GraphMatcher;
-
-/**
- * <code>AbstractGraph</code> is an abstract implementation of <code>ImmutableGraph</code> 
- * implementing the <code>equals</code> and the <code>hashCode</code> methods.
- * 
- * @author reto
- * 
- */
-public abstract class AbstractImmutableGraph extends AbstractGraph
-        implements ImmutableGraph {
-
-    public final synchronized int hashCode() {
-        int result = 0;
-        for (Iterator<Triple> iter = iterator(); iter.hasNext();) {
-            result += getBlankNodeBlindHash(iter.next());
-        }
-        return result;
-    }
-
-    /**
-     * @param triple
-     * @return hash without BNode hashes
-     */
-    private int getBlankNodeBlindHash(Triple triple) {
-        int hash = triple.getPredicate().hashCode();
-        RdfTerm subject = triple.getSubject();
-
-        if (!(subject instanceof BlankNode)) {
-            hash ^= subject.hashCode() >> 1;
-        }
-        RdfTerm object = triple.getObject();
-        if (!(object instanceof BlankNode)) {
-            hash ^= object.hashCode() << 1;
-        }
-
-        return hash;
-    }
-
-    @Override
-    public boolean add(Triple e) {
-        throw new UnsupportedOperationException("Graphs are not mutable, use Graph");
-
-    }
-
-    @Override
-    public boolean addAll(Collection<? extends Triple> c) {
-        throw new UnsupportedOperationException("Graphs are not mutable, use Graph");
-    }
-
-    @Override
-    public boolean remove(Object o) {
-        throw new UnsupportedOperationException("Graphs are not mutable, use Graph");
-    }
-
-    @Override
-    public boolean removeAll(Collection<?> c) {
-        throw new UnsupportedOperationException("Graphs are not mutable, use Graph");
-    }
-
-    @Override
-    public void clear() {
-        throw new UnsupportedOperationException("Graphs are not mutable, use Graph");
-    }
-    
-    
-    @Override
-    public ImmutableGraph getImmutableGraph() {
-        return this;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!(obj instanceof ImmutableGraph)) {
-            return false;
-        }
-        if (hashCode() != obj.hashCode()) {
-            return false;
-        }
-        return GraphMatcher.getValidMapping(this, (ImmutableGraph) obj) != null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/AbstractMGraph.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/AbstractMGraph.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/AbstractMGraph.java
deleted file mode 100644
index 55bb2c3..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/AbstractMGraph.java
+++ /dev/null
@@ -1,36 +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.clerezza.rdf.core.impl;
-
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.Graph;
-
-/**
- * <code>AbstractMGraph</code> is an abstract implementation of <code>Graph</code> 
- * implementing the <code>getGraph</code> method.
- *
- * @author reto
- */
-public abstract class AbstractMGraph extends AbstractGraph implements Graph {
-
-    @Override
-    public ImmutableGraph getImmutableGraph() {
-        return new SimpleImmutableGraph(this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/DelayedNotificator.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/DelayedNotificator.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/DelayedNotificator.java
deleted file mode 100644
index bc49042..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/DelayedNotificator.java
+++ /dev/null
@@ -1,112 +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.clerezza.rdf.core.impl;
-
-import java.lang.ref.WeakReference;
-import java.util.*;
-
-import org.apache.commons.rdf.event.GraphEvent;
-import org.apache.commons.rdf.event.GraphListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- * @author reto
- */
-class DelayedNotificator {
-
-    private static final Logger log = LoggerFactory.getLogger(DelayedNotificator.class);
-    private static Timer timer = new Timer("Event delivery timer",true);
-
-    static class ListenerHolder {
-
-        long delay;
-        List<GraphEvent> events = null;
-        WeakReference<GraphListener> listenerRef;
-
-        public ListenerHolder(GraphListener listener, long delay) {
-            this.listenerRef = new WeakReference<GraphListener>(listener);
-            this.delay = delay;
-        }
-
-        private void registerEvent(GraphEvent event) {
-            synchronized (this) {
-                if (events == null) {
-                    events = new ArrayList<GraphEvent>();
-                    events.add(event);
-                    timer.schedule(new TimerTask() {
-
-                        @Override
-                        public void run() {
-                            List<GraphEvent> eventsLocal;
-                            synchronized (ListenerHolder.this) {
-                                eventsLocal = events;
-                                events = null;
-                            }
-                            GraphListener listener = listenerRef.get();
-                            if (listener == null) {
-                                log.debug("Ignoring garbage collected listener");
-                            } else {
-                                try {
-                                    listener.graphChanged(eventsLocal);
-                                } catch (Exception e) {
-                                    log.warn("Exception delivering ImmutableGraph event", e);
-                                }
-                            }
-                        }
-                    }, delay);
-                } else {
-                    events.add(event);
-                }
-            }
-        }
-    }
-    
-    private final Map<GraphListener, ListenerHolder> map = Collections.synchronizedMap(
-            new WeakHashMap<GraphListener, ListenerHolder>());
-
-    void addDelayedListener(GraphListener listener, long delay) {
-        map.put(listener, new ListenerHolder(listener, delay));
-    }
-
-    /**
-     * removes a Listener, this doesn't prevent the listenerRef from receiving
-     * events alreay scheduled.
-     *
-     * @param listenerRef
-     */
-    void removeDelayedListener(GraphListener listener) {
-        map.remove(listener);
-    }
-
-    /**
-     * if the listenerRef has not been registered as delayed listenerRef te events is
-     * forwarded synchroneously
-     * @param event
-     */
-    void sendEventToListener(GraphListener listener, GraphEvent event) {
-        ListenerHolder holder = map.get(listener);
-        if (holder == null) {
-            listener.graphChanged(Collections.singletonList(event));
-        } else {
-            holder.registerEvent(event);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/PlainLiteralImpl.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/PlainLiteralImpl.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/PlainLiteralImpl.java
deleted file mode 100644
index 9ba5495..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/PlainLiteralImpl.java
+++ /dev/null
@@ -1,103 +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.clerezza.rdf.core.impl;
-
-import java.io.Serializable;
-import org.apache.commons.rdf.Iri;
-
-import org.apache.commons.rdf.Language;
-import org.apache.commons.rdf.Literal;
-
-/**
- *
- * @author reto
- */
-public class PlainLiteralImpl implements Literal, Serializable {
-
-    private String lexicalForm;
-    private Language language = null;
-
-    public PlainLiteralImpl(String value) {
-        if (value == null) {
-            throw new IllegalArgumentException("The literal string cannot be null");
-        }
-        this.lexicalForm = value;
-    }
-
-    public PlainLiteralImpl(String value, Language language) {
-        if (value == null) {
-            throw new IllegalArgumentException("The literal string cannot be null");
-        }
-        this.lexicalForm = value;
-        this.language = language;
-    }
-
-    @Override
-    public String getLexicalForm() {
-        return lexicalForm;
-    }
-
-    @Override
-    public boolean equals(Object otherObj) {
-        if (!(otherObj instanceof Literal)) {
-            return false;
-        }
-        Literal other = (Literal) otherObj;
-        if (!lexicalForm.equals(other.getLexicalForm())) {
-            return false;
-        }
-        if (language != null) {
-            return language.equals(other.getLanguage());
-        }
-        if (other.getLanguage() != null) {
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int hash = lexicalForm.hashCode();
-        if (language != null) {
-            hash += language.hashCode();
-        }
-        return hash;
-    }
-
-    @Override
-    public Language getLanguage() {
-        return language;
-    }
-
-    @Override
-    public String toString() {
-        StringBuffer result = new StringBuffer();
-        result.append('\"').append(lexicalForm).append('\"');
-        if (language != null) {
-            result.append("@").append(language.toString());
-        }
-        return result.toString();
-    }
-
-    @Override
-    public Iri getDataType() {
-        return XSD_STRING;
-    }
-    private static final Iri XSD_STRING = new Iri("http://www.w3.org/2001/XMLSchema#string");
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleGraph.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleGraph.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleGraph.java
deleted file mode 100644
index 334a7d9..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleGraph.java
+++ /dev/null
@@ -1,220 +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.clerezza.rdf.core.impl;
-
-import java.lang.ref.SoftReference;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.ConcurrentModificationException;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Iri;
-
-/**
- * For now this is a minimalistic implementation, without any indexes or other
- * optimizations.
- *
- * This class is not public, implementations should use {@link SimpleGraph} or
- * {@link SimpleMGraph}.
- *
- * @author reto
- */
-class SimpleGraph extends AbstractGraph {
-
-    final Set<Triple> triples;
-
-    private boolean checkConcurrency = false;
-
-    class SimpleIterator implements Iterator<Triple> {
-
-        private Iterator<Triple> listIter;
-        private boolean isValid = true;
-
-        public SimpleIterator(Iterator<Triple> listIter) {
-            this.listIter = listIter;
-        }
-        private Triple currentNext;
-
-        @Override
-        public boolean hasNext() {
-            checkValidity();
-            return listIter.hasNext();
-        }
-
-        @Override
-        public Triple next() {
-            checkValidity();
-            currentNext = listIter.next();
-            return currentNext;
-        }        
-
-        @Override
-        public void remove() {
-            checkValidity();
-            listIter.remove();
-            triples.remove(currentNext);            
-            invalidateIterators(this);            
-        }
-
-        private void checkValidity() throws ConcurrentModificationException {
-            if (checkConcurrency && !isValid) {
-                throw new ConcurrentModificationException();
-            }
-        }
-
-        private void invalidate() {
-            isValid = false;
-        }
-    }    
-    
-    private final Set<SoftReference<SimpleIterator>> iterators =
-            Collections.synchronizedSet(new HashSet<SoftReference<SimpleIterator>>());
-    
-    /**
-     * Creates an empty SimpleGraph
-     */
-    public SimpleGraph() {
-        triples = Collections.synchronizedSet(new HashSet<Triple>());
-    }
-
-    /**
-     * Creates a SimpleGraph using the passed iterator, the iterator 
-     * is consumed before the constructor returns
-     * 
-     * @param iterator
-     */
-    public SimpleGraph(Iterator<Triple> iterator) {
-        triples = new HashSet<Triple>();
-        while (iterator.hasNext()) {
-            Triple triple = iterator.next();
-            triples.add(triple);
-        }
-    }
-
-    /**
-     * Creates a SimpleGraph for the specified set of triples, 
-     * subsequent modification of baseSet do affect the created instance.
-     * 
-     * @param baseSet
-     */
-    public SimpleGraph(Set<Triple> baseSet) {
-        this.triples = baseSet;
-    }
-
-    /**
-     * Creates a SimpleGraph for the specified collection of triples,
-     * subsequent modification of baseSet do not affect the created instance.
-     *
-     * @param baseSet
-     */
-    public SimpleGraph(Collection<Triple> baseCollection) {
-        this.triples = new HashSet<Triple>(baseCollection);
-    }
-
-    @Override
-    public int size() {
-        return triples.size();
-    }
-
-    @Override
-    public Iterator<Triple> performFilter(final BlankNodeOrIri subject, final Iri predicate, final RdfTerm object) {
-        final List<Triple> tripleList = new ArrayList<Triple>();
-        synchronized (triples) {
-            Iterator<Triple> baseIter = triples.iterator();
-            while (baseIter.hasNext()) {
-                Triple triple = baseIter.next();
-                if ((subject != null)
-                        && (!triple.getSubject().equals(subject))) {
-                    continue;
-                }
-                if ((predicate != null)
-                        && (!triple.getPredicate().equals(predicate))) {
-                    continue;
-                }
-                if ((object != null)
-                        && (!triple.getObject().equals(object))) {
-                    continue;
-                }
-                tripleList.add(triple);
-            }
-
-            final Iterator<Triple> listIter = tripleList.iterator();
-            SimpleIterator resultIter = new SimpleIterator(listIter);
-            if (checkConcurrency) {
-                iterators.add(new SoftReference<SimpleIterator>(resultIter));
-            }
-            return resultIter;
-        }
-    }
-
-
-    @Override
-    public boolean performAdd(Triple e) {
-        boolean modified = triples.add(e);
-        if (modified) {
-            invalidateIterators(null);
-        }
-        return modified;
-    }
-    
-    private void invalidateIterators(SimpleIterator caller) {
-        if (!checkConcurrency) {
-            return;
-        }
-        Set<SoftReference> oldReferences = new HashSet<SoftReference>();
-        synchronized(iterators) {
-            for (SoftReference<SimpleGraph.SimpleIterator> softReference : iterators) {
-                SimpleIterator simpleIterator = softReference.get();
-                if (simpleIterator == null) {
-                    oldReferences.add(softReference);
-                    continue;
-                }
-                if (simpleIterator != caller) {
-                    simpleIterator.invalidate();
-                }
-            }
-        }
-        iterators.removeAll(oldReferences);
-    }
-
-    /**
-     * Specifies whether or not to throw <code>ConcurrentModificationException</code>s,
-     * if this simple triple collection is modified concurrently. Concurrency
-     * check is set to false by default.
-     *
-     * @param bool Specifies whether or not to check concurrent modifications.
-     */
-    public void setCheckConcurrency(boolean bool) {
-        checkConcurrency = bool;
-    }
-    
-    
-    @Override
-    public ImmutableGraph getImmutableGraph() {
-        return new SimpleImmutableGraph(this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleImmutableGraph.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleImmutableGraph.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleImmutableGraph.java
deleted file mode 100644
index d0c6a61..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleImmutableGraph.java
+++ /dev/null
@@ -1,78 +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.clerezza.rdf.core.impl;
-
-import java.util.Iterator;
-
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Iri;
-
-/**
- *
- * @author reto
- */
-public class SimpleImmutableGraph extends AbstractImmutableGraph {
-
-    private Graph graph;
-    
-    /**
-     * Creates a ImmutableGraph with the triples in Graph
-     * 
-     * @param Graph the collection of triples this ImmutableGraph shall consist of
-     */
-    public SimpleImmutableGraph(Graph Graph) {
-        this.graph = new SimpleGraph(Graph.iterator());
-    }
-
-    /**
-     * Creates a ImmutableGraph with the triples in Graph.
-     *
-     * This construction allows to specify if the Graph might change
-     * in future. If GraphWillNeverChange is set to true it will
-     * assume that the collection never changes, in this case the collection
-     * isn't copied making things more efficient.
-     *
-     * @param Graph the collection of triples this ImmutableGraph shall consist of
-     * @param GraphWillNeverChange true if the caller promises Graph will never change
-     */
-    public SimpleImmutableGraph(Graph Graph, boolean GraphWillNeverChange) {
-        if (!GraphWillNeverChange) {
-            this.graph = new SimpleGraph(Graph.iterator());
-        } else {
-            this.graph = Graph;
-        }
-    }
-    
-    public SimpleImmutableGraph(Iterator<Triple> tripleIter) {
-        this.graph = new SimpleGraph(tripleIter);
-    }
-
-    @Override
-    public int size() {
-        return graph.size();
-    }
-
-    @Override
-    public Iterator<Triple> performFilter(BlankNodeOrIri subject, Iri predicate, RdfTerm object) {
-        return graph.filter(subject, predicate, object);
-    }
-}