jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1331852 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: kernel/KernelNodeStore.java spi/state/AbstractNodeStore.java spi/state/NodeState.java spi/state/NodeStateDiff.java
Date Sat, 28 Apr 2012 23:08:45 GMT
Author: jukka
Date: Sat Apr 28 23:08:45 2012
New Revision: 1331852

URL: http://svn.apache.org/viewvc?rev=1331852&view=rev
Log:
OAK-30: Strongly typed wrapper for the MicroKernel

Extract an AbstractNodeStore class with generic functionality.
Some additional documentation about the state interfaces.

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeStore.java
      - copied, changed from r1331846, 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
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStateDiff.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=1331852&r1=1331851&r2=1331852&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
Sat Apr 28 23:08:45 2012
@@ -22,6 +22,7 @@ import org.apache.jackrabbit.mk.api.Micr
 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;
@@ -33,7 +34,7 @@ import java.util.Set;
 /**
  * {@link MicroKernel}-based {@link NodeStore} implementation.
  */
-public class KernelNodeStore implements NodeStore {
+public class KernelNodeStore extends AbstractNodeStore {
 
     final MicroKernel kernel;
     final CoreValueFactory valueFactory;

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeStore.java
(from r1331846, 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/spi/state/AbstractNodeStore.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/AbstractNodeStore.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java&r1=1331846&r2=1331852&rev=1331852&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/spi/state/AbstractNodeStore.java
Sat Apr 28 23:08:45 2012
@@ -16,59 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.jackrabbit.oak.kernel;
+package org.apache.jackrabbit.oak.spi.state;
 
-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.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 implements NodeStore {
-
-    final MicroKernel kernel;
-    final CoreValueFactory valueFactory;
-
-    public KernelNodeStore(MicroKernel kernel, CoreValueFactory valueFactory) {
-        this.kernel = kernel;
-        this.valueFactory = valueFactory;
-    }
 
-    @Override
-    public NodeState getRoot() {
-        return new KernelNodeState(kernel, valueFactory, "/", kernel.getHeadRevision());
-    }
-
-    @Override
-    public NodeStateBuilder getBuilder(NodeState base) {
-        if (!(base instanceof KernelNodeState)) {
-            throw new IllegalArgumentException("Alien node state");
-        }
-
-        KernelNodeState kernelNodeState = (KernelNodeState) base;
-        String branchRevision = kernel.branch(kernelNodeState.getRevision());
-        String path = kernelNodeState.getPath();
-        return KernelNodeStateBuilder.create(kernel, valueFactory, path, branchRevision);
-    }
-
-    @Override
-    public void apply(NodeStateBuilder builder) throws CommitFailedException {
-        if (!(builder instanceof  KernelNodeStateBuilder)) {
-            throw new IllegalArgumentException("Alien builder");
-        }
-        
-        KernelNodeStateBuilder kernelNodeStateBuilder = (KernelNodeStateBuilder) builder;
-        kernelNodeStateBuilder.apply();
-    }
+public abstract class AbstractNodeStore implements NodeStore {
 
     @Override
     public void compare(NodeState before, NodeState after, NodeStateDiff diff) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java?rev=1331852&r1=1331851&r2=1331852&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeState.java
Sat Apr 28 23:08:45 2012
@@ -19,9 +19,9 @@ package org.apache.jackrabbit.oak.spi.st
 import org.apache.jackrabbit.oak.api.PropertyState;
 
 /**
- * A tree consists of nodes and properties, each of which evolves
- * through different states during its lifecycle. This interface
- * represents a specific, immutable state of a node in a tree. A node
+ * A node in a content tree consists of child nodes and properties, each
+ * of which evolves through different states during its lifecycle. This
+ * interface represents a specific, immutable state of a node. The state
  * consists of an unordered set of name -> item mappings, where
  * each item is either a property or a child node.
  * <p>
@@ -91,8 +91,6 @@ import org.apache.jackrabbit.oak.api.Pro
  */
 public interface NodeState {
 
-    // TODO: check if can be replaced by the mk.model interface
-
     /**
      * Returns the named property. The name is an opaque string and
      * is not parsed or otherwise interpreted by this method.

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStateDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStateDiff.java?rev=1331852&r1=1331851&r2=1331852&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStateDiff.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStateDiff.java
Sat Apr 28 23:08:45 2012
@@ -27,8 +27,12 @@ import org.apache.jackrabbit.oak.api.Pro
  * added, changed or deleted methods where appropriate. Differences in
  * the ordering of properties or child nodes do not affect the comparison,
  * and the order in which such differences are reported is unspecified.
- *
- * TODO: check if can be replaced by mk.model.NodeStateDiff
+ * <p>
+ * Note that the {@link NodeStore#compare(NodeState, NodeState, NodeStateDiff)}
+ * method only compares the given states without recursing to the subtrees
+ * below. An implementation of this interface should recursively call that
+ * method for the relevant child node entries to find out all the changes
+ * across the entire subtree below the given node.
  */
 public interface NodeStateDiff {
 



Mime
View raw message