jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1205913 - in /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk: ./ model/ store/ store/util/
Date Thu, 24 Nov 2011 16:24:58 GMT
Author: stefan
Date: Thu Nov 24 16:24:54 2011
New Revision: 1205913

URL: http://svn.apache.org/viewvc?rev=1205913&view=rev
Log:
refactoring: 
- cleanup package structure
- use AbstractPersistenceManager as base for experimental storage engines
- misc. minor improvements

Added:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/AbstractCommit.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/AbstractNode.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/Commit.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
      - copied, changed from r1202102, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/MutableCommit.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/MutableNode.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/Node.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeDelta.java
      - copied, changed from r1202102, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeDelta.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeDiffHandler.java
      - copied, changed from r1202102, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeDiffHandler.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeProxy.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeUtils.java
      - copied, changed from r1202102, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeUtils.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/StoredCommit.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/StoredNode.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/util/
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/util/Constants.java
      - copied, changed from r1202102, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Constants.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/util/PersistentId.java
      - copied, changed from r1205778, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/PersistentId.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/util/Serializer.java
Removed:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/AbstractRevisionStore.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/BDbRevisionStore.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Blob.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Commit.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Constants.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/FatNode.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/FatNodePart.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/H2RevisionStore.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/MongoRevisionStore.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/MutableCommit.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/MutableNode.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Node.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeDelta.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeDiffHandler.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeTree.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeUtils.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/PersistenceManager.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/PersistentId.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/SimpleRevisionStore.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/StoredObject.java
Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/RevisionStore.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java?rev=1205913&r1=1205912&r2=1205913&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java Thu Nov 24 16:24:54 2011
@@ -20,11 +20,13 @@ import org.apache.jackrabbit.mk.api.Micr
 import org.apache.jackrabbit.mk.api.MicroKernelException;
 import org.apache.jackrabbit.mk.json.JsopBuilder;
 import org.apache.jackrabbit.mk.json.JsopTokenizer;
-import org.apache.jackrabbit.mk.store.Commit;
-import org.apache.jackrabbit.mk.store.CommitBuilder;
-import org.apache.jackrabbit.mk.store.Node;
-import org.apache.jackrabbit.mk.store.NodeDiffHandler;
-import org.apache.jackrabbit.mk.store.NodeUtils;
+import org.apache.jackrabbit.mk.model.Commit;
+import org.apache.jackrabbit.mk.model.CommitBuilder;
+import org.apache.jackrabbit.mk.model.Node;
+import org.apache.jackrabbit.mk.model.NodeDiffHandler;
+import org.apache.jackrabbit.mk.model.NodeUtils;
+import org.apache.jackrabbit.mk.model.StoredCommit;
+import org.apache.jackrabbit.mk.model.StoredNode;
 import org.apache.jackrabbit.mk.store.NotFoundException;
 import org.apache.jackrabbit.mk.util.CommitGate;
 import org.apache.jackrabbit.mk.util.PathUtils;
@@ -90,9 +92,9 @@ public class MicroKernelImpl implements 
             throw new IllegalStateException("this instance has already been disposed");
         }
         maxEntries = maxEntries < 0 ? Integer.MAX_VALUE : maxEntries;
-        List<Commit> history = new ArrayList<Commit>();
+        List<StoredCommit> history = new ArrayList<StoredCommit>();
         try {
-            Commit commit = rep.getHeadCommit();
+            StoredCommit commit = rep.getHeadCommit();
             while (commit != null
                     && history.size() < maxEntries
                     && commit.getCommitTS() >= since) {
@@ -110,7 +112,7 @@ public class MicroKernelImpl implements 
 
         JsopBuilder buff = new JsopBuilder().array();
         for (int i = history.size() - 1; i >= 0; i--) {
-            Commit commit = history.get(i);
+            StoredCommit commit = history.get(i);
             buff.object().
                     key("id").value(commit.getId()).
                     key("ts").value(commit.getCommitTS()).
@@ -128,9 +130,9 @@ public class MicroKernelImpl implements 
             throw new IllegalStateException("this instance has already been disposed");
         }
 
-        List<Commit> commits = new ArrayList<Commit>();
+        List<StoredCommit> commits = new ArrayList<StoredCommit>();
         try {
-            Commit toCommit = rep.getCommit(toRevisionId);
+            StoredCommit toCommit = rep.getCommit(toRevisionId);
 
             Commit fromCommit;
             if (toRevisionId.equals(fromRevisionId)) {
@@ -146,7 +148,7 @@ public class MicroKernelImpl implements 
             // collect commits, starting with toRevisionId
             // and traversing parent commit links until we've reached
             // fromRevisionId
-            Commit commit = toCommit;
+            StoredCommit commit = toCommit;
             while (commit != null) {
                 commits.add(commit);
                 if (commit.getId().equals(fromRevisionId)) {
@@ -166,7 +168,7 @@ public class MicroKernelImpl implements 
         // iterate over commits in chronological order,
         // starting with oldest commit
         for (int i = commits.size() - 1; i >= 0; i--) {
-            Commit commit = commits.get(i);
+            StoredCommit commit = commits.get(i);
             if (commit.getParentId() == null) {
                 continue;
             }
@@ -196,7 +198,7 @@ public class MicroKernelImpl implements 
             // to detect 'move' operations
             final HashMap<String, String> addedNodes = new HashMap<String, String>();
             final HashMap<String, String> removedNodes = new HashMap<String, String>();
-            Node node1, node2;
+            StoredNode node1, node2;
             try {
                 node1 = rep.getNode(fromRevisionId, path);
             } catch (NotFoundException e) {
@@ -222,7 +224,7 @@ public class MicroKernelImpl implements 
                 return buff.newline().toString();
             }
 
-            NodeUtils.diff(path, node1, node2, true, rep.getPersistenceManager(), new NodeDiffHandler() {
+            NodeUtils.diff(path, node1, node2, true, rep.getRevisionStore(), new NodeDiffHandler() {
                 public void propAdded(String nodePath, String propName, String value) {
                     buff.tag('+').
                             key(PathUtils.concat(nodePath, propName)).
@@ -252,7 +254,7 @@ public class MicroKernelImpl implements 
                     buff.tag('+').
                             key(PathUtils.concat(nodePath, childName)).object();
                     try {
-                        toJson(buff, rep.getPersistenceManager().getNode(id), Integer.MAX_VALUE, 0, -1, false);
+                        toJson(buff, rep.getRevisionStore().getNode(id), Integer.MAX_VALUE, 0, -1, false);
                     } catch (Exception e) {
                         buff.value("ERROR: failed to retrieve node " + id);
                     }
@@ -283,7 +285,7 @@ public class MicroKernelImpl implements 
                 buff.reset();
 
                 // TODO refactor code, avoid duplication
-                NodeUtils.diff(path, node1, node2, true, rep.getPersistenceManager(), new NodeDiffHandler() {
+                NodeUtils.diff(path, node1, node2, true, rep.getRevisionStore(), new NodeDiffHandler() {
                     public void propAdded(String nodePath, String propName, String value) {
                         buff.tag('+').
                                 key(PathUtils.concat(nodePath, propName)).
@@ -316,7 +318,7 @@ public class MicroKernelImpl implements 
                         buff.tag('+').
                                 key(PathUtils.concat(nodePath, childName)).object();
                         try {
-                            toJson(buff, rep.getPersistenceManager().getNode(id), Integer.MAX_VALUE, 0, -1, false);
+                            toJson(buff, rep.getRevisionStore().getNode(id), Integer.MAX_VALUE, 0, -1, false);
                         } catch (Exception e) {
                             buff.value("ERROR: failed to retrieve node " + id);
                         }
@@ -455,7 +457,7 @@ public class MicroKernelImpl implements 
             throw new IllegalStateException("this instance has already been disposed");
         }
         try {
-            return rep.getPersistenceManager().getBlobLength(blobId);
+            return rep.getRevisionStore().getBlobLength(blobId);
         } catch (Exception e) {
             throw new MicroKernelException(e);
         }
@@ -466,7 +468,7 @@ public class MicroKernelImpl implements 
             throw new IllegalStateException("this instance has already been disposed");
         }
         try {
-            return rep.getPersistenceManager().readBlob(blobId, pos, buff, off, length);
+            return rep.getRevisionStore().getBlob(blobId, pos, buff, off, length);
         } catch (Exception e) {
             throw new MicroKernelException(e);
         }
@@ -477,7 +479,7 @@ public class MicroKernelImpl implements 
             throw new IllegalStateException("this instance has already been disposed");
         }
         try {
-            return rep.getPersistenceManager().writeBlob(in);
+            return rep.getRevisionStore().putBlob(in);
         } catch (Exception e) {
             throw new MicroKernelException(e);
         }
@@ -504,7 +506,7 @@ public class MicroKernelImpl implements 
                     builder.key(childName).object();
                     if (depth > 0) {
                         String childId = child.getValue();
-                        toJson(builder, rep.getPersistenceManager().getNode(childId), depth - 1, 0, -1, inclVirtualProps);
+                        toJson(builder, rep.getRevisionStore().getNode(childId), depth - 1, 0, -1, inclVirtualProps);
                     }
                     builder.endObject();
                 }

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java?rev=1205913&r1=1205912&r2=1205913&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/Repository.java Thu Nov 24 16:24:54 2011
@@ -17,15 +17,17 @@
 package org.apache.jackrabbit.mk;
 
 import java.io.File;
-import org.apache.jackrabbit.mk.blobs.BlobStore;
-import org.apache.jackrabbit.mk.blobs.FileBlobStore;
-import org.apache.jackrabbit.mk.store.Commit;
-import org.apache.jackrabbit.mk.store.CommitBuilder;
-import org.apache.jackrabbit.mk.store.H2RevisionStore;
-import org.apache.jackrabbit.mk.store.MongoRevisionStore;
-import org.apache.jackrabbit.mk.store.Node;
+import org.apache.jackrabbit.mk.model.Commit;
+import org.apache.jackrabbit.mk.model.CommitBuilder;
+import org.apache.jackrabbit.mk.model.Node;
+import org.apache.jackrabbit.mk.model.StoredCommit;
+import org.apache.jackrabbit.mk.model.StoredNode;
+import org.apache.jackrabbit.mk.store.AbstractPersistenceManager;
+import org.apache.jackrabbit.mk.store.BDbPersistenceManager;
+import org.apache.jackrabbit.mk.store.FSPersistenceManager;
+import org.apache.jackrabbit.mk.store.H2PersistenceManager;
+import org.apache.jackrabbit.mk.store.MongoPersistenceManager;
 import org.apache.jackrabbit.mk.store.NotFoundException;
-import org.apache.jackrabbit.mk.store.PersistenceManager;
 import org.apache.jackrabbit.mk.store.RevisionStore;
 import org.apache.jackrabbit.mk.util.PathUtils;
 
@@ -37,7 +39,7 @@ public class Repository {
     final String homeDir;
     boolean initialized;
 
-    final PersistenceManager pm;
+    final AbstractPersistenceManager pm;
 
     public Repository(String homeDir) throws Exception {
         File home = new File(homeDir == null ? "." : homeDir, ".mk");
@@ -45,7 +47,12 @@ public class Repository {
             home.mkdirs();
         }
         this.homeDir = home.getCanonicalPath();
-        pm = new PersistenceManager();
+
+        //pm = new MongoPersistenceManager();
+        pm = new H2PersistenceManager();
+        //pm = new BDbPersistenceManager();
+        //pm = new FSPersistenceManager();
+
         initialized = false;
     }
 
@@ -55,22 +62,7 @@ public class Repository {
         }
 
         File home = new File(homeDir);
-
-        //RevisionStore revStore = new MongoRevisionStore();
-        RevisionStore revStore = new H2RevisionStore();
-        //RevisionStore revStore = new SimpleRevisionStore();
-        //RevisionStore revStore = new BDbRevisionStore();
-        revStore.initialize(home);
-
-        BlobStore blobStore;
-        //if (revStore instanceof BlobStore) {
-        if (false) {
-            blobStore = (BlobStore) revStore;
-        } else {
-            blobStore = new FileBlobStore(new File(home, "blobs").getCanonicalPath());
-        }
-
-        pm.initialize(revStore, blobStore);
+        pm.initialize(home);
 
         initialized = true;
     }
@@ -85,7 +77,7 @@ public class Repository {
         initialized = false;
     }
 
-    public PersistenceManager getPersistenceManager() {
+    public RevisionStore getRevisionStore() {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
@@ -100,14 +92,14 @@ public class Repository {
         return pm.getHeadCommitId();
     }
 
-    public Commit getHeadCommit() throws Exception {
+    public StoredCommit getHeadCommit() throws Exception {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
         return pm.getHeadCommit();
     }
 
-    public Commit getCommit(String id) throws NotFoundException, Exception {
+    public StoredCommit getCommit(String id) throws NotFoundException, Exception {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
@@ -122,11 +114,17 @@ public class Repository {
      * @throws NotFoundException if either path or revision doesn't exist
      * @throws Exception if another error occurs
      */
-    public Node getNode(String revId, String path) throws NotFoundException, Exception {
+    public StoredNode getNode(String revId, String path) throws NotFoundException, Exception {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
 
+        StoredNode root = pm.getRootNode(revId);
+        if (PathUtils.denotesRoot(path)) {
+            return root;
+        }
+
+        //return root.getNode(path.substring(1), pm);
         String[] ids = resolvePath(revId, path);
         return pm.getNode(ids[ids.length - 1]);
     }
@@ -142,7 +140,7 @@ public class Repository {
 
         try {
             String[] names = PathUtils.split(path);
-            Node parent = pm.getNode(pm.getCommit(revId).getRootNodeId());
+            Node parent = pm.getRootNode(revId);
             for (int i = 0; i < names.length; i++) {
                 String id = parent.getChildNodeEntries().get(names[i]);
                 if (id == null) {
@@ -157,7 +155,7 @@ public class Repository {
     }
 
     public CommitBuilder getCommitBuilder(String revId, String msg) throws Exception {
-        return new CommitBuilder(revId, msg, this);
+        return new CommitBuilder(revId, msg, pm);
 
     }
 

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/AbstractCommit.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/AbstractCommit.java?rev=1205913&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/AbstractCommit.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/AbstractCommit.java Thu Nov 24 16:24:54 2011
@@ -0,0 +1,51 @@
+/*
+ * 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.jackrabbit.mk.model;
+
+/**
+ *
+ */
+public abstract class AbstractCommit implements Commit {
+
+    // id of root node associated with this commit
+    protected String rootNodeId;
+
+    // commit timestamp
+    protected long commitTS;
+
+    // commit message
+    protected String msg;
+
+    // id of parent commit
+    protected String parentId;
+
+    public String getParentId() {
+        return parentId;
+    }
+
+    public String getRootNodeId() {
+        return rootNodeId;
+    }
+
+    public long getCommitTS() {
+        return commitTS;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/AbstractNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/AbstractNode.java?rev=1205913&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/AbstractNode.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/AbstractNode.java Thu Nov 24 16:24:54 2011
@@ -0,0 +1,158 @@
+/*
+ * 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.jackrabbit.mk.model;
+
+import org.apache.jackrabbit.mk.store.RevisionProvider;
+import org.apache.jackrabbit.mk.store.NotFoundException;
+import org.apache.jackrabbit.mk.util.PathUtils;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ *
+ */
+public abstract class AbstractNode implements Node {
+
+    final protected Map<String, String> properties;
+
+    // map keeping insertion order
+    //final protected LinkedHashMap<String, Node> children;
+    final protected LinkedHashMap<String, String> childEntries;
+
+    public AbstractNode() {
+        this.properties = new HashMap<String, String>();
+        //this.children = new LinkedHashMap<String, Node>();
+        this.childEntries = new LinkedHashMap<String, String>();
+    }
+
+    public AbstractNode(Node other) {
+        this.properties = new HashMap<String, String>(other.getProperties());
+        //this.children = new LinkedHashMap<String, Node>(other.getChildNodes(0, -1));
+        this.childEntries = new LinkedHashMap<String, String>(other.getChildNodeEntries());
+    }
+
+    public Map<String, String> getProperties() {
+        return properties;
+    }
+
+    public List<String> getChildNodeNames(int offset, int count) {
+        Set<String> keys = childEntries.keySet();
+        List<String> names = new ArrayList(keys);
+        if (offset < 0 || count < -1) {
+            throw new IllegalArgumentException();
+        }
+        if (offset == 0 && count == -1) {
+            return names;
+        } else {
+            if (offset >= names.size()) {
+                return Collections.emptyList();
+            }
+            int to = offset + count;
+            if (to > names.size()) {
+                to = names.size();
+            }
+            return names.subList(offset, to);
+        }
+    }
+
+    public int getChildNodeCount() {
+        return childEntries.size();
+    }
+
+    public Map<String, String> getChildNodeEntries() {
+        return childEntries;
+    }
+
+    public Map<String, String> getChildNodeEntries(int offset, int count) {
+        if (offset < 0 || count < -1) {
+            throw new IllegalArgumentException();
+        }
+        if (offset == 0 && count == -1) {
+            return childEntries;
+        } else {
+            if (offset >= childEntries.size()) {
+                return Collections.emptyMap();
+            }
+            int to = offset + count;
+            if (to > childEntries.size()) {
+                to = childEntries.size();
+                count = to - offset;
+            }
+            Map<String, String> result = new LinkedHashMap<String, String>(count);
+            for (Map.Entry<String, String> entry : childEntries.entrySet()) {
+                if (offset-- > 0) {
+                    continue;
+                }
+                result.put(entry.getKey(), entry.getValue());
+                if (--count <= 0) {
+                    break;
+                }
+            }
+            return result;
+        }
+    }
+
+    public Map<String, Node> getChildNodes(int offset, int count, RevisionProvider provider)
+            throws Exception {
+        if (offset < 0 || count < -1) {
+            throw new IllegalArgumentException();
+        }
+
+        if (offset >= childEntries.size()) {
+            return Collections.emptyMap();
+        }
+
+        // todo support embedded/in-lined sub-trees
+
+        int to = offset + count;
+        if (to > childEntries.size()) {
+            to = childEntries.size();
+            count = to - offset;
+        }
+        Map<String, Node> result = new LinkedHashMap<String, Node>(count);
+        for (Map.Entry<String, String> entry : childEntries.entrySet()) {
+            if (offset-- > 0) {
+                continue;
+            }
+            result.put(entry.getKey(), provider.getNode(entry.getValue()));
+            if (--count <= 0) {
+                break;
+            }
+        }
+        return result;
+    }
+
+    public Node getNode(String relPath, RevisionProvider provider)
+            throws NotFoundException, Exception {
+        String[] names = PathUtils.split(relPath);
+
+        Node node = this;
+        for (String name : names) {
+            node = node.getChildNodes(0, -1, provider).get(name);
+            if (node == null) {
+                throw new NotFoundException();
+            }
+        }
+        return node;
+    }
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/Commit.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/Commit.java?rev=1205913&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/Commit.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/Commit.java Thu Nov 24 16:24:54 2011
@@ -0,0 +1,31 @@
+/*
+ * 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.jackrabbit.mk.model;
+
+/**
+ *
+ */
+public interface Commit {
+
+    String getRootNodeId();
+
+    public String getParentId();
+
+    public long getCommitTS();
+
+    public String getMsg();
+}

Copied: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java (from r1202102, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java)
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java?p2=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java&p1=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java&r1=1202102&r2=1205913&rev=1205913&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/CommitBuilder.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java Thu Nov 24 16:24:54 2011
@@ -14,9 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.mk.store;
+package org.apache.jackrabbit.mk.model;
 
-import org.apache.jackrabbit.mk.Repository;
+import org.apache.jackrabbit.mk.store.NotFoundException;
+import org.apache.jackrabbit.mk.store.RevisionStore;
 import org.apache.jackrabbit.mk.util.PathUtils;
 
 import java.util.ArrayList;
@@ -35,18 +36,16 @@ public class CommitBuilder {
 
     final String msg;
 
-    final Repository rep;
-    final PersistenceManager store;
+    final RevisionStore store;
 
     final Map<String, MutableNode> staged;
     // change log
     final List<Change> changeLog;
 
-    public CommitBuilder(String baseRevId, String msg, Repository rep) throws Exception {
+    public CommitBuilder(String baseRevId, String msg, RevisionStore store) throws Exception {
         this.baseRevId = baseRevId;
         this.msg = msg;
-        this.rep = rep;
-        store = rep.getPersistenceManager();
+        this.store = store;
         staged = new HashMap<String, MutableNode>();
         changeLog = new ArrayList<Change>();
     }
@@ -168,7 +167,7 @@ public class CommitBuilder {
             return baseRevId;
         }
 
-        String currentHead = rep.getHeadRevision();
+        String currentHead = store.getHeadCommitId();
         if (!currentHead.equals(baseRevId)) {
             // update base revision to new head
             baseRevId = currentHead;
@@ -187,18 +186,18 @@ public class CommitBuilder {
         String newRevId;
         store.lockHead();
         try {
-            currentHead = rep.getHeadRevision();
+            currentHead = store.getHeadCommitId();
             if (!currentHead.equals(baseRevId)) {
-                Node baseRoot = rep.getNode(baseRevId, "/");
-                Node theirRoot = rep.getNode(currentHead, "/");
-                Node ourRoot = rep.getPersistenceManager().getNode(rootNodeId);
+                StoredNode baseRoot = store.getRootNode(baseRevId);
+                StoredNode theirRoot = store.getRootNode(currentHead);
+                StoredNode ourRoot = store.getNode(rootNodeId);
 
                 rootNodeId = mergeTree(baseRoot, ourRoot, theirRoot);
 
                 baseRevId = currentHead;
             }
 
-            if (rep.getCommit(currentHead).getRootNodeId().equals(rootNodeId)) {
+            if (store.getCommit(currentHead).getRootNodeId().equals(rootNodeId)) {
                 // the commit didn't cause any changes,
                 // no need to create new commit object/update head revision
                 return currentHead;
@@ -227,7 +226,7 @@ public class CommitBuilder {
         if (node == null) {
             MutableNode parent = staged.get("/");
             if (parent == null) {
-                parent = new MutableNode(rep.getNode(baseRevId, "/"));
+                parent = new MutableNode(store.getRootNode(baseRevId));
                 staged.put("/", parent);
             }
             node = parent;
@@ -239,7 +238,7 @@ public class CommitBuilder {
                     // not yet staged, resolve id using staged parent
                     // to allow for staged move operations
                     String id = parent.getChildNodeEntries().get(names[names.length - i - 1]);
-                    node = new MutableNode(rep.getPersistenceManager().getNode(id));
+                    node = new MutableNode(store.getNode(id));
                     staged.put(path, node);
                 }
                 parent = node;
@@ -310,7 +309,7 @@ public class CommitBuilder {
      * @return id of merged root node
      * @throws Exception
      */
-    String /* id of merged root node */ mergeTree(Node baseRoot, Node ourRoot, Node theirRoot) throws Exception {
+    String /* id of merged root node */ mergeTree(StoredNode baseRoot, StoredNode ourRoot, StoredNode theirRoot) throws Exception {
         // as we're going to use the staging area for the merge process,
         // we need to clear it first
         staged.clear();
@@ -321,7 +320,7 @@ public class CommitBuilder {
         return persistStagedNodes();
     }
 
-    void mergeNode(Node baseNode, Node ourNode, Node theirNode, String path) throws Exception {
+    void mergeNode(StoredNode baseNode, StoredNode ourNode, StoredNode theirNode, String path) throws Exception {
         // todo review/verify correctness of merge algorithm
         NodeDelta theirChanges = new NodeDelta(baseNode, theirNode);
         NodeDelta ourChanges = new NodeDelta(baseNode, ourNode);
@@ -359,9 +358,9 @@ public class CommitBuilder {
                 case NODE_CONTENT_CONFLICT: {
                     if (ourChanges.getChangedChildNodes().containsKey(conflictName)) {
                         // modified subtrees
-                        Node baseChild = store.getNode(baseNode.getChildNodeEntries().get(conflictName));
-                        Node ourChild = store.getNode(ourNode.getChildNodeEntries().get(conflictName));
-                        Node theirChild = store.getNode(theirNode.getChildNodeEntries().get(conflictName));
+                        StoredNode baseChild = store.getNode(baseNode.getChildNodeEntries().get(conflictName));
+                        StoredNode ourChild = store.getNode(ourNode.getChildNodeEntries().get(conflictName));
+                        StoredNode theirChild = store.getNode(theirNode.getChildNodeEntries().get(conflictName));
                         // merge the dirty subtrees recursively
                         mergeNode(baseChild, ourChild, theirChild, PathUtils.concat(path, conflictName));
                     } else {

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/MutableCommit.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/MutableCommit.java?rev=1205913&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/MutableCommit.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/MutableCommit.java Thu Nov 24 16:24:54 2011
@@ -0,0 +1,42 @@
+/*
+ * 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.jackrabbit.mk.model;
+
+/**
+ *
+ */
+public class MutableCommit extends AbstractCommit {
+
+    public MutableCommit() {
+    }
+
+    public void setParentId(String parentId) {
+        this.parentId = parentId;
+    }
+
+    public void setRootNodeId(String rootNodeId) {
+        this.rootNodeId = rootNodeId;
+    }
+
+    public void setCommitTS(long commitTS) {
+        this.commitTS = commitTS;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/MutableNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/MutableNode.java?rev=1205913&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/MutableNode.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/MutableNode.java Thu Nov 24 16:24:54 2011
@@ -0,0 +1,30 @@
+/*
+ * 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.jackrabbit.mk.model;
+
+/**
+ *
+ */
+public class MutableNode extends AbstractNode {
+
+    public MutableNode() {
+    }
+
+    public MutableNode(Node other) {
+        super(other);
+    }
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/Node.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/Node.java?rev=1205913&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/Node.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/Node.java Thu Nov 24 16:24:54 2011
@@ -0,0 +1,44 @@
+/*
+ * 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.jackrabbit.mk.model;
+
+import org.apache.jackrabbit.mk.store.RevisionProvider;
+import org.apache.jackrabbit.mk.store.NotFoundException;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ */
+public interface Node {
+
+    Map<String, String> getProperties();
+    List<String> getChildNodeNames(int offset, int count);
+    int getChildNodeCount();
+    /**
+     * @deprecated use getChildNodes(int, int, RevisionProvider) instead
+     */
+    Map<String, String> getChildNodeEntries();
+    /**
+     * @deprecated use getChildNodes(int, int, RevisionProvider) instead
+     */
+    Map<String, String> getChildNodeEntries(int offset, int count);
+
+    Map<String, Node> getChildNodes(int offset, int count, RevisionProvider provider) throws Exception;
+    Node getNode(String relPath, RevisionProvider provider) throws NotFoundException, Exception;
+}

Copied: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeDelta.java (from r1202102, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeDelta.java)
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeDelta.java?p2=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeDelta.java&p1=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeDelta.java&r1=1202102&r2=1205913&rev=1205913&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeDelta.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeDelta.java Thu Nov 24 16:24:54 2011
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.mk.store;
+package org.apache.jackrabbit.mk.model;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -47,8 +47,8 @@ public class NodeDelta implements NodeDi
         REMOVED_DIRTY_NODE_CONFLICT
     }
 
-    final Node node1;
-    final Node node2;
+    final StoredNode node1;
+    final StoredNode node2;
 
     Map<String, String> addedProperties = new HashMap<String, String>();
     Map<String, String> removedProperties = new HashMap<String, String>();
@@ -58,7 +58,7 @@ public class NodeDelta implements NodeDi
     Map<String, String> removedChildNodes = new HashMap<String, String>();
     Map<String, String> changedChildNodes = new HashMap<String, String>();
 
-    public NodeDelta(Node node1, Node node2) throws Exception {
+    public NodeDelta(StoredNode node1, StoredNode node2) throws Exception {
         this.node1 = node1;
         this.node2 = node2;
 

Copied: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeDiffHandler.java (from r1202102, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeDiffHandler.java)
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeDiffHandler.java?p2=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeDiffHandler.java&p1=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeDiffHandler.java&r1=1202102&r2=1205913&rev=1205913&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeDiffHandler.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeDiffHandler.java Thu Nov 24 16:24:54 2011
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.mk.store;
+package org.apache.jackrabbit.mk.model;
 
 /**
  *

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeProxy.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeProxy.java?rev=1205913&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeProxy.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeProxy.java Thu Nov 24 16:24:54 2011
@@ -0,0 +1,55 @@
+/*
+ * 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.jackrabbit.mk.model;
+
+import org.apache.jackrabbit.mk.store.RevisionProvider;
+import org.apache.jackrabbit.mk.store.NotFoundException;
+
+/**
+ *
+ */
+public final class NodeProxy {
+
+    private final String id;
+    private final Node node;
+
+    public NodeProxy(String id) {
+        this.id = id;
+        this.node = null;
+    }
+
+    public NodeProxy(Node node) {
+        this.node = node;
+        this.id = null;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public Node getNode() {
+        return node;
+    }
+
+    public Node getTarget(RevisionProvider provider) throws NotFoundException, Exception {
+        if (node != null) {
+            return node;
+        } else {
+            return provider.getNode(id);
+        }
+    }
+}

Copied: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeUtils.java (from r1202102, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeUtils.java)
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeUtils.java?p2=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeUtils.java&p1=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeUtils.java&r1=1202102&r2=1205913&rev=1205913&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/NodeUtils.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/NodeUtils.java Thu Nov 24 16:24:54 2011
@@ -14,8 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.mk.store;
+package org.apache.jackrabbit.mk.model;
 
+import org.apache.jackrabbit.mk.store.RevisionProvider;
 import org.apache.jackrabbit.mk.util.PathUtils;
 
 import java.util.HashSet;
@@ -46,7 +47,7 @@ public class NodeUtils {
     }
 
     public static void diff(String path, Node node1, Node node2,
-                            boolean deep, PersistenceManager store,
+                            boolean deep, RevisionProvider store,
                             NodeDiffHandler handler) throws Exception {
 
         // compare properties
@@ -76,8 +77,8 @@ public class NodeUtils {
         // todo determine copy/move and child-node reorder operations
 
         // compare child node entries
-        Map<String, String> oldEntries = node1.getChildNodeEntries();
-        Map<String, String> newEntries = node2.getChildNodeEntries();
+        Map<String, String> oldEntries = node1.getChildNodeEntries(0, -1);
+        Map<String, String> newEntries = node2.getChildNodeEntries(0, -1);
         if (!oldEntries.equals(newEntries)) {
             Set<String> set = new HashSet<String>();
             set.addAll(oldEntries.keySet());

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/StoredCommit.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/StoredCommit.java?rev=1205913&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/StoredCommit.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/StoredCommit.java Thu Nov 24 16:24:54 2011
@@ -0,0 +1,37 @@
+/*
+ * 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.jackrabbit.mk.model;
+
+/**
+ *
+ */
+public class StoredCommit extends AbstractCommit {
+
+    private final String id;
+
+    public StoredCommit(String id, String parentId, long commitTS, String rootNodeId, String msg) {
+        this.id = id;
+        this.parentId = parentId;
+        this.commitTS = commitTS;
+        this.rootNodeId = rootNodeId;
+        this.msg = msg;
+    }
+
+    public String getId() {
+        return id;
+    }
+}

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/StoredNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/StoredNode.java?rev=1205913&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/StoredNode.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/StoredNode.java Thu Nov 24 16:24:54 2011
@@ -0,0 +1,77 @@
+/*
+ * 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.jackrabbit.mk.model;
+
+import org.apache.jackrabbit.mk.store.RevisionProvider;
+import org.apache.jackrabbit.mk.store.NotFoundException;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ */
+public class StoredNode extends AbstractNode {
+
+    private final String id;
+
+    public StoredNode(String id, Map<String, String> properties, LinkedHashMap<String, String> childEntries) {
+        this.id = id;
+        this.properties.putAll(properties);
+        this.childEntries.putAll(childEntries);
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public Map<String, String> getProperties() {
+        return Collections.unmodifiableMap(properties);
+    }
+
+    public Map<String, String> getChildNodeEntries() {
+        return Collections.unmodifiableMap(super.getChildNodeEntries());
+    }
+
+    public Map<String, String> getChildNodeEntries(int offset, int count) {
+        return Collections.unmodifiableMap(super.getChildNodeEntries(offset, count));
+    }
+
+    public List<String> getChildNodeNames(int offset, int count) {
+        return Collections.unmodifiableList(super.getChildNodeNames(offset, count));
+    }
+
+    public int getChildNodeCount() {
+        return childEntries.size();
+    }
+
+    public Map<String, Node> getChildNodes(int offset, int count, RevisionProvider provider)
+            throws Exception {
+        // todo return StoredNode instances instead?
+        return Collections.unmodifiableMap(super.getChildNodes(offset, count, provider));
+    }
+
+    public Node getNode(String relPath, RevisionProvider provider) throws NotFoundException, Exception {
+        Node result = super.getNode(relPath, provider);
+        if (!(result instanceof StoredNode)) {
+            // todo return a StoredNode instance instead?
+        }
+        return result;
+    }
+}

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/RevisionStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/RevisionStore.java?rev=1205913&r1=1205912&r2=1205913&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/RevisionStore.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/RevisionStore.java Thu Nov 24 16:24:54 2011
@@ -16,24 +16,20 @@
  */
 package org.apache.jackrabbit.mk.store;
 
-import java.io.File;
+import org.apache.jackrabbit.mk.model.Commit;
+import org.apache.jackrabbit.mk.model.Node;
+
 import java.io.InputStream;
 
 /**
- * <code>RevisionStore</code> represents a simple, <i>content-addressable</i>
- * loose object store.
+ *
  */
-public interface RevisionStore {
-
-    void initialize(File homeDir) throws Exception;
-
-    void close();
-
-    InputStream get(String id) throws NotFoundException, Exception;
-
-    String /* id */ put(InputStream in) throws Exception;
-
-    String /* id */ getHeadId() throws Exception;
+public interface RevisionStore extends RevisionProvider {
 
-    void setHeadId(String revId) throws Exception;
+    String /*id*/ putNode(Node node) throws Exception;
+    String /*id*/ putCommit(Commit commit) throws Exception;
+    void setHeadCommitId(String commitId) throws Exception;
+    void lockHead();
+    void unlockHead();
+    String /*id*/ putBlob(InputStream in) throws Exception;
 }

Copied: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/util/Constants.java (from r1202102, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Constants.java)
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/util/Constants.java?p2=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/util/Constants.java&p1=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Constants.java&r1=1202102&r2=1205913&rev=1205913&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/Constants.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/util/Constants.java Thu Nov 24 16:24:54 2011
@@ -14,12 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.mk.store;
+package org.apache.jackrabbit.mk.store.util;
 
 /**
  *
  */
-public class Constants {
+public interface Constants {
 
     static final String[] TYPE_NAMES = {"node", "nodetree", "fatnode", "fatnodepart", "commit", "blob"};
 

Copied: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/util/PersistentId.java (from r1205778, jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/PersistentId.java)
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/util/PersistentId.java?p2=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/util/PersistentId.java&p1=jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/PersistentId.java&r1=1205778&r2=1205913&rev=1205913&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/PersistentId.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/util/PersistentId.java Thu Nov 24 16:24:54 2011
@@ -14,12 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.mk.store;
+package org.apache.jackrabbit.mk.store.util;
 
 import org.apache.jackrabbit.mk.util.IOUtils;
 
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;

Added: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/util/Serializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/util/Serializer.java?rev=1205913&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/util/Serializer.java (added)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/store/util/Serializer.java Thu Nov 24 16:24:54 2011
@@ -0,0 +1,120 @@
+/*
+ * 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.jackrabbit.mk.store.util;
+
+import org.apache.jackrabbit.mk.model.Commit;
+import org.apache.jackrabbit.mk.model.StoredCommit;
+import org.apache.jackrabbit.mk.model.StoredNode;
+import org.apache.jackrabbit.mk.model.Node;
+import org.apache.jackrabbit.mk.util.IOUtils;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ *
+ */
+public class Serializer {
+
+    private Serializer() {
+    }
+
+    //-----------------------------------------------------------------< Node >
+
+    public static byte[] toBytes(Node node) {
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        try {
+            out.write(Constants.NODE);
+            Map<String, String> properties = node.getProperties();
+            IOUtils.writeVarInt(out, properties.size());
+            for (Map.Entry<String, String> entry : properties.entrySet()) {
+                IOUtils.writeString(out, entry.getKey());
+                IOUtils.writeString(out, entry.getValue());
+            }
+            Map<String, String> childEntries = node.getChildNodeEntries(0, -1);
+            IOUtils.writeVarInt(out, childEntries.size());
+            for (Map.Entry<String, String> entry : childEntries.entrySet()) {
+                IOUtils.writeString(out, entry.getKey());
+                IOUtils.writeString(out, entry.getValue());
+            }
+            out.close();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+
+        return out.toByteArray();
+    }
+
+    public static StoredNode fromBytes(String id, byte[] bytes, Class<Node> type) throws Exception {
+        ByteArrayInputStream in = new ByteArrayInputStream(bytes);
+        if (in.read() != Constants.NODE) {
+            throw new Exception("unknown data format");
+        }
+        int count = IOUtils.readVarInt(in);
+        Map<String, String> props = new HashMap<String, String>(count);
+        while (count-- > 0) {
+            String name = IOUtils.readString(in);
+            String value = IOUtils.readString(in);
+            props.put(name, value);
+        }
+        count = IOUtils.readVarInt(in);
+        LinkedHashMap<String, String> childEntries = new LinkedHashMap<String, String>(count);
+        while (count-- > 0) {
+            String name = IOUtils.readString(in);
+            String childId = IOUtils.readString(in);
+            childEntries.put(name, childId);
+        }
+        return new StoredNode(id, props, childEntries);
+    }
+
+    //---------------------------------------------------------------< Commit >
+
+    public static byte[] toBytes(Commit commit) {
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        try {
+            out.write(Constants.COMMIT);
+            IOUtils.writeString(out, commit.getRootNodeId());
+            IOUtils.writeVarLong(out, commit.getCommitTS());
+            String msg = commit.getMsg();
+            IOUtils.writeString(out, msg == null ? "" : msg);
+            String parentId = commit.getParentId();
+            IOUtils.writeString(out, parentId == null ? "" : parentId);
+            out.close();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+
+        return out.toByteArray();
+    }
+
+    public static StoredCommit fromBytes(String id, byte[] bytes, Class<Commit> type) throws Exception {
+        ByteArrayInputStream in = new ByteArrayInputStream(bytes);
+        if (in.read() != Constants.COMMIT) {
+            throw new Exception("unknown data format");
+        }
+        String rootNodeId = IOUtils.readString(in);
+        long commitTS = IOUtils.readVarLong(in);
+        String msg = IOUtils.readString(in);
+        String parentId = IOUtils.readString(in);
+        return new StoredCommit(id, "".equals(parentId) ? null : parentId, commitTS, rootNodeId, "".equals(msg) ? null : msg);
+    }
+
+}



Mime
View raw message