jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1185885 - in /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy: EntryFactory.java HierarchyEntry.java NodeEntry.java
Date Tue, 18 Oct 2011 21:43:08 GMT
Author: mduerig
Date: Tue Oct 18 21:43:07 2011
New Revision: 1185885

URL: http://svn.apache.org/viewvc?rev=1185885&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP)
simplification and clean up

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java?rev=1185885&r1=1185884&r2=1185885&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/EntryFactory.java
Tue Oct 18 21:43:07 2011
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.jcr2spi.hierarchy;
 
 import org.apache.jackrabbit.jcr2spi.LogUtil;
+import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry.EntryInvalidator;
 import org.apache.jackrabbit.jcr2spi.state.TransientItemStateFactory;
 import org.apache.jackrabbit.spi.IdFactory;
 import org.apache.jackrabbit.spi.Name;
@@ -54,10 +55,7 @@ public final class EntryFactory {
 
     private final NodeEntry rootEntry;
 
-    /**
-     * Strategy used for item state invalidation (refresh)
-     */
-    private final InvalidationStrategy invalidationStrategy;
+    private final EntryInvalidator entryInvalidator;
 
     /**
      * Create a new instance of the {@code EntryFactory}.
@@ -76,7 +74,7 @@ public final class EntryFactory {
         this.listener = listener;
         this.namePathResolver = namePathResolver;
 
-        invalidationStrategy = new NodeEntry.LazyInvalidation();
+        entryInvalidator = new EntryInvalidator();
         rootEntry = createNodeEntry(null, NameConstants.ROOT, null);
     }
 
@@ -118,10 +116,10 @@ public final class EntryFactory {
     }
 
     /**
-     * @return  the strategy used for item state invalidation (refresh)
+     * @return  the entry invalidator (refresh)
      */
-    public InvalidationStrategy getInvalidationStrategy() {
-        return invalidationStrategy;
+    public EntryInvalidator getEntryInvalidator() {
+        return entryInvalidator;
     }
 
     //--------------------------------------------------------------------------
@@ -145,32 +143,4 @@ public final class EntryFactory {
         void uniqueIdChanged(NodeEntry entry, String previousUniqueID);
     }
 
-    // ----------------------------------------------< InvalidationStrategy >---
-    
-    /**
-     * Strategy for invalidating item states
-     */
-    public interface InvalidationStrategy {
-
-        /**
-         * Invalidate underlying {@link org.apache.jackrabbit.jcr2spi.state.ItemState} of
this
-         * {@code entry}. Implementors may choose to delay the actual call to
-         * {@link org.apache.jackrabbit.jcr2spi.state.ItemState#invalidate()} for this
-         * {@code entry} and for any of its child entries. They need to ensure however that
-         * {@link #applyPending(HierarchyEntry)} properly invalidates the respective state
when called.
-         *
-         * @param entry The {@code HierarchyEntry} to invalidate.
-         * @param recursive Invalidate state of child entries if {@code true}.
-         */
-        void invalidate(HierarchyEntry<?> entry, boolean recursive);
-
-        /**
-         * Apply any pending {@link org.apache.jackrabbit.jcr2spi.state.ItemState#invalidate()
-         * invalidation} of the underlying {@link org.apache.jackrabbit.jcr2spi.state.ItemState}
of
-         * this {@code entry}.
-         *
-         * @param entry The affected {@code NodeEntry}.
-         */
-        void applyPending(HierarchyEntry<?> entry);
-    }
 }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java?rev=1185885&r1=1185884&r2=1185885&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java
Tue Oct 18 21:43:07 2011
@@ -112,14 +112,6 @@ public abstract class HierarchyEntry<STA
     }
 
     /**
-     * Shortcut for {@link EntryFactory#getInvalidationStrategy()}
-     * @return
-     */
-    protected EntryFactory.InvalidationStrategy getInvalidationStrategy() {
-        return factory.getInvalidationStrategy();
-    }
-
-    /**
      * Resolves this {@code HierarchyEntryImpl} and returns the target
      * {@code ItemState} of this reference.
      *
@@ -188,6 +180,31 @@ public abstract class HierarchyEntry<STA
         }
     }
 
+    /**
+     * @param staleParent
+     */
+    protected void remove(boolean staleParent) {
+        STATE_TYPE state = getItemState();
+        Status status = getStatus();
+        if (state != null) {
+            if (status == Status.EXISTING_MODIFIED) {
+                state.setStatus(Status.STALE_DESTROYED);
+            } else if (status == Status.NEW && staleParent) {
+                // keep status NEW
+            } else {
+                state.setStatus(Status.REMOVED);
+                if (!staleParent) {
+                    parent.internalRemoveChildEntry(this);
+                }
+            }
+        } else {
+            // unresolved
+            if (!staleParent && parent != null) {
+                parent.internalRemoveChildEntry(this);
+            }
+        }
+    }
+
     //-----------------------------------------------------< HierarchyEntry >---
 
     /**
@@ -334,7 +351,7 @@ public abstract class HierarchyEntry<STA
      * state in the repository.
      */
     public void invalidate(boolean recursive) {
-        getInvalidationStrategy().invalidate(this, recursive);
+        factory.getEntryInvalidator().invalidate(this, recursive);
     }
 
     /**
@@ -342,7 +359,7 @@ public abstract class HierarchyEntry<STA
      * changes to the underlying {@code ItemState} are applied.
      */
     public void calculateStatus() {
-        getInvalidationStrategy().applyPending(this);
+        factory.getEntryInvalidator().applyPending(this);
     }
 
     /**
@@ -487,43 +504,15 @@ public abstract class HierarchyEntry<STA
      * NodeEntry all descending ItemStates must get their status changed as well.
      */
     public void remove() {
-        internalRemove(false);
-    }
-
-    //--------------------------------------------------------------------------
-
-    /**
-     * @param staleParent
-     */
-    void internalRemove(boolean staleParent) {
-        STATE_TYPE state = getItemState();
-        Status status = getStatus();
-        if (state != null) {
-            if (status == Status.EXISTING_MODIFIED) {
-                state.setStatus(Status.STALE_DESTROYED);
-            } else if (status == Status.NEW && staleParent) {
-                // keep status NEW
-            } else {
-                state.setStatus(Status.REMOVED);
-                if (!staleParent) {
-                    parent.internalRemoveChildEntry(this);
-                }
-            }
-        } else {
-            // unresolved
-            if (!staleParent && parent != null) {
-                parent.internalRemoveChildEntry(this);
-            }
-        }
+        remove(false);
     }
 
-    // ----------------------------------------------< InvalidationStrategy >---
+    // ----------------------------------------------< EntryInvalidator >---
     
     /**
-     * An implementation of {@code InvalidationStrategy} which lazily invalidates
-     * the underlying {@link ItemState}s.
+     * An invalidator which lazily invalidates the underlying {@link ItemState}s.
      */
-    static class LazyInvalidation implements EntryFactory.InvalidationStrategy {
+    public static class EntryInvalidator {
 
         /**
          * Marker for entries with a pending recursive invalidation.
@@ -552,7 +541,6 @@ public abstract class HierarchyEntry<STA
          * invalidates the entry right away.
          * {@inheritDoc}
          */
-        @Override
         public void invalidate(HierarchyEntry<?> entry, boolean recursive) {
             if (recursive) {
                 entry.generation = INVALIDATION_PENDING;
@@ -577,7 +565,6 @@ public abstract class HierarchyEntry<STA
          * Otherwise this method does nothing.
          * {@inheritDoc}
          */
-        @Override
         public void applyPending(HierarchyEntry<?> entry) {
             if (!invalidating) {
                 invalidating = true;

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java?rev=1185885&r1=1185884&r2=1185885&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
Tue Oct 18 21:43:07 2011
@@ -247,25 +247,25 @@ public class NodeEntry extends Hierarchy
     @Override
     public void remove() {
         // handle this entry first
-        super.internalRemove(false);
+        super.remove(false);
         boolean staleParent = getStatus() == Status.STALE_DESTROYED;
         // now remove all child-entries (or mark them accordingly)
         for (Iterator<HierarchyEntry<?>> it = getAllChildEntries(true); it.hasNext();)
{
             HierarchyEntry<?> ce = it.next();
-            ce.internalRemove(staleParent);
+            ce.remove(staleParent);
         }
     }
 
     @Override
-    void internalRemove(boolean staleParent) {
+    protected void remove(boolean staleParent) {
         // handle this entry first
-        super.internalRemove(staleParent);
+        super.remove(staleParent);
         staleParent = staleParent || getStatus() == Status.STALE_DESTROYED;
 
         // now remove all child-entries (or mark them accordingly)
         for (Iterator<HierarchyEntry<?>> it = getAllChildEntries(true); it.hasNext();)
{
             HierarchyEntry<?> ce = it.next();
-            ce.internalRemove(staleParent);
+            ce.remove(staleParent);
         }
     }
 



Mime
View raw message