jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1245088 - in /jackrabbit/sandbox/jackrabbit-microkernel/src: main/java/org/apache/jackrabbit/state/ChangeTree.java main/java/org/apache/jackrabbit/state/TransientSpace.java test/java/org/apache/jackrabbit/RepositoryTest.java
Date Thu, 16 Feb 2012 17:17:38 GMT
Author: mduerig
Date: Thu Feb 16 17:17:38 2012
New Revision: 1245088

URL: http://svn.apache.org/viewvc?rev=1245088&view=rev
Log:
Microkernel based prototype of JCR implementation (WIP)
- make changeTree immutable and acquire new changeTree instance on refresh   

Modified:
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientSpace.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java?rev=1245088&r1=1245087&r2=1245088&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeTree.java
Thu Feb 16 17:17:38 2012
@@ -113,14 +113,6 @@ public class ChangeTree {
     }
 
     /**
-     * Clear all transient changes made to this change tree.
-     */
-    public void clear() {
-        root.clear();
-        existing.clear();
-    }
-
-    /**
      * @return  {@code true} iff this change tree has transient changes.
      */
     public boolean hasChanges() {  

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientSpace.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientSpace.java?rev=1245088&r1=1245087&r2=1245088&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientSpace.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientSpace.java
Thu Feb 16 17:17:38 2012
@@ -26,6 +26,7 @@ import org.apache.jackrabbit.mk.api.Micr
 import org.apache.jackrabbit.spi.commons.iterator.Predicate;
 import org.apache.jackrabbit.state.ChangeTree.Listener;
 import org.apache.jackrabbit.state.ChangeTree.NodeDelta;
+import org.apache.jackrabbit.utils.Provider;
 
 import javax.jcr.RepositoryException;
 
@@ -37,9 +38,10 @@ import javax.jcr.RepositoryException;
  */
 public class TransientSpace {
     private final MicroKernel microkernel;
-    private final ChangeTree changeTree;
     private final ChangeLog changeLog = new ChangeLog();
+    private final Provider<ChangeTree> changeTreeProvider;
 
+    private ChangeTree changeTree;
     private String revision;
 
     /**
@@ -49,11 +51,11 @@ public class TransientSpace {
      * @param microkernel
      * @param revision
      */
-    public TransientSpace(String workspace, final MicroKernel microkernel, final String revision)
{
+    public TransientSpace(final String workspace, final MicroKernel microkernel, final String
revision) {
         this.microkernel = microkernel;
         this.revision = revision;
 
-        Listener changeTreeListener = new Listener() {
+        final Listener changeTreeListener = new Listener() {
             @Override
             public void added(NodeDelta nodeDelta) {
                 changeLog.addNode(nodeDelta.getPath());
@@ -75,14 +77,21 @@ public class TransientSpace {
             }
         };
 
-        Predicate<Path> nodeExists = new Predicate<Path>() {
+        final Predicate<Path> nodeExists = new Predicate<Path>() {
             @Override
             public boolean evaluate(Path path) {
                 return microkernel.nodeExists(path.toMkPath(), getRevision());
             }
         };
 
-        changeTree = new ChangeTree(Path.create(workspace), changeTreeListener, nodeExists);
+        changeTreeProvider = new Provider<ChangeTree>() {
+            @Override
+            public ChangeTree get() {
+                return new ChangeTree(Path.create(workspace), changeTreeListener, nodeExists);
+            }
+        };
+
+        changeTree = changeTreeProvider.get();
     }
 
     /**
@@ -104,7 +113,7 @@ public class TransientSpace {
         try {
             revision = microkernel.commit("", changeLog.toJsop(), revision, "");
             changeLog.clear();
-            changeTree.clear();
+            changeTree = changeTreeProvider.get();
             return revision;
         }
         catch (MicroKernelException e) {
@@ -122,7 +131,7 @@ public class TransientSpace {
     public String refresh(boolean keepChanges) {
         if (!keepChanges) {
             changeLog.clear();
-            changeTree.clear();
+            changeTree = changeTreeProvider.get();
         }
 
         return revision = microkernel.getHeadRevision();

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java?rev=1245088&r1=1245087&r2=1245088&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java
Thu Feb 16 17:17:38 2012
@@ -1126,9 +1126,6 @@ public class RepositoryTest {
     public void sessionRefreshFalse() throws RepositoryException {
         Session session = getRepository().login();
         try {
-            session.getNode("/").addNode("foo");
-            session.save();
-
             Node foo = session.getNode("/foo");
             foo.addNode("added");
             NodeIterator it = foo.getNodes();



Mime
View raw message