jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1336143 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
Date Wed, 09 May 2012 12:38:21 GMT
Author: jukka
Date: Wed May  9 12:38:21 2012
New Revision: 1336143

URL: http://svn.apache.org/viewvc?rev=1336143&view=rev
Log:
OAK-68: Extension point for commit validation

Connect the commit hook so it gets called before the MK.merge() call

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java

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=1336143&r1=1336142&r2=1336143&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
Wed May  9 12:38:21 2012
@@ -25,6 +25,7 @@ import org.apache.jackrabbit.oak.commons
 import org.apache.jackrabbit.oak.plugins.memory.MemoryChildNodeEntry;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
+import org.apache.jackrabbit.oak.spi.commit.EmptyCommitHook;
 import org.apache.jackrabbit.oak.spi.state.AbstractNodeState;
 import org.apache.jackrabbit.oak.spi.state.AbstractNodeStore;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
@@ -72,6 +73,10 @@ public class KernelNodeStore extends Abs
      */
     private KernelNodeState root;
 
+    public KernelNodeStore(MicroKernel kernel) {
+        this(kernel, new EmptyCommitHook());
+    }
+
     public KernelNodeStore(MicroKernel kernel, CommitHook commitHook) {
         this.kernel = kernel;
         this.commitHook = commitHook;
@@ -96,11 +101,9 @@ public class KernelNodeStore extends Abs
             throw new IllegalArgumentException("Alien node state");
         }
 
-        KernelNodeState kernelNodeState = (KernelNodeState) base;
-        String branchRevision = kernel.branch(kernelNodeState.getRevision());
-        String path = kernelNodeState.getPath();
-        KernelNodeState branchRoot = new KernelNodeState(kernel, valueFactory, path, branchRevision);
-        return KernelNodeStateBuilder.create(new NodeStateBuilderContext(branchRoot));
+        NodeStateBuilderContext context =
+                new NodeStateBuilderContext((KernelNodeState) base);
+        return KernelNodeStateBuilder.create(context);
     }
 
     @Override
@@ -132,7 +135,10 @@ public class KernelNodeStore extends Abs
         /** Path of the root of the whole subtree */
         private final String path;
 
-        /** Root of the subtree */
+        /** Original root of the subtree */
+        private final NodeState base;
+
+        /** Current root of the subtree */
         private NodeState root;
 
         /** Current branch revision */
@@ -141,10 +147,12 @@ public class KernelNodeStore extends Abs
         /** Pending changes */
         private StringBuilder jsop = new StringBuilder();
 
-        NodeStateBuilderContext(KernelNodeState root) {
-            this.path = root.getPath();
-            this.root = root;
-            this.revision = root.getRevision();
+        NodeStateBuilderContext(KernelNodeState base) {
+            this.base = base;
+            this.path = base.getPath();
+            this.revision = kernel.branch(base.getRevision());
+            this.root = new KernelNodeState(
+                    kernel, valueFactory, path, revision);
         }
 
         /**
@@ -288,6 +296,10 @@ public class KernelNodeStore extends Abs
         void applyPendingChanges() throws CommitFailedException {
             try {
                 purgePendingChanges();
+
+                // TODO handle potential commit changes from the hook
+                commitHook.beforeCommit(KernelNodeStore.this, base, root);
+
                 kernel.merge(revision, null);
                 revision = null;
             }



Mime
View raw message