jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1299626 - in /jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit: ItemImpl.java NodeImpl.java PropertyImpl.java SessionImpl.java state/TransientNodeState.java
Date Mon, 12 Mar 2012 11:10:18 GMT
Author: mduerig
Date: Mon Mar 12 11:10:17 2012
New Revision: 1299626

URL: http://svn.apache.org/viewvc?rev=1299626&view=rev
Log:
Microkernel based prototype of JCR implementation (WIP)
- refactoring 

Modified:
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/ItemImpl.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/NodeImpl.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/PropertyImpl.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/SessionImpl.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientNodeState.java

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/ItemImpl.java?rev=1299626&r1=1299625&r2=1299626&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/ItemImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/ItemImpl.java
Mon Mar 12 11:10:17 2012
@@ -20,6 +20,7 @@
 package org.apache.jackrabbit;
 
 import org.apache.jackrabbit.SessionImpl.Context;
+import org.apache.jackrabbit.state.TransientNodeState;
 
 import javax.jcr.Item;
 import javax.jcr.Node;
@@ -82,4 +83,10 @@ abstract class ItemImpl implements Item 
         throw new UnsupportedRepositoryOperationException("Use Session#refresh");
     }
 
+    //------------------------------------------< internal >---
+
+    protected static TransientNodeState getNodeState(Context sessionContext, Path path) {
+        return sessionContext.getSession().getNodeState(path);
+    }
+
 }

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/NodeImpl.java?rev=1299626&r1=1299625&r2=1299626&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/NodeImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/NodeImpl.java
Mon Mar 12 11:10:17 2012
@@ -63,11 +63,15 @@ public class NodeImpl extends ItemImpl i
     private final TransientNodeState state;
 
     static boolean exist(Context sessionContext, Path path) {
-        return TransientNodeState.hasNodeState(sessionContext, path);
+        return getNodeState(sessionContext, path) != null;
     }
 
     static Node create(Context sessionContext, Path path) throws PathNotFoundException {
         TransientNodeState state = getNodeState(sessionContext, path);
+        if (state == null) {
+            throw new PathNotFoundException(path.toJcrPath());
+        }
+
         return new NodeImpl(sessionContext, state);
     }
 
@@ -295,7 +299,7 @@ public class NodeImpl extends ItemImpl i
 
     @Override
     public boolean hasNodes() throws RepositoryException {
-        return state.hasChildNodeStates();
+        return state.hasNodes();
     }
 
     @Override
@@ -582,15 +586,6 @@ public class NodeImpl extends ItemImpl i
 
     //------------------------------------------< private >---
 
-    private static TransientNodeState getNodeState(Context sessionContext, Path path) throws
PathNotFoundException {
-        TransientNodeState state = TransientNodeState.getNodeState(sessionContext, path);
-        if (state == null) {
-            throw new PathNotFoundException(path.toJcrPath());
-        }
-
-        return state;
-    }
-
     private Path path() {
         return state.getPath();
     }

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/PropertyImpl.java?rev=1299626&r1=1299625&r2=1299626&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/PropertyImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/PropertyImpl.java
Mon Mar 12 11:10:17 2012
@@ -48,14 +48,14 @@ public class PropertyImpl extends ItemIm
     private final JsonValue value;
 
     public static boolean exist(Context sessionContext, Path path) {
-        TransientNodeState parentState = TransientNodeState.getNodeState(sessionContext,
path.getParent());
+        TransientNodeState parentState = getNodeState(sessionContext, path.getParent());
         return parentState != null && parentState.hasProperty(path.getName());
     }
 
     static Property create(Context sessionContext, Path path) throws PathNotFoundException,
             ItemNotFoundException {
 
-        TransientNodeState parentState = TransientNodeState.getNodeState(sessionContext,
path.getParent());
+        TransientNodeState parentState = getNodeState(sessionContext, path.getParent());
         if (parentState == null) {
             throw new PathNotFoundException(path.toJcrPath());
         }

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/SessionImpl.java?rev=1299626&r1=1299625&r2=1299626&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/SessionImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/SessionImpl.java
Mon Mar 12 11:10:17 2012
@@ -23,6 +23,7 @@ import org.apache.jackrabbit.configurati
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.security.Authenticator;
 import org.apache.jackrabbit.security.CredentialsInfo;
+import org.apache.jackrabbit.state.ChangeTree.NodeDelta;
 import org.apache.jackrabbit.state.TransientNodeState;
 import org.apache.jackrabbit.state.TransientNodeStateCache;
 import org.apache.jackrabbit.state.TransientSpace;
@@ -137,6 +138,21 @@ public class SessionImpl implements Sess
         }
     };
 
+    public TransientNodeState getNodeState(Path path) {
+        NodeDelta delta = transientSpace.getNodeDelta(path);
+        if (delta == null) {
+            return null;
+        }
+        else {
+            TransientNodeState state = nodeStateCache.get(path);
+            if (state == null) {
+                state = new TransientNodeState(sessionContext, delta);
+                nodeStateCache.put(path, state);
+            }
+            return state;
+        }
+    }
+
     private SessionImpl(GlobalContext globalContext, CredentialsInfo credentialsInfo, String
workspaceName,
                         String revision) {
 
@@ -256,7 +272,7 @@ public class SessionImpl implements Sess
         checkLive();
         
         Path sourcePath = Path.create(workspaceName, srcAbsPath);
-        TransientNodeState sourceParent = TransientNodeState.getNodeState(sessionContext,
sourcePath.getParent());
+        TransientNodeState sourceParent = getNodeState(sourcePath.getParent());
         if (sourceParent == null) {
             throw new PathNotFoundException(srcAbsPath);
         }

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientNodeState.java?rev=1299626&r1=1299625&r2=1299626&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientNodeState.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/TransientNodeState.java
Mon Mar 12 11:10:17 2012
@@ -51,7 +51,7 @@ public class TransientNodeState {
     private NodeState persistentNodeState;
     private NodeDelta nodeDelta;
 
-    private TransientNodeState(Context sessionContext, NodeDelta nodeDelta) {
+    public TransientNodeState(Context sessionContext, NodeDelta nodeDelta) {
         this.sessionContext = sessionContext;
         this.nodeDelta = nodeDelta;
     }
@@ -97,22 +97,23 @@ public class TransientNodeState {
         getNodeDelta().setValue(name, value);
     }
 
-    public boolean hasChildNodeStates() {
+    public boolean hasNodes() {
         return getNodes().hasNext();
     }
 
     public Iterator<TransientNodeState> getNodes() {
-        BatchIterator<ChildNodeEntry> persistedEntries = new BatchIterator<ChildNodeEntry>(BATCH_SIZE)
{
-            @Override
-            protected Iterator<? extends ChildNodeEntry> getBatch(long pos, long size)
{
-                return getPersistentNodeState().getChildNodeEntries(pos, size).iterator();
-            }
-        };
+        Iterator<? extends ChildNodeEntry> persistedEntries = flatten(
+            new BatchIterator<ChildNodeEntry>(BATCH_SIZE) {
+                @Override
+                protected Iterator<? extends ChildNodeEntry> getBatch(long pos, long
size) {
+                    return getPersistentNodeState().getChildNodeEntries(pos, size).iterator();
+                }
+        });
 
         final NodeDelta delta = getNodeDelta();
 
         // fixme: this is not safe against concurrent modifications. Either copy delta or
make NodeDelta immutable
-        Iterator<ChildNodeEntry> unmodifiedEntries = filter(flatten(persistedEntries),
+        Iterator<ChildNodeEntry> unmodifiedEntries = filter(persistedEntries,
                 new Predicate<ChildNodeEntry>() {
                     @Override
                     public boolean evaluate(ChildNodeEntry entry) {
@@ -186,18 +187,9 @@ public class TransientNodeState {
         getNodeDelta().setValue(name, null);
     }
 
-    public static TransientNodeState getNodeState(Context sessionContext, Path path) {
-        NodeDelta delta = sessionContext.getTransientSpace().getNodeDelta(path);
-        return delta == null ? null : getNodeState(sessionContext, delta);
-    }
-
-    public static boolean hasNodeState(Context sessionContext, Path path) {
-        return getNodeState(sessionContext, path) != null;
-    }
-
     @Override
     public String toString() {
-        return getPath().toString();
+        return "TransientNodeState(" + getPath().toString() + ')';
     }
 
     //------------------------------------------< private >---



Mime
View raw message