jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1332676 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
Date Tue, 01 May 2012 14:46:57 GMT
Author: jukka
Date: Tue May  1 14:46:56 2012
New Revision: 1332676

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

Make KernelNodeState keep track of the currently seen state of the tree so that we can better
trigger after-commit hooks

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=1332676&r1=1332675&r2=1332676&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
Tue May  1 14:46:56 2012
@@ -21,32 +21,46 @@ package org.apache.jackrabbit.oak.kernel
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
-import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.spi.state.AbstractNodeStore;
-import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateBuilder;
-import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 
-import java.util.HashSet;
-import java.util.Set;
 /**
  * {@link MicroKernel}-based {@link NodeStore} implementation.
  */
 public class KernelNodeStore extends AbstractNodeStore {
 
-    final MicroKernel kernel;
-    final CoreValueFactory valueFactory;
+    /**
+     * The {@link MicroKernel} instance used to store the content tree.
+     */
+    private final MicroKernel kernel;
+
+    /**
+     * Value factory backed by the {@link #kernel} instance.
+     */
+    private final CoreValueFactory valueFactory;
+
+    /**
+     * State of the current root node.
+     */
+    private KernelNodeState root;
 
     public KernelNodeStore(MicroKernel kernel) {
         this.kernel = kernel;
         this.valueFactory = new CoreValueFactoryImpl(kernel);
+        this.root = new KernelNodeState(
+                kernel, valueFactory, "/", kernel.getHeadRevision());
     }
 
     @Override
-    public NodeState getRoot() {
-        return new KernelNodeState(kernel, valueFactory, "/", kernel.getHeadRevision());
+    public synchronized NodeState getRoot() {
+        String revision = kernel.getHeadRevision();
+        if (!revision.equals(root.getRevision())) {
+            root = new KernelNodeState(
+                    kernel, valueFactory, "/", kernel.getHeadRevision());
+        }
+        return root;
     }
 
     @Override



Mime
View raw message