jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1326443 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ oak-core/src/test/java/org/apache/jac...
Date Sun, 15 Apr 2012 23:32:30 GMT
Author: mduerig
Date: Sun Apr 15 23:32:29 2012
New Revision: 1326443

URL: http://svn.apache.org/viewvc?rev=1326443&view=rev
Log:
OAK-18: Define Oak API 
- redesigned NodeStateEditor into Branch
- moved CRUD methods to NodeStateEditor
- moved copy/move methods to Branch
- removed ItemStateProvider

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Branch.java
      - copied, changed from r1325846, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/NodeStateEditor.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBranch.java
      - copied, changed from r1325846, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditor.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelBranchFuzzIT.java   (contents, props changed)
      - copied, changed from r1325846, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorFuzzIT.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelBranchTest.java
      - copied, changed from r1325846, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorTest.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/NodeStateEditor.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditor.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorFuzzIT.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorTest.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemStateProvider.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Connection.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TransientNodeState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ConnectionImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TmpRepositoryService.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/NodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TransientKernelNodeState.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Branch.java (from r1325846, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/NodeStateEditor.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Branch.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Branch.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/NodeStateEditor.java&r1=1325846&r2=1326443&rev=1326443&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/NodeStateEditor.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Branch.java Sun Apr 15 23:32:29 2012
@@ -18,59 +18,17 @@
  */
 package org.apache.jackrabbit.oak.api;
 
-import java.util.List;
-
 /**
- * An editor for modifying existing and creating new node states.
+ * An branch for modifying existing and creating new node states.
  */
-public interface NodeStateEditor {
-
-    /**
-     * Add the child node state with the given {@code name}. Does nothing
-     * if such a child node already exists.
-     *
-     * @param name name of the new node state
-     * @return the transient state of the child node with that name or {@code null}
-     * if no such node exists.
-     */
-    TransientNodeState addNode(String name);
-
-    /**
-     * Remove the child node state with the given {@code name}. Does nothing
-     * if no such child node exists.
-     * @param name  name of the node state to remove
-     */
-    void removeNode(String name);
-
-    /**
-     * Set a single valued property state on this node state.
-     *
-     * @param name The name of this property
-     * @param value The value of this property
-     */
-    void setProperty(String name, Scalar value);
-
-    /**
-     * Set a multivalued valued property state on this node state.
-     *
-     * @param name The name of this property
-     * @param values The value of this property
-     */
-    void setProperty(String name, List<Scalar> values);
-
-    /**
-     * Remove a property from this node state
-     * @param name name of the property
-     */
-    void removeProperty(String name);
+public interface Branch {
 
     /**
      * Move the node state located at {@code sourcePath} to a node
      * state at {@code destPath}. Do noting if either the source
      * does not exist, the parent of the destination does not exist
      * or the destination exists already. Both paths must resolve
-     * to node states located in the subtree below the transient
-     * state this editor is acting upon.
+     * to node states located in this branch.
      *
      * @param sourcePath source path relative to this node state
      * @param destPath destination path relative to this node state
@@ -82,8 +40,7 @@ public interface NodeStateEditor {
      * state at {@code destPath}. Do noting if either the source
      * does not exist, the parent of the destination does not exist
      * or the destination exists already. Both paths must resolve
-     * to node states located in the subtree below the transient
-     * state this editor is acting upon.
+     * to node states located in this branch.
      *
      * @param sourcePath source path relative to this node state
      * @param destPath destination path relative to this node state
@@ -91,19 +48,13 @@ public interface NodeStateEditor {
     void copy(String sourcePath, String destPath);
 
     /**
-     * Edit the child node state at the given {@code path}.
-     * The path must resolve to a node state located in the subtree
-     * below the transient state this editor is acting upon.
+     * Retrieve the child node state at the given {@code path}.
+     * The path must resolve to a node state located in this branch.
      *
-     * @param path path of the child node state to edit.
-     * @return editor for the child node state at the given path or
-     *         {@code null} if no such node state exists.
+     * @param path path of the child node state to getNode.
+     * @return transient node state at the given path or {@code null} if no
+     * such node state exists.
      */
-    NodeStateEditor edit(String path);
+    TransientNodeState getNode(String path);
 
-    /**
-     * Return the transient state which this editor is acting upon
-     * @return transient node state
-     */
-    TransientNodeState getTransientState();
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Connection.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Connection.java?rev=1326443&r1=1326442&r2=1326443&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Connection.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Connection.java Sun Apr 15 23:32:29 2012
@@ -85,21 +85,21 @@ public interface Connection extends Clos
     void refresh();
 
     /**
-     * Atomically apply all changes in the passed {@code editor} to the underlying
+     * Atomically apply all changes in the passed {@code branch} to the underlying
      * Microkernel.
      *
-     * @param editor  editor carrying the changes to be applies
+     * @param branch  branch carrying the changes to be applies
      * @throws CommitFailedException
      */
-    void commit(NodeStateEditor editor) throws CommitFailedException;
+    void commit(Branch branch) throws CommitFailedException;
 
     /**
-     * Get an node state editor for the current root. Use {@link #commit(NodeStateEditor)}
-     * to atomically apply the changes made in this editor to the underlying Microkernel.
+     * Branch the current root. Use {@link #commit(Branch)} to atomically apply the
+     * changes made in this branch to the underlying Microkernel.
      *
-     * @return editor for the current root.
+     * @return branch of the current root.
      */
-    NodeStateEditor getNodeStateEditor();
+    Branch branchRoot();
 
     /**
      * Get the query engine.

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TransientNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TransientNodeState.java?rev=1326443&r1=1326442&r2=1326443&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TransientNodeState.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/TransientNodeState.java Sun Apr 15 23:32:29 2012
@@ -18,9 +18,10 @@
  */
 package org.apache.jackrabbit.oak.api;
 
+import java.util.List;
+
 /**
- * A transient node state represents a node being edited. All edit operations are
- * done through an associated {@link org.apache.jackrabbit.oak.api.NodeStateEditor}.
+ * A transient node state represents a mutable node.
  * <p>
  * A transient node state contains the current state of a node and is
  * in contrast to {@link org.apache.jackrabbit.mk.model.NodeState} instances
@@ -47,9 +48,9 @@ public interface TransientNodeState {
     TransientNodeState getParent();
 
     /**
-     * @return  editor acting upon this instance
+     * @return  the branch this state belongs to
      */
-    NodeStateEditor getEditor();
+    Branch getBranch();
 
     /**
      * Get a property state
@@ -74,6 +75,15 @@ public interface TransientNodeState {
     long getPropertyCount();
 
     /**
+     * All property states. The returned {@code Iterable} has snapshot semantics. That
+     * is, it reflect the state of this transient node state instance at the time of the
+     * call. Later changes to this instance are no visible to iterators obtained from
+     * the returned iterable.
+     * @return  An {@code Iterable} for all property states
+     */
+    Iterable<PropertyState> getProperties();
+
+    /**
      * Get a child node state
      * @param name  name of the child node state
      * @return  the child node state with the given {@code name} or {@code null}
@@ -96,15 +106,6 @@ public interface TransientNodeState {
     long getChildNodeCount();
 
     /**
-     * All property states. The returned {@code Iterable} has snapshot semantics. That
-     * is, it reflect the state of this transient node state instance at the time of the
-     * call. Later changes to this instance are no visible to iterators obtained from
-     * the returned iterable.
-     * @return  An {@code Iterable} for all property states
-     */
-    Iterable<PropertyState> getProperties();
-
-    /**
      * All child node states. The returned {@code Iterable} has snapshot semantics. That
      * is, it reflect the state of this transient node state instance at the time of the
      * call. Later changes to this instance are no visible to iterators obtained from
@@ -112,4 +113,44 @@ public interface TransientNodeState {
      * @return  An {@code Iterable} for all child node states
      */
     Iterable<TransientNodeState> getChildNodes();
+
+    /**
+     * Add the child node state with the given {@code name}. Does nothing
+     * if such a child node already exists.
+     *
+     * @param name name of the new node state
+     * @return the transient state of the child node with that name or {@code null}
+     * if no such node exists.
+     */
+    TransientNodeState addNode(String name);
+
+    /**
+     * Remove the child node state with the given {@code name}. Does nothing
+     * if no such child node exists.
+     * @param name  name of the node state to remove
+     */
+    void removeNode(String name);
+
+    /**
+     * Set a single valued property state on this node state.
+     *
+     * @param name The name of this property
+     * @param value The value of this property
+     */
+    void setProperty(String name, Scalar value);
+
+    /**
+     * Set a multivalued valued property state on this node state.
+     *
+     * @param name The name of this property
+     * @param values The value of this property
+     */
+    void setProperty(String name, List<Scalar> values);
+
+    /**
+     * Remove a property from this node state
+     * @param name name of the property
+     */
+    void removeProperty(String name);
+
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ConnectionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ConnectionImpl.java?rev=1326443&r1=1326442&r2=1326443&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ConnectionImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ConnectionImpl.java Sun Apr 15 23:32:29 2012
@@ -21,7 +21,7 @@ import org.apache.jackrabbit.oak.api.Aut
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.Connection;
 import org.apache.jackrabbit.oak.kernel.NodeState;
-import org.apache.jackrabbit.oak.api.NodeStateEditor;
+import org.apache.jackrabbit.oak.api.Branch;
 import org.apache.jackrabbit.oak.kernel.NodeStore;
 import org.apache.jackrabbit.oak.api.QueryEngine;
 import org.slf4j.Logger;
@@ -99,16 +99,16 @@ public class ConnectionImpl implements C
     }
 
     @Override
-    public void commit(NodeStateEditor editor) throws CommitFailedException {
+    public void commit(Branch branch) throws CommitFailedException {
         try {
-            store.merge(editor);
+            store.merge(branch);
         } catch (MicroKernelException e) {
             throw new CommitFailedException(e);
         }
     }
 
     @Override
-    public NodeStateEditor getNodeStateEditor() {
+    public Branch branchRoot() {
         return store.branch(root);
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TmpRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TmpRepositoryService.java?rev=1326443&r1=1326442&r2=1326443&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TmpRepositoryService.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TmpRepositoryService.java Sun Apr 15 23:32:29 2012
@@ -20,7 +20,7 @@ import org.apache.jackrabbit.mk.MicroKer
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.oak.api.Connection;
 import org.apache.jackrabbit.oak.kernel.NodeState;
-import org.apache.jackrabbit.oak.api.NodeStateEditor;
+import org.apache.jackrabbit.oak.api.Branch;
 import org.apache.jackrabbit.oak.api.QueryEngine;
 import org.apache.jackrabbit.oak.api.RepositoryService;
 import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
@@ -83,9 +83,9 @@ public class TmpRepositoryService implem
             NodeState root = nodeStore.getRoot();
             NodeState wspNode = root.getChildNode(wspName);
             if (wspNode == null) {
-                NodeStateEditor editor = nodeStore.branch(root);
-                editor.addNode(wspName);
-                nodeStore.merge(editor);
+                Branch branch = nodeStore.branch(root);
+                branch.getNode("/").addNode(wspName);
+                nodeStore.merge(branch);
             }
         }
 

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBranch.java (from r1325846, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditor.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBranch.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBranch.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditor.java&r1=1325846&r2=1326443&rev=1326443&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditor.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBranch.java Sun Apr 15 23:32:29 2012
@@ -20,8 +20,7 @@ package org.apache.jackrabbit.oak.kernel
 
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.json.JsonBuilder;
-import org.apache.jackrabbit.oak.api.NodeStateEditor;
-import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Branch;
 import org.apache.jackrabbit.oak.api.Scalar;
 import org.apache.jackrabbit.oak.api.TransientNodeState;
 
@@ -32,9 +31,9 @@ import static org.apache.jackrabbit.mk.u
 import static org.apache.jackrabbit.mk.util.PathUtils.getParentPath;
 
 /**
- * This {@code NodeStateEditor} implementation accumulates all changes into a json diff
+ * This {@code Branch} implementation accumulates all changes into a json diff
  * and applies them to the microkernel on
- * {@link NodeStore#merge(org.apache.jackrabbit.oak.api.NodeStateEditor)}
+ * {@link NodeStore#merge(org.apache.jackrabbit.oak.api.Branch)}
  *
  * TODO: review/rewrite when OAK-45 is resolved
  * When the MicroKernel has support for branching and merging private working copies,
@@ -44,79 +43,27 @@ import static org.apache.jackrabbit.mk.u
  *   transient space gets too big.
  * - spool write operations through to the private working copy on a background thread
  */
-public class KernelNodeStateEditor implements NodeStateEditor {
+public class KernelBranch implements Branch {
 
     /** Base node state of this private branch */
     private final NodeState base;
 
-    /** Transient state this editor is acting upon */
-    private final TransientKernelNodeState transientState;
+    /** Root state of this branch */
+    private final TransientKernelNodeState root;
 
     /** Json diff of this private branch */
     private final StringBuilder jsop;
 
     /**
-     * Create a new node state editor representing the root of a fresh
-     * private branch.
+     * Create a new branch for the given base node state
      * @param base  base node state of the private branch
      */
-    KernelNodeStateEditor(NodeState base) {
+    KernelBranch(NodeState base) {
         this.base = base;
-        transientState = new TransientKernelNodeState(base, this);
+        root = new TransientKernelNodeState(this, base);
         jsop = new StringBuilder();
     }
 
-    /**
-     * Create a new node state editor for a given transient node state.
-     * @param parentEditor  editor of the parent of {@code state}
-     * @param state  transient node state for which to create the node state editor
-     */
-    KernelNodeStateEditor(KernelNodeStateEditor parentEditor, TransientKernelNodeState state) {
-        base = parentEditor.base;
-        transientState = state;
-        jsop = parentEditor.jsop;
-    }
-
-    @Override
-    public TransientNodeState addNode(String name) {
-        if (!transientState.hasNode(name)) {
-            transientState.addNode(name);
-            jsop.append("+\"").append(path(name)).append("\":{}");
-        }
-
-        return transientState.getChildNode(name);
-    }
-
-    @Override
-    public void removeNode(String name) {
-        if (transientState.hasNode(name)) {
-            transientState.removeNode(name);
-            jsop.append("-\"").append(path(name)).append('"');
-        }
-    }
-
-    @Override
-    public void setProperty(String name, Scalar value) {
-        PropertyState propertyState = new KernelPropertyState(name, value);
-        transientState.setProperty(propertyState);
-        jsop.append("^\"").append(path(propertyState.getName())).append("\":")
-                .append(encode(propertyState));
-    }
-
-    @Override
-    public void setProperty(String name, List<Scalar> values) {
-        PropertyState propertyState = new KernelPropertyState(name, values);
-        transientState.setProperty(propertyState);
-        jsop.append("^\"").append(path(propertyState.getName())).append("\":")
-                .append(encode(propertyState));
-    }
-
-    @Override
-    public void removeProperty(String name) {
-        transientState.removeProperty(name);
-        jsop.append("^\"").append(path(name)).append("\":null");
-    }
-
     @Override
     public void move(String sourcePath, String destPath) {
         TransientKernelNodeState sourceParent = getTransientState(getParentPath(sourcePath));
@@ -132,8 +79,8 @@ public class KernelNodeStateEditor imple
         }
 
         sourceParent.move(sourceName, destParent, destName);
-        jsop.append(">\"").append(path(sourcePath))
-                .append("\":\"").append(path(destPath)).append('"');
+        jsop.append(">\"").append(sourcePath)
+                .append("\":\"").append(destPath).append('"');
     }
 
     @Override
@@ -151,22 +98,15 @@ public class KernelNodeStateEditor imple
         }
 
         sourceParent.copy(sourceName, destParent, destName);
-        jsop.append("*\"").append(path(sourcePath)).append("\":\"")
-                .append(path(destPath)).append('"');
+        jsop.append("*\"").append(sourcePath).append("\":\"")
+                .append(destPath).append('"');
     }
 
     @Override
-    public KernelNodeStateEditor edit(String path) {
-        TransientKernelNodeState state = getTransientState(path);
-        return state == null
-            ? null
-            : state.getEditor();
+    public TransientNodeState getNode(String path) {
+        return getTransientState(path);
     }
 
-    @Override
-    public TransientNodeState getTransientState() {
-        return transientState;
-    }
 
     //------------------------------------------------------------< internal >---
     /**
@@ -192,6 +132,26 @@ public class KernelNodeStateEditor imple
         return new KernelNodeState(microkernel, targetPath, rev);
     }
 
+    void addNode(TransientKernelNodeState state, String name) {
+        jsop.append("+\"").append(path(state, name)).append("\":{}");
+    }
+
+    void removeNode(TransientKernelNodeState state, String name) {
+        jsop.append("-\"").append(path(state, name)).append('"');
+    }
+
+    void setProperty(TransientKernelNodeState state, String name, Scalar value) {
+        jsop.append("^\"").append(path(state, name)).append("\":").append(encode(value));
+    }
+
+    void setProperty(TransientKernelNodeState state, String name, List<Scalar> values) {
+        jsop.append("^\"").append(path(state, name)).append("\":").append(encode(values));
+    }
+
+    void removeProperty(TransientKernelNodeState state, String name) {
+        jsop.append("^\"").append(path(state, name)).append("\":null");
+    }
+
     /**
      * Get a transient node state for the node identified by
      * {@code path}
@@ -200,7 +160,7 @@ public class KernelNodeStateEditor imple
      *          at {@code path} or {@code null} if no such item exits.
      */
     private TransientKernelNodeState getTransientState(String path) {
-        TransientKernelNodeState state = transientState;
+        TransientKernelNodeState state = root;
         for (String name : elements(path)) {
             state = state.getChildNode(name);
             if (state == null) {
@@ -211,23 +171,17 @@ public class KernelNodeStateEditor imple
     }
 
     /**
-     * Path of the item {@code name}
+     * Path of the item {@code name} of the given {@code state}
+     *
+     * @param state
      * @param name The item name.
      * @return relative path of the item {@code name}
      */
-    private String path(String name) {
-        String path = transientState.getPath();
+    private static String path(TransientKernelNodeState state, String name) {
+        String path = state.getPath();
         return path.isEmpty() ? name : path + '/' + name;
     }
 
-    private static String encode(PropertyState state) {
-        if (state.isArray()) {
-            return encode(state.getArray());
-        } else {
-            return encode(state.getScalar());
-        }
-    }
-
     private static String encode(Scalar scalar) {
         switch (scalar.getType()) {
             case BOOLEAN: return JsonBuilder.encode(scalar.getBoolean());

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java?rev=1326443&r1=1326442&r2=1326443&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java Sun Apr 15 23:32:29 2012
@@ -19,7 +19,7 @@
 package org.apache.jackrabbit.oak.kernel;
 
 import org.apache.jackrabbit.mk.api.MicroKernel;
-import org.apache.jackrabbit.oak.api.NodeStateEditor;
+import org.apache.jackrabbit.oak.api.Branch;
 
 /**
  * {@link MicroKernel}-based {@link NodeStore} implementation.
@@ -38,23 +38,23 @@ public class KernelNodeStore implements 
     }
 
     @Override
-    public NodeStateEditor branch(NodeState base) {
-        return new KernelNodeStateEditor(base);
+    public Branch branch(NodeState base) {
+        return new KernelBranch(base);
     }
 
     @Override
-    public NodeState merge(NodeStateEditor branch) {
-        if (!(branch instanceof KernelNodeStateEditor)) {
+    public NodeState merge(Branch branch) {
+        if (!(branch instanceof KernelBranch)) {
             throw new IllegalArgumentException("Branch does not belong to this store");
         }
 
-        KernelNodeStateEditor kne = (KernelNodeStateEditor) branch;
+        KernelBranch kne = (KernelBranch) branch;
         NodeState target = kne.getBaseNodeState();
         if (!(target instanceof KernelNodeState)) {
             throw new IllegalArgumentException("Target does not belong to this store");
         }
 
-        return ((KernelNodeStateEditor) branch).mergeInto(kernel, (KernelNodeState) target);
+        return ((KernelBranch) branch).mergeInto(kernel, (KernelNodeState) target);
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/NodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/NodeStore.java?rev=1326443&r1=1326442&r2=1326443&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/NodeStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/NodeStore.java Sun Apr 15 23:32:29 2012
@@ -16,14 +16,14 @@
  */
 package org.apache.jackrabbit.oak.kernel;
 
-import org.apache.jackrabbit.oak.api.NodeStateEditor;
+import org.apache.jackrabbit.oak.api.Branch;
 
 /**
  * Storage abstraction for content trees. At any given point in time
  * the stored content tree is rooted at a single immutable node state.
  * Changes in the tree are constructed by branching off a private copy
  * using the {@link #branch(NodeState)} method which can be modified
- * and merged back using the {@link #merge(org.apache.jackrabbit.oak.api.NodeStateEditor)}
+ * and merged back using the {@link #merge(org.apache.jackrabbit.oak.api.Branch)}
  * method.
  * <p>
  * This is a low-level interface that doesn't cover functionality like
@@ -44,13 +44,13 @@ public interface NodeStore {
     /**
      * Creates a private branch from a {@code base} node state
      * for editing. The branch can later be merged back into
-     * the node store using the {@link #merge(org.apache.jackrabbit.oak.api.NodeStateEditor) merge}
+     * the node store using the {@link #merge(org.apache.jackrabbit.oak.api.Branch) merge}
      * method.
      *
      * @param base base node state
      * @return a private branch rooted at {@code base}
      */
-    NodeStateEditor branch(NodeState base);
+    Branch branch(NodeState base);
 
     /**
      * Atomically merges the changes from {@code branch} back into the
@@ -60,7 +60,7 @@ public interface NodeStore {
      * @param branch branch for merging.
      * @return node state resulting from merging {@code branch}.
      */
-    NodeState merge(NodeStateEditor branch);
+    NodeState merge(Branch branch);
 
     /**
      * Compares the given two node states. Any found differences are

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TransientKernelNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TransientKernelNodeState.java?rev=1326443&r1=1326442&r2=1326443&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TransientKernelNodeState.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TransientKernelNodeState.java Sun Apr 15 23:32:29 2012
@@ -19,6 +19,7 @@
 package org.apache.jackrabbit.oak.kernel;
 
 import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Scalar;
 import org.apache.jackrabbit.oak.api.TransientNodeState;
 import org.apache.jackrabbit.oak.util.Function1;
 import org.apache.jackrabbit.oak.util.Iterators;
@@ -28,6 +29,7 @@ import org.apache.jackrabbit.oak.util.Pr
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
@@ -39,8 +41,8 @@ import static org.apache.jackrabbit.oak.
 import static org.apache.jackrabbit.oak.util.Iterators.map;
 
 public class TransientKernelNodeState implements TransientNodeState {
-    /** Editor acting upon this instance */
-    private final KernelNodeStateEditor editor;
+    /** Branch this state belongs to */
+    private final KernelBranch branch;
 
     /**
      * Underlying persistent state or {@code null} if this instance represents an
@@ -73,38 +75,37 @@ public class TransientKernelNodeState im
     private TransientNodeState parent;
 
     /**
-     * Create a new instance representing the root of a sub-tree.
+     * Create a new instance representing the root of a branch.
+     * @param branch  the branch this state belongs to
      * @param persistentState  underlying persistent state
-     * @param editor  editor acting upon the transient node state
      */
-    TransientKernelNodeState(NodeState persistentState, KernelNodeStateEditor editor) {
-        this.editor = editor;
-        this.persistentState = persistentState;
-        this.parent = null;
-        this.name = "";
+    TransientKernelNodeState(KernelBranch branch, NodeState persistentState) {
+        this(branch, persistentState, null, "");
     }
 
     /**
      * Create a new instance representing a added node state
-     * @param parentEditor  editor of the parent state
+     * @param branch  the branch the state belongs to
+     * @param parent  the parent state of the state
      * @param name  name of the state
      */
-    private TransientKernelNodeState(KernelNodeStateEditor parentEditor, String name) {
-        this(parentEditor, name, null);
+    private TransientKernelNodeState(KernelBranch branch, TransientNodeState parent, String name) {
+        this(branch, null, parent, name);
     }
 
     /**
      * Create a new instance with an underlying persistent state
-     * @param parentEditor  editor of the parent state
-     * @param name  name of the state
+     * @param branch  the branch the state belongs to
      * @param persistedState  underlying persistent state
+     * @param parent  the parent state of the state
+     * @param name  name of the state
      */
-    private TransientKernelNodeState(KernelNodeStateEditor parentEditor, String name,
-            NodeState persistedState) {
+    private TransientKernelNodeState(KernelBranch branch, NodeState persistedState,
+            TransientNodeState parent, String name) {
 
-        editor = new KernelNodeStateEditor(parentEditor, this);
+        this.branch = branch;
         this.persistentState = persistedState;
-        parent = parentEditor.getTransientState();
+        this.parent = parent;
         this.name = name;
     }
 
@@ -118,7 +119,7 @@ public class TransientKernelNodeState im
     private TransientKernelNodeState(TransientKernelNodeState state, TransientKernelNodeState parent,
             String name) {
 
-        editor = new KernelNodeStateEditor(parent.getEditor(), this);
+        branch = state.branch;
         persistentState = state.persistentState;
         this.parent = parent;
         this.name = name;
@@ -166,8 +167,8 @@ public class TransientKernelNodeState im
     }
 
     @Override
-    public KernelNodeStateEditor getEditor() {
-        return editor;
+    public KernelBranch getBranch() {
+        return branch;
     }
 
     @Override
@@ -312,24 +313,51 @@ public class TransientKernelNodeState im
         };
     }
 
-    //------------------------------------------------------------< internal >---
+    @Override
+    public TransientNodeState addNode(String name) {
+        if (!hasNode(name)) {
+            addedNodes.put(name, new TransientKernelNodeState(branch, this, name));
+            branch.addNode(this, name);
+        }
 
-    /**
-     * Add a new child node state with the given {@code name}.
-     * The behaviour of this method is not defined if a node state with that
-     * {@code name} already exists.
-     * @param name  name of the child node state
-     */
-    void addNode(String name) {
-        addedNodes.put(name, new TransientKernelNodeState(editor, name));
+        return getChildNode(name);
     }
 
-    /**
-     * Remove the child node state with the given {@code name}.
-     * Does nothing if there is no node state with the given {@code name}.
-     * @param name  name of the child node state
-     */
-    void removeNode(String name) {
+    @Override
+    public void removeNode(String name) {
+        if (hasNode(name)) {
+            markNodeRemoved(name);
+            branch.removeNode(this, name);
+        }
+    }
+
+    @Override
+    public void setProperty(String name, Scalar value) {
+        PropertyState propertyState = new KernelPropertyState(name, value);
+        setProperty(propertyState);
+        branch.setProperty(this, name, value);
+    }
+
+    @Override
+    public void setProperty(String name, List<Scalar> values) {
+        PropertyState propertyState = new KernelPropertyState(name, values);
+        setProperty(propertyState);
+        branch.setProperty(this, name, values);
+    }
+
+    @Override
+    public void removeProperty(String name) {
+        addedProperties.remove(name);
+        if (hasExistingProperty(name)) {
+            // Mark as removed if removing existing
+            removedProperties.add(name);
+        }
+        branch.removeProperty(this, name);
+    }
+
+//------------------------------------------------------------< internal >---
+
+    void markNodeRemoved(String name) {
         addedNodes.remove(name);
         if (hasExistingNode(name)) {
             // Mark as removed if removing existing
@@ -337,10 +365,6 @@ public class TransientKernelNodeState im
         }
     }
 
-    /**
-     * Set a property state.
-     * @param state  a property state
-     */
     void setProperty(PropertyState state) {
         if (hasExistingProperty(state.getName())) {
             removedProperties.add(state.getName());
@@ -348,47 +372,15 @@ public class TransientKernelNodeState im
         addedProperties.put(state.getName(), state);
     }
 
-    /**
-     * Remove the property state with the given {@code name}.
-     * Does nothing if there is no property state with the given {@code name}.
-     * @param name  a property state
-     */
-    void removeProperty(String name) {
-        addedProperties.remove(name);
-        if (hasExistingProperty(name)) {
-            // Mark as removed if removing existing
-            removedProperties.add(name);
-        }
-    }
-
-    /**
-     * Move the child node state with the given {@code name} to the new parent at
-     * The behaviour of this method is undefined if either this node state has
-     * no child node state with the given {@code name} or {@code destParent} already
-     * has a child node state of {@code destName}.
-     *
-     * @param name  name of the child node state to move
-     * @param destParent  parent of the moved node state
-     * @param destName  name of the moved node state
-     */
     void move(String name, TransientKernelNodeState destParent, String destName) {
         TransientKernelNodeState state = getChildNode(name);
-        removeNode(name);
+        markNodeRemoved(name);
 
         state.name = destName;
         state.parent = destParent;
         destParent.addedNodes.put(destName, state);
     }
 
-    /**
-     * Copy the child node state with the given {@code name} to the new parent at
-     * The behaviour of this method is undefined if {@code destParent} already
-     * has a child node state of {@code destName}.
-     *
-     * @param name  name of the child node state to move
-     * @param destParent  parent of the moved node state
-     * @param destName  name of the moved node state
-     */
     void copy(String name, TransientKernelNodeState destParent, String destName) {
         destParent.addedNodes.put(destName,
                 new TransientKernelNodeState(getChildNode(name), destParent, destName));
@@ -415,7 +407,7 @@ public class TransientKernelNodeState im
             if (state == null) {
                 return null;
             }
-            transientState = new TransientKernelNodeState(editor, name, state);
+            transientState = new TransientKernelNodeState(branch, state, this, name);
             existingChildNodes.put(name, transientState);
         }
         return transientState;

Copied: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelBranchFuzzIT.java (from r1325846, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorFuzzIT.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelBranchFuzzIT.java?p2=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelBranchFuzzIT.java&p1=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorFuzzIT.java&r1=1325846&r2=1326443&rev=1326443&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorFuzzIT.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelBranchFuzzIT.java Sun Apr 15 23:32:29 2012
@@ -37,18 +37,18 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Random;
 
-import static org.apache.jackrabbit.oak.kernel.KernelNodeStateEditorFuzzIT.Operation.AddNode;
-import static org.apache.jackrabbit.oak.kernel.KernelNodeStateEditorFuzzIT.Operation.MoveNode;
-import static org.apache.jackrabbit.oak.kernel.KernelNodeStateEditorFuzzIT.Operation.CopyNode;
-import static org.apache.jackrabbit.oak.kernel.KernelNodeStateEditorFuzzIT.Operation.RemoveNode;
-import static org.apache.jackrabbit.oak.kernel.KernelNodeStateEditorFuzzIT.Operation.RemoveProperty;
-import static org.apache.jackrabbit.oak.kernel.KernelNodeStateEditorFuzzIT.Operation.Save;
-import static org.apache.jackrabbit.oak.kernel.KernelNodeStateEditorFuzzIT.Operation.SetProperty;
+import static org.apache.jackrabbit.oak.kernel.KernelBranchFuzzIT.Operation.AddNode;
+import static org.apache.jackrabbit.oak.kernel.KernelBranchFuzzIT.Operation.MoveNode;
+import static org.apache.jackrabbit.oak.kernel.KernelBranchFuzzIT.Operation.CopyNode;
+import static org.apache.jackrabbit.oak.kernel.KernelBranchFuzzIT.Operation.RemoveNode;
+import static org.apache.jackrabbit.oak.kernel.KernelBranchFuzzIT.Operation.RemoveProperty;
+import static org.apache.jackrabbit.oak.kernel.KernelBranchFuzzIT.Operation.Save;
+import static org.apache.jackrabbit.oak.kernel.KernelBranchFuzzIT.Operation.SetProperty;
 import static org.junit.Assert.assertEquals;
 
 @RunWith(Parameterized.class)
-public class KernelNodeStateEditorFuzzIT {
-    static final Logger log = LoggerFactory.getLogger(KernelNodeStateEditorFuzzIT.class);
+public class KernelBranchFuzzIT {
+    static final Logger log = LoggerFactory.getLogger(KernelBranchFuzzIT.class);
 
     private static final int OP_COUNT = 5000;
 
@@ -67,7 +67,7 @@ public class KernelNodeStateEditorFuzzIT
         });
     }
 
-    public KernelNodeStateEditorFuzzIT(int seed) {
+    public KernelBranchFuzzIT(int seed) {
         log.info("Seed = {}", seed);
         random = new Random(seed);
     }
@@ -81,22 +81,22 @@ public class KernelNodeStateEditorFuzzIT
     @Test
     public void fuzzTest() throws Exception {
         KernelNodeState state1 = new KernelNodeState(mk1, "/", mk1.getHeadRevision());
-        KernelNodeStateEditor editor1 = new KernelNodeStateEditor(state1);
+        KernelBranch branch1 = new KernelBranch(state1);
 
         KernelNodeState state2 = new KernelNodeState(mk2, "/", mk2.getHeadRevision());
-        KernelNodeStateEditor editor2 = new KernelNodeStateEditor(state2);
+        KernelBranch branch2 = new KernelBranch(state2);
 
         for (Operation op : operations(OP_COUNT)) {
             log.info("{}", op);
-            op.apply(editor1);
-            op.apply(editor2);
-            checkEqual(editor1.getTransientState(), editor2.getTransientState());
+            op.apply(branch1);
+            op.apply(branch2);
+            checkEqual(branch1.getNode("/"), branch2.getNode("/"));
 
-            state1 = editor1.mergeInto(mk1, state1);
-            editor1 = new KernelNodeStateEditor(state1);
+            state1 = branch1.mergeInto(mk1, state1);
+            branch1 = new KernelBranch(state1);
             if (op instanceof Save) {
-                state2 = editor2.mergeInto(mk2, state2);
-                editor2 = new KernelNodeStateEditor(state2);
+                state2 = branch2.mergeInto(mk2, state2);
+                branch2 = new KernelBranch(state2);
                 assertEquals(state1, state2);
             }
         }
@@ -129,7 +129,7 @@ public class KernelNodeStateEditorFuzzIT
     }
 
     abstract static class Operation {
-        abstract void apply(KernelNodeStateEditor editor);
+        abstract void apply(KernelBranch branch);
 
         static class AddNode extends Operation {
             private final String parentPath;
@@ -141,8 +141,8 @@ public class KernelNodeStateEditorFuzzIT
             }
 
             @Override
-            void apply(KernelNodeStateEditor editor) {
-                editor.edit(parentPath).addNode(name);
+            void apply(KernelBranch branch) {
+                branch.getNode(parentPath).addNode(name);
             }
 
             @Override
@@ -159,10 +159,10 @@ public class KernelNodeStateEditorFuzzIT
             }
 
             @Override
-            void apply(KernelNodeStateEditor editor) {
+            void apply(KernelBranch branch) {
                 String parentPath = PathUtils.getParentPath(path);
                 String name = PathUtils.getName(path);
-                editor.edit(parentPath).removeNode(name);
+                branch.getNode(parentPath).removeNode(name);
             }
 
             @Override
@@ -181,8 +181,8 @@ public class KernelNodeStateEditorFuzzIT
             }
 
             @Override
-            void apply(KernelNodeStateEditor editor) {
-                editor.move(source.substring(1), destination.substring(1));
+            void apply(KernelBranch branch) {
+                branch.move(source.substring(1), destination.substring(1));
             }
 
             @Override
@@ -201,8 +201,8 @@ public class KernelNodeStateEditorFuzzIT
             }
 
             @Override
-            void apply(KernelNodeStateEditor editor) {
-                editor.copy(source.substring(1), destination.substring(1));
+            void apply(KernelBranch branch) {
+                branch.copy(source.substring(1), destination.substring(1));
             }
 
             @Override
@@ -223,8 +223,8 @@ public class KernelNodeStateEditorFuzzIT
             }
 
             @Override
-            void apply(KernelNodeStateEditor editor) {
-                editor.edit(parentPath).setProperty(propertyName, propertyValue);
+            void apply(KernelBranch branch) {
+                branch.getNode(parentPath).setProperty(propertyName, propertyValue);
             }
 
             @Override
@@ -244,8 +244,8 @@ public class KernelNodeStateEditorFuzzIT
             }
 
             @Override
-            void apply(KernelNodeStateEditor editor) {
-                editor.edit(parentPath).removeProperty(name);
+            void apply(KernelBranch branch) {
+                branch.getNode(parentPath).removeProperty(name);
             }
 
             @Override
@@ -256,7 +256,7 @@ public class KernelNodeStateEditorFuzzIT
 
         static class Save extends Operation {
             @Override
-            void apply(KernelNodeStateEditor editor) {
+            void apply(KernelBranch branch) {
                 // empty
             }
 

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelBranchFuzzIT.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelBranchTest.java (from r1325846, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelBranchTest.java?p2=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelBranchTest.java&p1=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorTest.java&r1=1325846&r2=1326443&rev=1326443&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelBranchTest.java Sun Apr 15 23:32:29 2012
@@ -23,7 +23,6 @@ import org.apache.jackrabbit.mk.simple.S
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Scalar;
 import org.apache.jackrabbit.oak.api.TransientNodeState;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -33,13 +32,13 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
-import static junit.framework.Assert.assertNull;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
-public class KernelNodeStateEditorTest {
+public class KernelBranchTest {
 
     private final MicroKernel microkernel = new SimpleKernelImpl("mem:");
 
@@ -57,8 +56,8 @@ public class KernelNodeStateEditorTest {
 
     @Test
     public void getNode() {
-        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
-        TransientNodeState transientState = editor.getTransientState();
+        KernelBranch branch = new KernelBranch(state);
+        TransientNodeState transientState = branch.getNode("/");
         TransientNodeState childState = transientState.getChildNode("any");
         assertNull(childState);
 
@@ -68,22 +67,22 @@ public class KernelNodeStateEditorTest {
 
     @Test
     public void getProperty() {
-        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
-        TransientNodeState transientState = editor.getTransientState();
+        KernelBranch branch = new KernelBranch(state);
+        TransientNodeState transientState = branch.getNode("/");
         PropertyState propertyState = transientState.getProperty("any");
         assertNull(propertyState);
-        
+
         propertyState = transientState.getProperty("a");
         assertNotNull(propertyState);
         assertFalse(propertyState.isArray());
         assertEquals(Scalar.Type.LONG, propertyState.getScalar().getType());
         assertEquals(1, propertyState.getScalar().getLong());
     }
-    
+
     @Test
     public void getNodes() {
-        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
-        TransientNodeState transientState = editor.getTransientState();
+        KernelBranch branch = new KernelBranch(state);
+        TransientNodeState transientState = branch.getNode("/");
         Iterable<TransientNodeState> nodes = transientState.getChildNodes();
 
         Set<String> expectedPaths = new HashSet<String>();
@@ -93,14 +92,14 @@ public class KernelNodeStateEditorTest {
             assertTrue(expectedPaths.remove(node.getPath()));
         }
         assertTrue(expectedPaths.isEmpty());
-        
+
         assertEquals(3, transientState.getChildNodeCount());
     }
 
     @Test
     public void getProperties() {
-        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
-        TransientNodeState transientState = editor.getTransientState();
+        KernelBranch branch = new KernelBranch(state);
+        TransientNodeState transientState = branch.getNode("/");
 
         Map<String, Scalar> expectedProperties = new HashMap<String, Scalar>();
         expectedProperties.put("a", ScalarImpl.longScalar(1));
@@ -116,69 +115,69 @@ public class KernelNodeStateEditorTest {
         }
 
         assertTrue(expectedProperties.isEmpty());
-        
+
         assertEquals(3, transientState.getPropertyCount());
     }
 
     @Test
     public void addNode() {
-        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
-        TransientNodeState transientState = editor.getTransientState();
+        KernelBranch branch = new KernelBranch(state);
+        TransientNodeState transientState = branch.getNode("/");
 
         assertFalse(transientState.hasNode("new"));
-        TransientNodeState newNode = editor.addNode("new");
+        TransientNodeState newNode = transientState.addNode("new");
         assertNotNull(newNode);
         assertEquals("new", newNode.getName());
         assertTrue(transientState.hasNode("new"));
 
-        NodeState newState = editor.mergeInto(microkernel, state);
+        NodeState newState = branch.mergeInto(microkernel, state);
         assertNotNull(newState.getChildNode("new"));
     }
 
     @Test
     public void addExistingNode() {
-        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
-        TransientNodeState transientState = editor.getTransientState();
+        KernelBranch branch = new KernelBranch(state);
+        TransientNodeState transientState = branch.getNode("/");
 
         assertFalse(transientState.hasNode("new"));
-        TransientNodeState newNode = editor.addNode("new");
-        NodeState newState = editor.mergeInto(microkernel, state);
+        transientState.addNode("new");
+        NodeState newState = branch.mergeInto(microkernel, state);
 
-        editor = new KernelNodeStateEditor(newState);
-        transientState = editor.getTransientState();
+        branch = new KernelBranch(newState);
+        transientState = branch.getNode("/");
         assertTrue(transientState.hasNode("new"));
-        newNode = editor.addNode("new");
+        TransientNodeState newNode = transientState.addNode("new");
         assertNotNull(newNode);
         assertEquals("new", newNode.getName());
     }
 
     @Test
     public void removeNode() {
-        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
-        TransientNodeState transientState = editor.getTransientState();
+        KernelBranch branch = new KernelBranch(state);
+        TransientNodeState transientState = branch.getNode("/");
 
         assertTrue(transientState.hasNode("x"));
-        editor.removeNode("x");
+        transientState.removeNode("x");
         assertFalse(transientState.hasNode("x"));
 
-        NodeState newState = editor.mergeInto(microkernel, state);
+        NodeState newState = branch.mergeInto(microkernel, state);
         assertNull(newState.getChildNode("x"));
     }
 
     @Test
     public void setProperty() {
-        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
-        TransientNodeState transientState = editor.getTransientState();
+        KernelBranch branch = new KernelBranch(state);
+        TransientNodeState transientState = branch.getNode("/");
 
         assertFalse(transientState.hasProperty("new"));
         Scalar value = ScalarImpl.stringScalar("value");
-        editor.setProperty("new", value);
+        transientState.setProperty("new", value);
         PropertyState property = transientState.getProperty("new");
         assertNotNull(property);
         assertEquals("new", property.getName());
         assertEquals(value, property.getScalar());
 
-        NodeState newState = editor.mergeInto(microkernel, state);
+        NodeState newState = branch.mergeInto(microkernel, state);
         property = newState.getProperty("new");
         assertNotNull(property);
         assertEquals("new", property.getName());
@@ -187,29 +186,29 @@ public class KernelNodeStateEditorTest {
 
     @Test
     public void removeProperty() {
-        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
-        TransientNodeState transientState = editor.getTransientState();
+        KernelBranch branch = new KernelBranch(state);
+        TransientNodeState transientState = branch.getNode("/");
 
         assertTrue(transientState.hasProperty("a"));
-        editor.removeProperty("a");
+        transientState.removeProperty("a");
         assertFalse(transientState.hasProperty("a"));
 
-        NodeState newState = editor.mergeInto(microkernel, state);
-        Assert.assertNull(newState.getProperty("a"));
+        NodeState newState = branch.mergeInto(microkernel, state);
+        assertNull(newState.getProperty("a"));
     }
 
     @Test
     public void move() {
-        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
-        TransientNodeState transientState = editor.getTransientState();
+        KernelBranch branch = new KernelBranch(state);
+        TransientNodeState transientState = branch.getNode("/");
         TransientNodeState y = transientState.getChildNode("y");
 
         assertTrue(transientState.hasNode("x"));
-        editor.move("x", "y/xx");
+        branch.move("x", "y/xx");
         assertFalse(transientState.hasNode("x"));
         assertTrue(y.hasNode("xx"));
 
-        NodeState newState = editor.mergeInto(microkernel, state);
+        NodeState newState = branch.mergeInto(microkernel, state);
         assertNull(newState.getChildNode("x"));
         assertNotNull(newState.getChildNode("y"));
         assertNotNull(newState.getChildNode("y").getChildNode("xx"));
@@ -217,31 +216,31 @@ public class KernelNodeStateEditorTest {
 
     @Test
     public void rename() {
-        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
-        TransientNodeState transientState = editor.getTransientState();
+        KernelBranch branch = new KernelBranch(state);
+        TransientNodeState transientState = branch.getNode("/");
 
         assertTrue(transientState.hasNode("x"));
-        editor.move("x", "xx");
+        branch.move("x", "xx");
         assertFalse(transientState.hasNode("x"));
         assertTrue(transientState.hasNode("xx"));
 
-        NodeState newState = editor.mergeInto(microkernel, state);
+        NodeState newState = branch.mergeInto(microkernel, state);
         assertNull(newState.getChildNode("x"));
         assertNotNull(newState.getChildNode("xx"));
     }
 
     @Test
     public void copy() {
-        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
-        TransientNodeState transientState = editor.getTransientState();
+        KernelBranch branch = new KernelBranch(state);
+        TransientNodeState transientState = branch.getNode("/");
         TransientNodeState y = transientState.getChildNode("y");
 
         assertTrue(transientState.hasNode("x"));
-        editor.copy("x", "y/xx");
+        branch.copy("x", "y/xx");
         assertTrue(transientState.hasNode("x"));
         assertTrue(y.hasNode("xx"));
 
-        NodeState newState = editor.mergeInto(microkernel, state);
+        NodeState newState = branch.mergeInto(microkernel, state);
         assertNotNull(newState.getChildNode("x"));
         assertNotNull(newState.getChildNode("y"));
         assertNotNull(newState.getChildNode("y").getChildNode("xx"));
@@ -249,16 +248,16 @@ public class KernelNodeStateEditorTest {
 
     @Test
     public void deepCopy() {
-        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
-        TransientNodeState transientState = editor.getTransientState();
+        KernelBranch branch = new KernelBranch(state);
+        TransientNodeState transientState = branch.getNode("/");
         TransientNodeState y = transientState.getChildNode("y");
 
-        editor.edit("x").addNode("x1");
-        editor.copy("x", "y/xx");
+        branch.getNode("x").addNode("x1");
+        branch.copy("x", "y/xx");
         assertTrue(y.hasNode("xx"));
         assertTrue(y.getChildNode("xx").hasNode("x1"));
 
-        NodeState newState = editor.mergeInto(microkernel, state);
+        NodeState newState = branch.mergeInto(microkernel, state);
         assertNotNull(newState.getChildNode("x"));
         assertNotNull(newState.getChildNode("y"));
         assertNotNull(newState.getChildNode("y").getChildNode("xx"));
@@ -268,59 +267,61 @@ public class KernelNodeStateEditorTest {
         NodeState xx = newState.getChildNode("y").getChildNode("xx");
         assertEquals(x, xx);
     }
-    
+
     @Test
     public void getChildNodeCount() {
-        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
-        TransientNodeState transientState = editor.getTransientState();
+        KernelBranch branch = new KernelBranch(state);
+        TransientNodeState transientState = branch.getNode("/");
         assertEquals(3, transientState.getChildNodeCount());
 
-        editor.removeNode("x");
+        transientState.removeNode("x");
         assertEquals(2, transientState.getChildNodeCount());
 
-        editor.addNode("a");
+        transientState.addNode("a");
         assertEquals(3, transientState.getChildNodeCount());
 
-        editor.addNode("x");
+        transientState.addNode("x");
         assertEquals(4, transientState.getChildNodeCount());
     }
-    
+
     @Test
     public void getPropertyCount() {
-        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
-        TransientNodeState transientState = editor.getTransientState();
+        KernelBranch branch = new KernelBranch(state);
+        TransientNodeState transientState = branch.getNode("/");
         assertEquals(3, transientState.getPropertyCount());
 
         Scalar value = ScalarImpl.stringScalar("foo");
-        editor.setProperty("a", value);
+        transientState.setProperty("a", value);
         assertEquals(3, transientState.getPropertyCount());
 
-        editor.removeProperty("a");
+        transientState.removeProperty("a");
         assertEquals(2, transientState.getPropertyCount());
 
-        editor.setProperty("x", value);
+        transientState.setProperty("x", value);
         assertEquals(3, transientState.getPropertyCount());
 
-        editor.setProperty("a", value);
+        transientState.setProperty("a", value);
         assertEquals(4, transientState.getPropertyCount());
     }
-    
+
     @Test
     public void largeChildNodeList() {
-        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
+        KernelBranch branch = new KernelBranch(state);
+        TransientNodeState transientState = branch.getNode("/");
 
-        editor.addNode("large");
-        editor = editor.edit("large");
+        transientState.addNode("large");
+        transientState = transientState.getChildNode("large");
         for (int c = 0; c < 10000; c++) {
-            editor.addNode("n" + c);
+            transientState.addNode("n" + c);
         }
 
-        KernelNodeState newState = editor.mergeInto(microkernel, state);
-        editor = new KernelNodeStateEditor(newState);
-        editor = editor.edit("large");
+        KernelNodeState newState = branch.mergeInto(microkernel, state);
+        branch = new KernelBranch(newState);
+        transientState = branch.getNode("/");
+        transientState = transientState.getChildNode("large");
 
         int c = 0;
-        for (TransientNodeState q : editor.getTransientState().getChildNodes()) {
+        for (TransientNodeState q : transientState.getChildNodes()) {
             assertEquals("n" + c++, q.getName());
         }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1326443&r1=1326442&r2=1326443&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java Sun Apr 15 23:32:29 2012
@@ -19,7 +19,7 @@ package org.apache.jackrabbit.oak.jcr;
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter;
 import org.apache.jackrabbit.commons.iterator.PropertyIteratorAdapter;
-import org.apache.jackrabbit.oak.api.NodeStateEditor;
+import org.apache.jackrabbit.oak.api.Branch;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.TransientNodeState;
 import org.apache.jackrabbit.oak.jcr.util.ItemNameMatcher;
@@ -154,7 +154,7 @@ public class NodeImpl extends ItemImpl i
      */
     @Override
     public void remove() throws RepositoryException {
-        getTransientNodeState().getParent().getEditor().removeNode(getName());
+        getTransientNodeState().getParent().removeNode(getName());
     }
 
     /**
@@ -175,13 +175,13 @@ public class NodeImpl extends ItemImpl i
         checkStatus();
 
         String parentPath = Paths.concat(path(), Paths.getParentPath(relPath));
-        TransientNodeState parentState = getItemStateProvider().getTransientNodeState(parentPath);
+        TransientNodeState parentState = getBranch().getNode(parentPath);
         if (parentState == null) {
             throw new PathNotFoundException(relPath);
         }
 
         String name = Paths.getName(relPath);
-        parentState.getEditor().addNode(name);
+        parentState.addNode(name);
         return new NodeImpl(sessionContext, parentState.getChildNode(name));
     }
 
@@ -219,7 +219,7 @@ public class NodeImpl extends ItemImpl i
     public Property setProperty(String name, Value value, int type) throws RepositoryException {
         checkStatus();
 
-        getEditor().setProperty(name, ValueConverter.toScalar(value));
+        getState().setProperty(name, ValueConverter.toScalar(value));
         return getProperty(name);
     }
 
@@ -241,7 +241,7 @@ public class NodeImpl extends ItemImpl i
     public Property setProperty(String name, Value[] values, int type) throws RepositoryException {
         checkStatus();
 
-        getEditor().setProperty(name, ValueConverter.toScalar(values));
+        getState().setProperty(name, ValueConverter.toScalar(values));
         return getProperty(name);
     }
 
@@ -602,7 +602,7 @@ public class NodeImpl extends ItemImpl i
     public void setPrimaryType(String nodeTypeName) throws RepositoryException {
         checkStatus();
 
-        getEditor().setProperty(JcrConstants.JCR_PRIMARYTYPE, ScalarImpl.stringScalar(nodeTypeName));
+        getState().setProperty(JcrConstants.JCR_PRIMARYTYPE, ScalarImpl.stringScalar(nodeTypeName));
     }
 
     @Override
@@ -829,14 +829,14 @@ public class NodeImpl extends ItemImpl i
 
     //--------------------------------------------------------------------------
     /**
-     * Access to KernelNodeStateEditor to allow code in other packages to
+     * Access to TransientNodeState to allow code in other packages to
      * access item states.
      *
-     * @return The node state editor.
+     * @return The node state.
      * FIXME this should not be public in order to avoid clients to access internals through casting to the implementation
      */
-    public NodeStateEditor getEditor() {
-        return getTransientNodeState().getEditor();
+    public TransientNodeState getState() {
+        return getTransientNodeState();
     }
 
     //------------------------------------------------------------< private >---
@@ -862,12 +862,12 @@ public class NodeImpl extends ItemImpl i
         return getSession().getWorkspace().getLockManager();
     }
 
-    private ItemStateProvider getItemStateProvider() {
-        return sessionContext.getItemStateProvider();
+    private Branch getBranch() {
+        return sessionContext.getBranch();
     }
     
     private synchronized TransientNodeState getTransientNodeState() {
-        return transientNodeState = getItemStateProvider().getTransientNodeState(transientNodeState.getPath());
+        return transientNodeState = getBranch().getNode(transientNodeState.getPath());
     }
 
     private String path() {
@@ -894,7 +894,7 @@ public class NodeImpl extends ItemImpl i
 
     private NodeImpl getNodeOrNull(String relPath) {
         String absPath = Paths.concat(path(), relPath);
-        TransientNodeState nodeState = getItemStateProvider().getTransientNodeState(absPath);
+        TransientNodeState nodeState = getBranch().getNode(absPath);
         return nodeState == null
             ? null
             : new NodeImpl(sessionContext, nodeState);
@@ -902,7 +902,7 @@ public class NodeImpl extends ItemImpl i
     
     private PropertyImpl getPropertyOrNull(String relPath) {
         String absPath = Paths.concat(path(), Paths.getParentPath(relPath));
-        TransientNodeState parentState = getItemStateProvider().getTransientNodeState(absPath);
+        TransientNodeState parentState = getBranch().getNode(absPath);
         if (parentState == null) {
             return null;
         }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java?rev=1326443&r1=1326442&r2=1326443&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyImpl.java Sun Apr 15 23:32:29 2012
@@ -16,7 +16,7 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
-import org.apache.jackrabbit.oak.api.NodeStateEditor;
+import org.apache.jackrabbit.oak.api.Branch;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.TransientNodeState;
 import org.apache.jackrabbit.oak.jcr.util.LogUtil;
@@ -138,7 +138,7 @@ public class PropertyImpl extends ItemIm
      */
     @Override
     public void remove() throws RepositoryException {
-        getEditor().removeProperty(getStateName());
+        getParentState().removeProperty(getStateName());
     }
 
     /**
@@ -566,7 +566,7 @@ public class PropertyImpl extends ItemIm
             remove();
         }
         else {
-            getEditor().setProperty(getStateName(), ValueConverter.toScalar(value));
+            getParentState().setProperty(getStateName(), ValueConverter.toScalar(value));
         }
     }
 
@@ -586,7 +586,7 @@ public class PropertyImpl extends ItemIm
             remove();
         }
         else {
-            getEditor().setProperty(getStateName(), ValueConverter.toScalar(values));
+            getParentState().setProperty(getStateName(), ValueConverter.toScalar(values));
         }
     }
 
@@ -606,8 +606,8 @@ public class PropertyImpl extends ItemIm
         }
     }
 
-    private ItemStateProvider getItemStateProvider() {
-        return sessionContext.getItemStateProvider();
+    private Branch getBranch() {
+        return sessionContext.getBranch();
     }
 
     private TransientNodeState getParentState() {
@@ -615,10 +615,6 @@ public class PropertyImpl extends ItemIm
         return parentState;
     }
 
-    private NodeStateEditor getEditor() {
-        return getParentState().getEditor();
-    }
-
     private PropertyState getPropertyState() {
         resolve();
         return propertyState;
@@ -629,9 +625,15 @@ public class PropertyImpl extends ItemIm
     }
 
     private synchronized void resolve() {
-        parentState = getItemStateProvider().getTransientNodeState(parentState.getPath());
-        propertyState = getItemStateProvider().getPropertyState(
-                Paths.concat(parentState.getPath(), propertyState.getName()));
+        parentState = getBranch().getNode(parentState.getPath());
+        String path = Paths.concat(parentState.getPath(), propertyState.getName());
+
+        if (parentState == null) {
+            propertyState = null;
+        }
+        else {
+            propertyState = parentState.getProperty(Paths.getName(path));
+        }
     }
 
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java?rev=1326443&r1=1326442&r2=1326443&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java Sun Apr 15 23:32:29 2012
@@ -20,6 +20,7 @@
 package org.apache.jackrabbit.oak.jcr;
 
 import org.apache.jackrabbit.oak.api.Connection;
+import org.apache.jackrabbit.oak.api.Branch;
 
 import javax.jcr.Session;
 import javax.jcr.ValueFactory;
@@ -30,5 +31,5 @@ public interface SessionContext<T extend
     String getWorkspaceName();
     Connection getConnection();
     ValueFactory getValueFactory();
-    ItemStateProvider getItemStateProvider();
+    Branch getBranch();
 }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java?rev=1326443&r1=1326442&r2=1326443&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java Sun Apr 15 23:32:29 2012
@@ -19,7 +19,7 @@ package org.apache.jackrabbit.oak.jcr;
 import org.apache.jackrabbit.commons.AbstractSession;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.Connection;
-import org.apache.jackrabbit.oak.api.NodeStateEditor;
+import org.apache.jackrabbit.oak.api.Branch;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.ContentHandler;
@@ -55,8 +55,7 @@ public class SessionImpl extends Abstrac
     private final SessionContext<SessionImpl> sessionContext = new Context();
     private boolean isAlive = true;
 
-    private NodeStateEditor editor;
-    private ItemStateProvider itemStateProvider;
+    private Branch branch;
 
     SessionImpl(GlobalContext globalContext, Connection connection) {
         this.globalContext = globalContext;
@@ -64,8 +63,7 @@ public class SessionImpl extends Abstrac
         this.valueFactory = new ValueFactoryImpl();
         workspace = new WorkspaceImpl(sessionContext);
 
-        this.editor = connection.getNodeStateEditor();
-        this.itemStateProvider = new ItemStateProvider(editor.getTransientState());
+        this.branch = connection.branchRoot();
     }
 
 
@@ -118,7 +116,7 @@ public class SessionImpl extends Abstrac
     @Override
     public Node getRootNode() throws RepositoryException {
         ensureIsAlive();
-        return new NodeImpl(sessionContext, itemStateProvider.getTransientNodeState("/"));
+        return new NodeImpl(sessionContext, branch.getNode("/"));
     }
 
     @Override
@@ -145,7 +143,7 @@ public class SessionImpl extends Abstrac
 
         String srcPath = Paths.relativize("/", srcAbsPath);
         String destPath = Paths.relativize("/", destAbsPath);
-        editor.move(srcPath, destPath);
+        branch.move(srcPath, destPath);
     }
 
     //------------------------------------------------------------< state >---
@@ -154,10 +152,9 @@ public class SessionImpl extends Abstrac
     public void save() throws RepositoryException {
         ensureIsAlive();
         try {
-            connection.commit(editor);
+            connection.commit(branch);
             connection.refresh();
-            editor = connection.getNodeStateEditor();
-            itemStateProvider = new ItemStateProvider(editor.getTransientState());
+            branch = connection.branchRoot();
         } catch (CommitFailedException e) {
             throw new RepositoryException(e);
         }
@@ -168,8 +165,7 @@ public class SessionImpl extends Abstrac
         ensureIsAlive();
         connection.refresh();
         if (!keepChanges) {
-            editor = connection.getNodeStateEditor();
-            itemStateProvider = new ItemStateProvider(editor.getTransientState());
+            branch = connection.branchRoot();
         }
     }
 
@@ -442,8 +438,8 @@ public class SessionImpl extends Abstrac
         }
 
         @Override
-        public ItemStateProvider getItemStateProvider() {
-            return itemStateProvider;
+        public Branch getBranch() {
+            return branch;
         }
     }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java?rev=1326443&r1=1326442&r2=1326443&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/WorkspaceImpl.java Sun Apr 15 23:32:29 2012
@@ -18,7 +18,7 @@ package org.apache.jackrabbit.oak.jcr;
 
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.Connection;
-import org.apache.jackrabbit.oak.api.NodeStateEditor;
+import org.apache.jackrabbit.oak.api.Branch;
 import org.apache.jackrabbit.oak.jcr.query.QueryManagerImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -85,13 +85,13 @@ public class WorkspaceImpl implements Wo
 
         try {
             Connection connection = sessionContext.getConnection();
-            NodeStateEditor editor = connection.getNodeStateEditor();
+            Branch branch = connection.branchRoot();
 
             String srcPath = Paths.relativize("/", srcAbsPath);
             String destPath = Paths.relativize("/", destAbsPath);
-            editor.copy(srcPath, destPath);
+            branch.copy(srcPath, destPath);
 
-            connection.commit(editor);
+            connection.commit(branch);
         }
         catch (CommitFailedException e) {
             throw new RepositoryException(e);
@@ -116,13 +116,13 @@ public class WorkspaceImpl implements Wo
 
         try {
             Connection connection = sessionContext.getConnection();
-            NodeStateEditor editor = connection.getNodeStateEditor();
+            Branch branch = connection.branchRoot();
 
             String srcPath = Paths.relativize("/", srcAbsPath);
             String destPath = Paths.relativize("/", destAbsPath);
-            editor.move(srcPath, destPath);
+            branch.move(srcPath, destPath);
 
-            connection.commit(editor);
+            connection.commit(branch);
         }
         catch (CommitFailedException e) {
             throw new RepositoryException(e);

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java?rev=1326443&r1=1326442&r2=1326443&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java Sun Apr 15 23:32:29 2012
@@ -322,7 +322,7 @@ public class UserManagerImpl implements 
     void setInternalProperty(NodeImpl userNode, String name, String value, int type) throws RepositoryException {
         // TODO: check again if this really makes a transient modification with marking the property modified/new
         Scalar scalar = ValueConverter.toScalar(value, type);
-        userNode.getEditor().setProperty(name, scalar);
+        userNode.getState().setProperty(name, scalar);
     }
 
     void setInternalProperty(NodeImpl userNode, String name, String[] values, int type) throws RepositoryException {
@@ -331,12 +331,12 @@ public class UserManagerImpl implements 
         for (String value : values) {
             scalarList.add(ValueConverter.toScalar(value, PropertyType.STRING));
         }
-        userNode.getEditor().setProperty(name, scalarList);
+        userNode.getState().setProperty(name, scalarList);
     }
 
     void removeInternalProperty(NodeImpl userNode, String name) {
         // TODO: check again if this really makes a transient modification with marking the property modified
-        userNode.getEditor().removeProperty(name);
+        userNode.getState().removeProperty(name);
     }
 
     private Authorizable getAuthorizable(NodeImpl node) throws RepositoryException {



Mime
View raw message