clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [3/4] clerezza git commit: Adapted to updated RDF Commons draft
Date Mon, 12 Jan 2015 19:27:12 GMT
http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/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
index 7827d61..86f000b 100644
--- 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
@@ -18,89 +18,234 @@
  */
 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 org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.Graph;
+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.clerezza.rdf.core.impl.graphmatching.GraphMatcher;
+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;
 
 /**
- * <code>AbstractGraph</code> is an abstract implementation of <code>Graph</code> 
- * implementing the <code>equals</code> and the <code>hashCode</code> methods.
- * 
+ * 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 AbstractTripleCollection
+public abstract class AbstractGraph extends AbstractCollection<Triple>
         implements Graph {
 
-    public final synchronized int hashCode() {
-        int result = 0;
-        for (Iterator<Triple> iter = iterator(); iter.hasNext();) {
-            result += getBlankNodeBlindHash(iter.next());
+    //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;
         }
-        return result;
+        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));
+            }
+        };
     }
 
     /**
-     * @param triple
-     * @return hash without BNode hashes
+     * 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
      */
-    private int getBlankNodeBlindHash(Triple triple) {
-        int hash = triple.getPredicate().hashCode();
-        RdfTerm subject = triple.getSubject();
+    protected abstract Iterator<Triple> performFilter(BlankNodeOrIri subject, Iri predicate,
+            RdfTerm object);
 
-        if (!(subject instanceof BlankNode)) {
-            hash ^= subject.hashCode() >> 1;
-        }
-        RdfTerm object = triple.getObject();
-        if (!(object instanceof BlankNode)) {
-            hash ^= object.hashCode() << 1;
+    @Override
+    public boolean add(Triple triple) {
+        boolean success = performAdd(triple);
+        if (success) {
+            dispatchEvent(new AddEvent(this, triple));
         }
+        return success;
+    }
 
-        return hash;
+    /**
+     * 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 add(Triple e) {
-        throw new UnsupportedOperationException("Graphs are not mutable, use MGraph");
-
+    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 addAll(Collection<? extends Triple> c) {
-        throw new UnsupportedOperationException("Graphs are not mutable, use MGraph");
+    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;
     }
 
-    @Override
-    public boolean remove(Object o) {
-        throw new UnsupportedOperationException("Graphs are not mutable, use MGraph");
+    /**
+     * 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 boolean removeAll(Collection<?> c) {
-        throw new UnsupportedOperationException("Graphs are not mutable, use MGraph");
+    public void addGraphListener(GraphListener listener, FilterTriple filter) {
+        addGraphListener(listener, filter, 0);
     }
 
     @Override
-    public void clear() {
-        throw new UnsupportedOperationException("Graphs are not mutable, use MGraph");
+    public void addGraphListener(GraphListener listener, FilterTriple filter,
+            long delay) {
+        listenerConfigs.add(new ListenerConfiguration(listener, filter));
+        if (delay > 0) {
+            delayedNotificator.addDelayedListener(listener, delay);
+        }
     }
 
     @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
+    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();
+                }
+            }
         }
-        if (!(obj instanceof Graph)) {
-            return false;
+        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;
         }
-        if (hashCode() != obj.hashCode()) {
-            return false;
+
+        /**
+         * @return the listener
+         */
+        GraphListener getListener() {
+            GraphListener listener = listenerRef.get();
+            return listener;
+        }
+
+        /**
+         * @return the filter
+         */
+        FilterTriple getFilter() {
+            return filter;
         }
-        return GraphMatcher.getValidMapping(this, (Graph) obj) != null;
     }
 }

http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/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
new file mode 100644
index 0000000..9a52c88
--- /dev/null
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/AbstractImmutableGraph.java
@@ -0,0 +1,112 @@
+/*
+ * 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/9ae0a1bc/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
index 6f993f2..55bb2c3 100644
--- 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
@@ -18,19 +18,19 @@
  */
 package org.apache.clerezza.rdf.core.impl;
 
+import org.apache.commons.rdf.ImmutableGraph;
 import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.MGraph;
 
 /**
- * <code>AbstractMGraph</code> is an abstract implementation of <code>MGraph</code> 
+ * <code>AbstractMGraph</code> is an abstract implementation of <code>Graph</code> 
  * implementing the <code>getGraph</code> method.
  *
  * @author reto
  */
-public abstract class AbstractMGraph extends AbstractTripleCollection implements MGraph {
+public abstract class AbstractMGraph extends AbstractGraph implements Graph {
 
     @Override
-    public Graph getGraph() {
-        return new SimpleGraph(this);
+    public ImmutableGraph getImmutableGraph() {
+        return new SimpleImmutableGraph(this);
     }
 }

http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/AbstractTripleCollection.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/AbstractTripleCollection.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/AbstractTripleCollection.java
deleted file mode 100644
index c3528da..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/AbstractTripleCollection.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.TripleCollection;
-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>TripleCollection</code> implementing
- * <code>iterator</code> and <code>contains</code> calling <code>filter</code>.
- *
- * @author reto
- */
-public abstract class AbstractTripleCollection extends AbstractCollection<Triple>
-        implements TripleCollection {
-
-    //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(AbstractTripleCollection.this, currentTriple));
-            }
-        };
-    }
-
-    /**
-     * A subclass of <code>AbstractTripleCollection</code> should override 
-     * this method instead of <code>filter</code> for graph 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>AbstractTripleCollection</code> should override 
-     * this method instead of <code>add</code> for graph 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>AbstractTripleCollection</code> should override 
-     * this method instead of <code>remove</code> for graph 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/9ae0a1bc/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
index 78446b2..bc49042 100644
--- 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
@@ -67,7 +67,7 @@ class DelayedNotificator {
                                 try {
                                     listener.graphChanged(eventsLocal);
                                 } catch (Exception e) {
-                                    log.warn("Exception delivering graph event", e);
+                                    log.warn("Exception delivering ImmutableGraph event", e);
                                 }
                             }
                         }

http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/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
index 707f95a..334a7d9 100644
--- 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
@@ -18,61 +18,203 @@
  */
 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.TripleCollection;
 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
  */
-public class SimpleGraph extends AbstractGraph {
+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;
 
-    private TripleCollection tripleCollection;
+        @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 a graph with the triples in tripleCollection
-     * 
-     * @param tripleCollection the collection of triples this Graph shall consist of
+     * Creates an empty SimpleGraph
      */
-    public SimpleGraph(TripleCollection tripleCollection) {
-        this.tripleCollection = new SimpleTripleCollection(tripleCollection.iterator());
+    public SimpleGraph() {
+        triples = Collections.synchronizedSet(new HashSet<Triple>());
     }
 
     /**
-     * Creates a graph with the triples in tripleCollection.
-     *
-     * This construction allows to specify if the tripleCollection might change
-     * in future. If tripleCollectionWillNeverChange 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 tripleCollection the collection of triples this Graph shall consist of
-     * @param tripleCollectionWillNeverChange true if the caller promises tripleCollection will never change
+     * Creates a SimpleGraph using the passed iterator, the iterator 
+     * is consumed before the constructor returns
+     * 
+     * @param iterator
      */
-    public SimpleGraph(TripleCollection tripleCollection, boolean tripleCollectionWillNeverChange) {
-        if (!tripleCollectionWillNeverChange) {
-            this.tripleCollection = new SimpleTripleCollection(tripleCollection.iterator());
-        } else {
-            this.tripleCollection = tripleCollection;
+    public SimpleGraph(Iterator<Triple> iterator) {
+        triples = new HashSet<Triple>();
+        while (iterator.hasNext()) {
+            Triple triple = iterator.next();
+            triples.add(triple);
         }
     }
-    
-    public SimpleGraph(Iterator<Triple> tripleIter) {
-        this.tripleCollection = new SimpleTripleCollection(tripleIter);
+
+    /**
+     * 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 tripleCollection.size();
+        return triples.size();
     }
 
     @Override
-    public Iterator<Triple> performFilter(BlankNodeOrIri subject, Iri predicate, RdfTerm object) {
-        return tripleCollection.filter(subject, predicate, object);
+    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/9ae0a1bc/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
new file mode 100644
index 0000000..d0c6a61
--- /dev/null
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleImmutableGraph.java
@@ -0,0 +1,78 @@
+/*
+ * 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);
+    }
+}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleMGraph.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleMGraph.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleMGraph.java
index a27f395..19a4b72 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleMGraph.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleMGraph.java
@@ -22,15 +22,15 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.Set;
 
+import org.apache.commons.rdf.ImmutableGraph;
 import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.MGraph;
 import org.apache.commons.rdf.Triple;
 
 /**
  *
  * @author reto
  */
-public class SimpleMGraph extends SimpleTripleCollection implements MGraph {
+public class SimpleMGraph extends SimpleGraph implements Graph {
 
     /**
      * Creates an empty SimpleMGraph
@@ -50,10 +50,6 @@ public class SimpleMGraph extends SimpleTripleCollection implements MGraph {
         super(iterator);
     }
 
-    @Override
-    public Graph getGraph() {
-        return new SimpleGraph(this);
-    }
 }
 
     
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleTripleCollection.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleTripleCollection.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleTripleCollection.java
deleted file mode 100644
index 124f0ff..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleTripleCollection.java
+++ /dev/null
@@ -1,213 +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.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 SimpleTripleCollection extends AbstractTripleCollection {
-
-    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 SimpleTripleCollection
-     */
-    public SimpleTripleCollection() {
-        triples = Collections.synchronizedSet(new HashSet<Triple>());
-    }
-
-    /**
-     * Creates a SimpleTripleCollection using the passed iterator, the iterator 
-     * is consumed before the constructor returns
-     * 
-     * @param iterator
-     */
-    public SimpleTripleCollection(Iterator<Triple> iterator) {
-        triples = new HashSet<Triple>();
-        while (iterator.hasNext()) {
-            Triple triple = iterator.next();
-            triples.add(triple);
-        }
-    }
-
-    /**
-     * Creates a SimpleTripleCollection for the specified set of triples, 
-     * subsequent modification of baseSet do affect the created instance.
-     * 
-     * @param baseSet
-     */
-    public SimpleTripleCollection(Set<Triple> baseSet) {
-        this.triples = baseSet;
-    }
-
-    /**
-     * Creates a SimpleTripleCollection for the specified collection of triples,
-     * subsequent modification of baseSet do not affect the created instance.
-     *
-     * @param baseSet
-     */
-    public SimpleTripleCollection(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<SimpleTripleCollection.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;
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedGraph.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedGraph.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedGraph.java
new file mode 100644
index 0000000..7812a76
--- /dev/null
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedGraph.java
@@ -0,0 +1,137 @@
+/*
+ * 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.AbstractCollection;
+import java.util.Collection;
+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;
+import org.apache.clerezza.rdf.core.access.ReadOnlyException;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.event.FilterTriple;
+import org.apache.commons.rdf.event.GraphListener;
+
+/**
+ *
+ * This is a wrapper object for <code>Graph</code>. If <code>SecurityManger</code> 
+ * is not <code>null</code> <code>TcManager</code> checks the <code>TcPermission</code>. 
+ * If read-only permissions are set this wrapper is used instead of <code>Graph</code> 
+ * and throws exceptions when add or remove methods are called.
+ *
+ * @author tsuy
+ */
+public class WriteBlockedGraph extends AbstractCollection<Triple>
+        implements Graph {
+
+    private Graph triples;
+
+    public WriteBlockedGraph(Graph triples) {
+        this.triples = triples;
+    }
+
+    @Override
+    public int size() {
+        return triples.size();
+    }
+
+    @Override
+    public Iterator<Triple> filter(final BlankNodeOrIri subject, final Iri predicate, final RdfTerm object) {
+        final Iterator<Triple> baseIter = triples.filter(subject, predicate, object);
+        return new Iterator<Triple>() {
+            
+            @Override
+            public boolean hasNext() {
+                return baseIter.hasNext();
+            }
+
+            @Override
+            public Triple next() {
+                return baseIter.next();
+            }
+
+            @Override
+            public void remove() {
+                throw new ReadOnlyException("remove");
+            }
+
+            
+        };
+    }
+
+    @Override
+    public boolean add(Triple e) {
+        throw new ReadOnlyException("add");
+    }
+
+    @Override
+    public boolean addAll(Collection<? extends Triple> c) {
+        throw new ReadOnlyException("add all");
+    }
+
+    @Override
+    public void clear() {
+        throw new ReadOnlyException("clear");
+    }
+
+    @Override
+    public boolean remove(Object o) {
+        throw new ReadOnlyException("remove");
+    }
+
+    @Override
+    public boolean removeAll(Collection<?> c) {
+        throw new ReadOnlyException("remove all");
+    }
+    
+    @Override
+    public boolean retainAll(Collection<?> c) {
+        throw new ReadOnlyException("retain all");
+    }
+
+    @Override
+    public void addGraphListener(GraphListener listener, FilterTriple filter,
+            long delay) {
+        triples.addGraphListener(listener, filter, delay);
+    }
+
+    @Override
+    public void addGraphListener(GraphListener listener, FilterTriple filter) {
+        triples.addGraphListener(listener, filter);
+    }
+
+    @Override
+    public void removeGraphListener(GraphListener listener) {
+        triples.removeGraphListener(listener);
+    }
+
+    @Override
+    public Iterator iterator() {
+        return filter(null, null, null);
+    }
+    
+    @Override
+    public ImmutableGraph getImmutableGraph() {
+        return this.triples.getImmutableGraph();
+    }
+}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedMGraph.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedMGraph.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedMGraph.java
index 6ed3e06..129a803 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedMGraph.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedMGraph.java
@@ -19,38 +19,33 @@
 package org.apache.clerezza.rdf.core.impl;
 
 import java.util.concurrent.locks.ReadWriteLock;
-import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.ImmutableGraph;
 import org.apache.clerezza.rdf.core.access.LockableMGraph;
 
 
 /**
 *
-* This is a wrapper object for <code>MGraph</code>. If <code>SecurityManger</code> 
+* This is a wrapper object for <code>Graph</code>. If <code>SecurityManger</code> 
 * is not <code>null</code> <code>TcManager</code> checks the <code>TcPermission</code>. 
-* If read-only permissions are set this wrapper is used instead of <code>MGraph</code>.
+* If read-only permissions are set this wrapper is used instead of <code>Graph</code>.
 *
 * @author tsuy
 */
-public class WriteBlockedMGraph extends WriteBlockedTripleCollection 
+public class WriteBlockedMGraph extends WriteBlockedGraph 
         implements LockableMGraph {
 
-    private LockableMGraph mGraph;
+    private LockableMGraph graph;
     /**
      * Creates a wrapper of <code>SimpleMGraph</code>
      */
-    public WriteBlockedMGraph(LockableMGraph mGraph) {
-        super(mGraph);
-        this.mGraph = mGraph;
-    }
-
-    @Override
-    public Graph getGraph() {
-        return this.mGraph.getGraph();
+    public WriteBlockedMGraph(LockableMGraph graph) {
+        super(graph);
+        this.graph = graph;
     }
 
     @Override
     public ReadWriteLock getLock() {
-        return mGraph.getLock();
+        return graph.getLock();
     }
 }
 

http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedTripleCollection.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedTripleCollection.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedTripleCollection.java
deleted file mode 100644
index 19a7271..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedTripleCollection.java
+++ /dev/null
@@ -1,131 +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.AbstractCollection;
-import java.util.Collection;
-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.TripleCollection;
-import org.apache.commons.rdf.Iri;
-import org.apache.clerezza.rdf.core.access.ReadOnlyException;
-import org.apache.commons.rdf.event.FilterTriple;
-import org.apache.commons.rdf.event.GraphListener;
-
-/**
- *
- * This is a wrapper object for <code>TripleCollection</code>. If <code>SecurityManger</code> 
- * is not <code>null</code> <code>TcManager</code> checks the <code>TcPermission</code>. 
- * If read-only permissions are set this wrapper is used instead of <code>TripleCollection</code> 
- * and throws exceptions when add or remove methods are called.
- *
- * @author tsuy
- */
-public class WriteBlockedTripleCollection extends AbstractCollection<Triple>
-        implements TripleCollection {
-
-    private TripleCollection triples;
-
-    public WriteBlockedTripleCollection(TripleCollection triples) {
-        this.triples = triples;
-    }
-
-    @Override
-    public int size() {
-        return triples.size();
-    }
-
-    @Override
-    public Iterator<Triple> filter(final BlankNodeOrIri subject, final Iri predicate, final RdfTerm object) {
-        final Iterator<Triple> baseIter = triples.filter(subject, predicate, object);
-        return new Iterator<Triple>() {
-            
-            @Override
-            public boolean hasNext() {
-                return baseIter.hasNext();
-            }
-
-            @Override
-            public Triple next() {
-                return baseIter.next();
-            }
-
-            @Override
-            public void remove() {
-                throw new ReadOnlyException("remove");
-            }
-
-            
-        };
-    }
-
-    @Override
-    public boolean add(Triple e) {
-        throw new ReadOnlyException("add");
-    }
-
-    @Override
-    public boolean addAll(Collection<? extends Triple> c) {
-        throw new ReadOnlyException("add all");
-    }
-
-    @Override
-    public void clear() {
-        throw new ReadOnlyException("clear");
-    }
-
-    @Override
-    public boolean remove(Object o) {
-        throw new ReadOnlyException("remove");
-    }
-
-    @Override
-    public boolean removeAll(Collection<?> c) {
-        throw new ReadOnlyException("remove all");
-    }
-    
-    @Override
-    public boolean retainAll(Collection<?> c) {
-        throw new ReadOnlyException("retain all");
-    }
-
-    @Override
-    public void addGraphListener(GraphListener listener, FilterTriple filter,
-            long delay) {
-        triples.addGraphListener(listener, filter, delay);
-    }
-
-    @Override
-    public void addGraphListener(GraphListener listener, FilterTriple filter) {
-        triples.addGraphListener(listener, filter);
-    }
-
-    @Override
-    public void removeGraphListener(GraphListener listener) {
-        triples.removeGraphListener(listener);
-    }
-
-    @Override
-    public Iterator iterator() {
-        return filter(null, null, null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/GraphMatcher.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/GraphMatcher.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/GraphMatcher.java
index eced71e..2ea5389 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/GraphMatcher.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/GraphMatcher.java
@@ -26,9 +26,9 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.MGraph;
+import org.apache.commons.rdf.Graph;
 import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.TripleCollection;
+import org.apache.commons.rdf.Graph;
 import org.apache.commons.rdf.RdfTerm;
 import org.apache.commons.rdf.Triple;
 import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
@@ -49,7 +49,7 @@ public class GraphMatcher {
      * get a mapping from g1 to g2 or null if the graphs are not isomorphic. The
      * returned map maps each <code>BNode</code>s from g1 to one
      * of g2. If the graphs are ground graphs the method return an empty map if
-     * the graph are equals and null otherwise.
+     * the ImmutableGraph are equals and null otherwise.
      * <p/>
      * NOTE: This method does not returned mapping from blank nodes to grounded
      * nodes, a bnode in g1 is not a vraiable that may match any node, but must
@@ -72,9 +72,9 @@ public class GraphMatcher {
      * @param g2
      * @return a Set of NodePairs
      */
-    public static Map<BlankNode, BlankNode> getValidMapping(TripleCollection og1, TripleCollection og2) {
-        MGraph g1 = new SimpleMGraph(og1);
-        MGraph g2 = new SimpleMGraph(og2);
+    public static Map<BlankNode, BlankNode> getValidMapping(Graph og1, Graph og2) {
+        Graph g1 = new SimpleMGraph(og1);
+        Graph g2 = new SimpleMGraph(og2);
         if (!Utils.removeGrounded(g1,g2)) {
             return null;
         }
@@ -100,7 +100,7 @@ public class GraphMatcher {
         return matchings;
     }
 
-    private static Map<BlankNode, BlankNode> trialAndErrorMatching(MGraph g1, MGraph g2,
+    private static Map<BlankNode, BlankNode> trialAndErrorMatching(Graph g1, Graph g2,
             Map<Set<BlankNode>, Set<BlankNode>> matchingGroups) {
         if (log.isDebugEnabled()) {
             Set<BlankNode> bn1  = Utils.getBNodes(g1);
@@ -118,7 +118,7 @@ public class GraphMatcher {
         return null;
     }
 
-    private static boolean checkMapping(MGraph g1, MGraph g2, Map<BlankNode, BlankNode> map) {
+    private static boolean checkMapping(Graph g1, Graph g2, Map<BlankNode, BlankNode> map) {
         for (Triple triple : g1) {
             if (!g2.contains(map(triple, map))) {
                 return false;

http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/HashMatching.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/HashMatching.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/HashMatching.java
index b5289e6..7b3d540 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/HashMatching.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/HashMatching.java
@@ -27,11 +27,11 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.MGraph;
+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.TripleCollection;
+import org.apache.commons.rdf.Graph;
 import org.apache.commons.rdf.Iri;
 import org.apache.clerezza.rdf.core.impl.TripleImpl;
 import org.apache.clerezza.rdf.core.impl.graphmatching.collections.IntIterator;
@@ -53,7 +53,7 @@ public class HashMatching {
      * @param tc2
      * @throws GraphNotIsomorphicException
      */
-    HashMatching(MGraph tc1, MGraph tc2) throws GraphNotIsomorphicException {
+    HashMatching(Graph tc1, Graph tc2) throws GraphNotIsomorphicException {
         int foundMatchings = 0;
         int foundMatchingGroups = 0;
         Map<BlankNode, Integer> bNodeHashMap = new HashMap<BlankNode, Integer>();
@@ -101,14 +101,14 @@ public class HashMatching {
     }
     /*
      * returns a Map from bnodes to hash that can be used for future
-     * refinements, this could be separate for each graph.
+     * refinements, this could be separate for each ImmutableGraph.
      *
      * triples no longer containing an unmatched bnodes ae removed.
      *
      * Note that the matched node are not guaranteed to be equals, but only to
      * be the correct if the graphs are isomorphic.
      */
-    private Map<BlankNode, Integer> matchByHashes(MGraph g1, MGraph g2,
+    private Map<BlankNode, Integer> matchByHashes(Graph g1, Graph g2,
             Map<BlankNode, Integer> bNodeHashMap) {
         Map<BlankNode, Set<Property>> bNodePropMap1  = getBNodePropMap(g1);
         Map<BlankNode, Set<Property>> bNodePropMap2  = getBNodePropMap(g2);
@@ -155,7 +155,7 @@ public class HashMatching {
         }
         return result;
     }
-    private static Map<BlankNode, Set<Property>> getBNodePropMap(MGraph g) {
+    private static Map<BlankNode, Set<Property>> getBNodePropMap(Graph g) {
         Set<BlankNode> bNodes = Utils.getBNodes(g);
         Map<BlankNode, Set<Property>> result = new HashMap<BlankNode, Set<Property>>();
         for (BlankNode bNode : bNodes) {
@@ -163,7 +163,7 @@ public class HashMatching {
         }
         return result;
     }
-    private static Set<Property> getProperties(BlankNode bNode, MGraph g) {
+    private static Set<Property> getProperties(BlankNode bNode, Graph g) {
         Set<Property> result = new HashSet<Property>();
         Iterator<Triple> ti = g.filter(bNode, null, null);
         while (ti.hasNext()) {
@@ -189,16 +189,16 @@ public class HashMatching {
             return resource.hashCode();
         }
     }
-    private static void replaceNode(MGraph mGraph, BlankNode bNode, BlankNodeOrIri replacementNode) {
+    private static void replaceNode(Graph graph, BlankNode bNode, BlankNodeOrIri replacementNode) {
         Set<Triple> triplesToRemove = new HashSet<Triple>();
-        for (Triple triple : mGraph) {
+        for (Triple triple : graph) {
             Triple replacementTriple = getReplacement(triple, bNode, replacementNode);
             if (replacementTriple != null) {
                 triplesToRemove.add(triple);
-                mGraph.add(replacementTriple);
+                graph.add(replacementTriple);
             }
         }
-        mGraph.removeAll(triplesToRemove);
+        graph.removeAll(triplesToRemove);
     }
     private static Triple getReplacement(Triple triple, BlankNode bNode, BlankNodeOrIri replacementNode) {
         if (triple.getSubject().equals(bNode)) {

http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedGraphWrapper.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedGraphWrapper.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedGraphWrapper.java
index 8236e75..97547c0 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedGraphWrapper.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedGraphWrapper.java
@@ -18,19 +18,253 @@
  */
 package org.apache.clerezza.rdf.core.impl.util;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collection;
+import java.util.Iterator;
+import org.apache.clerezza.rdf.core.impl.SimpleImmutableGraph;
+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.ImmutableGraph;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.event.FilterTriple;
+import org.apache.commons.rdf.event.GraphListener;
 
 /**
  * Calls the methods of the wrapped <code>Graph</code> as privileged
  * code, because they may need permissions like writing to disk or accessing       
  * network.
- * 
+ *
  * @author mir
  */
-public class PrivilegedGraphWrapper extends PrivilegedTripleCollectionWrapper
-        implements Graph {
+public class PrivilegedGraphWrapper implements Graph {
+
+    private Graph graph;
+
+    public PrivilegedGraphWrapper(Graph Graph) {
+        this.graph = Graph;
+    }
+
+    @Override
+    public Iterator<Triple> filter(final BlankNodeOrIri subject, final Iri predicate,
+            final RdfTerm object) {
+        return AccessController.doPrivileged(new PrivilegedAction<Iterator<Triple>>() {
+
+            @Override
+            public Iterator<Triple> run() {
+                return graph.filter(subject, predicate, object);
+            }
+        });
+    }
+
+    @Override
+    public int size() {
+        return AccessController.doPrivileged(new PrivilegedAction<Integer>() {
+
+            @Override
+            public Integer run() {
+                return graph.size();
+            }
+        });
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+
+            @Override
+            public Boolean run() {
+                return graph.isEmpty();
+            }
+        });
+    }
+
+    @Override
+    public boolean contains(final Object o) {
+        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+
+            @Override
+            public Boolean run() {
+                return graph.contains(o);
+            }
+        });
+    }
+
+    @Override
+    public Iterator<Triple> iterator() {
+        return AccessController.doPrivileged(new PrivilegedAction<Iterator<Triple>>() {
+
+            @Override
+            public Iterator<Triple> run() {
+                return graph.iterator();
+            }
+        });
+    }
+
+    @Override
+    public Object[] toArray() {
+        return AccessController.doPrivileged(new PrivilegedAction<Object[]>() {
+
+            @Override
+            public Object[] run() {
+                return graph.toArray();
+            }
+        });
+    }
+
+    @Override
+    public <T> T[] toArray(final T[] a) {
+        return AccessController.doPrivileged(new PrivilegedAction<T[]>() {
+
+            @Override
+            public T[] run() {
+                return graph.toArray(a);
+            }
+        });
+    }
+
+    @Override
+    public boolean add(final Triple triple) {
+        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+
+            @Override
+            public Boolean run() {
+                return graph.add(triple);
+            }
+        });
+    }
+
+    @Override
+    public boolean remove(final Object o) {
+        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+
+            @Override
+            public Boolean run() {
+                return graph.remove(o);
+            }
+        });
+    }
+
+    @Override
+    public boolean containsAll(final Collection<?> c) {
+        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+
+            @Override
+            public Boolean run() {
+                return graph.containsAll(c);
+            }
+        });
+    }
+
+    @Override
+    public boolean addAll(final Collection<? extends Triple> c) {
+        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+
+            @Override
+            public Boolean run() {
+                return graph.addAll(c);
+            }
+        });
+    }
+
+    @Override
+    public boolean removeAll(final Collection<?> c) {
+        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+
+            @Override
+            public Boolean run() {
+                return graph.removeAll(c);
+            }
+        });
+    }
+
+    @Override
+    public boolean retainAll(final Collection<?> c) {
+        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+
+            @Override
+            public Boolean run() {
+                return graph.retainAll(c);
+            }
+        });
+    }
+
+    @Override
+    public void clear() {
+        AccessController.doPrivileged(new PrivilegedAction<Object>() {
+
+            @Override
+            public Object run() {
+                graph.clear();
+                return null;
+            }
+        });
+    }
+
+    @Override
+    public void addGraphListener(GraphListener listener, FilterTriple filter, long delay) {
+        graph.addGraphListener(listener, filter, delay);
+    }
+
+    @Override
+    public void addGraphListener(GraphListener listener, FilterTriple filter) {
+        graph.addGraphListener(listener, filter);
+    }
+
+    @Override
+    public void removeGraphListener(GraphListener listener) {
+        graph.removeGraphListener(listener);
+    }
+
+    private static class PriviledgedTripleIterator implements Iterator<Triple> {
+
+        private final Iterator<Triple> wrappedIterator;
+
+        public PriviledgedTripleIterator(Iterator<Triple> wrappedIterator) {
+            this.wrappedIterator = wrappedIterator;
+        }
+
+        @Override
+        public boolean hasNext() {
+            return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+
+                @Override
+                public Boolean run() {
+                    return wrappedIterator.hasNext();
+                }
+            });
+        }
+
+        @Override
+        public Triple next() {
+            return AccessController.doPrivileged(new PrivilegedAction<Triple>() {
+
+                @Override
+                public Triple run() {
+                    return wrappedIterator.next();
+                }
+            });
+        }
+
+        @Override
+        public void remove() {
+            AccessController.doPrivileged(new PrivilegedAction<Object>() {
+
+                @Override
+                public Object run() {
+                    wrappedIterator.remove();
+                    return null;
+                }
+            });
+        }
+    }
+    
+    
 
-    public PrivilegedGraphWrapper(Graph graph) {
-        super(graph);
+    @Override
+    public ImmutableGraph getImmutableGraph() {
+        return new SimpleImmutableGraph(this);
     }
 }

http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedImmuatbleGraphWrapper.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedImmuatbleGraphWrapper.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedImmuatbleGraphWrapper.java
new file mode 100644
index 0000000..fdf0b5a
--- /dev/null
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedImmuatbleGraphWrapper.java
@@ -0,0 +1,36 @@
+/*
+ * 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.util;
+
+import org.apache.commons.rdf.ImmutableGraph;
+
+/**
+ * Calls the methods of the wrapped <code>ImmutableGraph</code> as privileged
+ * code, because they may need permissions like writing to disk or accessing       
+ * network.
+ * 
+ * @author mir
+ */
+public class PrivilegedImmuatbleGraphWrapper extends PrivilegedGraphWrapper
+        implements ImmutableGraph {
+
+    public PrivilegedImmuatbleGraphWrapper(ImmutableGraph ImmutableGraph) {
+        super(ImmutableGraph);
+    }
+}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedMGraphWrapper.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedMGraphWrapper.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedMGraphWrapper.java
deleted file mode 100644
index 4575bea..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedMGraphWrapper.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.clerezza.rdf.core.impl.util;
-
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.MGraph;
-import org.apache.clerezza.rdf.core.impl.SimpleGraph;
-
-/**
- * Calls the methods of the wrapped <code>MGraph</code> as privileged
- * code, because they may need permissions like writing to disk or accessing       
- * network.
- *
- * @author mir
- */
-public class PrivilegedMGraphWrapper extends PrivilegedTripleCollectionWrapper implements MGraph {
-
-    public PrivilegedMGraphWrapper(MGraph wrappedMGraph) {
-        super(wrappedMGraph);
-    }
-
-    @Override
-    public Graph getGraph() {
-        return new SimpleGraph(this);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/9ae0a1bc/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedTripleCollectionWrapper.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedTripleCollectionWrapper.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedTripleCollectionWrapper.java
deleted file mode 100644
index 85a9dbd..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedTripleCollectionWrapper.java
+++ /dev/null
@@ -1,261 +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.util;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Collection;
-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.TripleCollection;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.event.FilterTriple;
-import org.apache.commons.rdf.event.GraphListener;
-
-/**
- * Calls the methods of the wrapped <code>TripleCollection</code> as privileged
- * code, because they may need permissions like writing to disk or accessing       
- * network.
- *
- * @author mir
- */
-public class PrivilegedTripleCollectionWrapper implements TripleCollection {
-
-    private TripleCollection tripleCollection;
-
-    public PrivilegedTripleCollectionWrapper(TripleCollection tripleCollection) {
-        this.tripleCollection = tripleCollection;
-    }
-
-    @Override
-    public Iterator<Triple> filter(final BlankNodeOrIri subject, final Iri predicate,
-            final RdfTerm object) {
-        return AccessController.doPrivileged(new PrivilegedAction<Iterator<Triple>>() {
-
-            @Override
-            public Iterator<Triple> run() {
-                return tripleCollection.filter(subject, predicate, object);
-            }
-        });
-    }
-
-    @Override
-    public int size() {
-        return AccessController.doPrivileged(new PrivilegedAction<Integer>() {
-
-            @Override
-            public Integer run() {
-                return tripleCollection.size();
-            }
-        });
-    }
-
-    @Override
-    public boolean isEmpty() {
-        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-
-            @Override
-            public Boolean run() {
-                return tripleCollection.isEmpty();
-            }
-        });
-    }
-
-    @Override
-    public boolean contains(final Object o) {
-        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-
-            @Override
-            public Boolean run() {
-                return tripleCollection.contains(o);
-            }
-        });
-    }
-
-    @Override
-    public Iterator<Triple> iterator() {
-        return AccessController.doPrivileged(new PrivilegedAction<Iterator<Triple>>() {
-
-            @Override
-            public Iterator<Triple> run() {
-                return tripleCollection.iterator();
-            }
-        });
-    }
-
-    @Override
-    public Object[] toArray() {
-        return AccessController.doPrivileged(new PrivilegedAction<Object[]>() {
-
-            @Override
-            public Object[] run() {
-                return tripleCollection.toArray();
-            }
-        });
-    }
-
-    @Override
-    public <T> T[] toArray(final T[] a) {
-        return AccessController.doPrivileged(new PrivilegedAction<T[]>() {
-
-            @Override
-            public T[] run() {
-                return tripleCollection.toArray(a);
-            }
-        });
-    }
-
-    @Override
-    public boolean add(final Triple triple) {
-        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-
-            @Override
-            public Boolean run() {
-                return tripleCollection.add(triple);
-            }
-        });
-    }
-
-    @Override
-    public boolean remove(final Object o) {
-        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-
-            @Override
-            public Boolean run() {
-                return tripleCollection.remove(o);
-            }
-        });
-    }
-
-    @Override
-    public boolean containsAll(final Collection<?> c) {
-        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-
-            @Override
-            public Boolean run() {
-                return tripleCollection.containsAll(c);
-            }
-        });
-    }
-
-    @Override
-    public boolean addAll(final Collection<? extends Triple> c) {
-        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-
-            @Override
-            public Boolean run() {
-                return tripleCollection.addAll(c);
-            }
-        });
-    }
-
-    @Override
-    public boolean removeAll(final Collection<?> c) {
-        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-
-            @Override
-            public Boolean run() {
-                return tripleCollection.removeAll(c);
-            }
-        });
-    }
-
-    @Override
-    public boolean retainAll(final Collection<?> c) {
-        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-
-            @Override
-            public Boolean run() {
-                return tripleCollection.retainAll(c);
-            }
-        });
-    }
-
-    @Override
-    public void clear() {
-        AccessController.doPrivileged(new PrivilegedAction<Object>() {
-
-            @Override
-            public Object run() {
-                tripleCollection.clear();
-                return null;
-            }
-        });
-    }
-
-    @Override
-    public void addGraphListener(GraphListener listener, FilterTriple filter, long delay) {
-        tripleCollection.addGraphListener(listener, filter, delay);
-    }
-
-    @Override
-    public void addGraphListener(GraphListener listener, FilterTriple filter) {
-        tripleCollection.addGraphListener(listener, filter);
-    }
-
-    @Override
-    public void removeGraphListener(GraphListener listener) {
-        tripleCollection.removeGraphListener(listener);
-    }
-
-    private static class PriviledgedTripleIterator implements Iterator<Triple> {
-
-        private final Iterator<Triple> wrappedIterator;
-
-        public PriviledgedTripleIterator(Iterator<Triple> wrappedIterator) {
-            this.wrappedIterator = wrappedIterator;
-        }
-
-        @Override
-        public boolean hasNext() {
-            return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
-
-                @Override
-                public Boolean run() {
-                    return wrappedIterator.hasNext();
-                }
-            });
-        }
-
-        @Override
-        public Triple next() {
-            return AccessController.doPrivileged(new PrivilegedAction<Triple>() {
-
-                @Override
-                public Triple run() {
-                    return wrappedIterator.next();
-                }
-            });
-        }
-
-        @Override
-        public void remove() {
-            AccessController.doPrivileged(new PrivilegedAction<Object>() {
-
-                @Override
-                public Object run() {
-                    wrappedIterator.remove();
-                    return null;
-                }
-            });
-        }
-    }
-}


Mime
View raw message