jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1183422 - in /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: hierarchy/HierarchyEntry.java state/ItemState.java state/NodeState.java state/PropertyState.java
Date Fri, 14 Oct 2011 16:57:35 GMT
Author: mduerig
Date: Fri Oct 14 16:57:35 2011
New Revision: 1183422

URL: http://svn.apache.org/viewvc?rev=1183422&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP)
remove node state diffing

Modified:
    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/state/ItemState.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java

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=1183422&r1=1183421&r2=1183422&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
Fri Oct 14 16:57:35 2011
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.jcr2spi.hi
 
 import org.apache.jackrabbit.jcr2spi.operation.Operation;
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
-import org.apache.jackrabbit.jcr2spi.state.ItemState.MergeResult;
 import org.apache.jackrabbit.jcr2spi.state.Status;
 import org.apache.jackrabbit.jcr2spi.state.TransientItemStateFactory;
 import org.apache.jackrabbit.spi.IdFactory;
@@ -332,11 +331,10 @@ public abstract class HierarchyEntry<STA
             // with the passed state.
             Status currentStatus = currentState.getStatus();
             boolean keepChanges = Status.isTransient(currentStatus) || Status.isStale(currentStatus);
-            MergeResult mergeResult = currentState.merge(state, keepChanges);
-            if (currentStatus == Status.INVALIDATED || mergeResult.modified()) {
+            currentState.merge(state, keepChanges);
+            if (currentStatus == Status.INVALIDATED) {
                 currentState.setStatus(Status.EXISTING);
             }
-            mergeResult.dispose();
         }
     }
 

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java?rev=1183422&r1=1183421&r2=1183422&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
Fri Oct 14 16:57:35 2011
@@ -258,9 +258,8 @@ public abstract class ItemState<ENTRY_TY
      *
      * @param another
      * @param keepChanges
-     * @return a MergeResult instance which represent the result of the merge operation
      */
-    public abstract MergeResult merge(ItemState<?> another, boolean keepChanges);
+    public abstract void merge(ItemState<?> another, boolean keepChanges);
 
     /**
      * Revert all transient modifications made to this ItemState.
@@ -315,51 +314,4 @@ public abstract class ItemState<ENTRY_TY
         }
     }
 
-    // -----------------------------------------------------< MergeResult >---
-
-    /**
-     * A MergeResult represents the result of a {@link ItemState#merge(ItemState, boolean)}
-     * operation.
-     */
-    public interface MergeResult {
-
-        /**
-         * @return  true iff the target state of {@link ItemState#merge(ItemState, boolean)}
-         * was modified.
-         */
-        boolean modified();
-
-        /**
-         * Dispose this MergeResult and release all internal resources that
-         * are not needed any more.
-         */
-        void dispose();
-    }
-
-    /**
-     * A SimpleMergeResult is just a holder for a modification status.
-     * The {@link #modified()} method just returns the modification status passed
-     * to the constructor.
-     */
-    protected static class SimpleMergeResult implements MergeResult {
-        private final boolean modified;
-
-        /**
-         * @param modified  modification status
-         */
-        public SimpleMergeResult(boolean modified) {
-            this.modified = modified;
-        }
-
-        @Override
-        public boolean modified() {
-            return modified;
-        }
-
-        @Override
-        public void dispose() {
-            // nothing to do.
-        }
-    }
-
 }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java?rev=1183422&r1=1183421&r2=1183422&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
Fri Oct 14 16:57:35 2011
@@ -113,8 +113,7 @@ public class NodeState extends ItemState
     }
 
     @Override
-    public MergeResult merge(ItemState<?> state, boolean keepChanges) {
-        boolean modified = false;
+    public void merge(ItemState<?> state, boolean keepChanges) {
         if (state != null && state != this) {
             if (!state.isNode()) {
                 IllegalArgumentException e = new IllegalArgumentException("Cannot merge node
state with property state");
@@ -126,22 +125,18 @@ public class NodeState extends ItemState
 
             if (!nodeTypeName.equals(otherState.nodeTypeName)) {
                 nodeTypeName = otherState.nodeTypeName;
-                modified = true;
             }
 
             if (otherState.definition != null && !otherState.definition.equals(definition))
{
                 definition = otherState.definition;
-                modified = true;
             }
 
             // since 'mixinTypeNames' are modified upon save only, no special
             // merging is required here. just reset the mixinTypeNames.
             if (!Arrays.containSameElements(otherState.mixinTypeNames, mixinTypeNames)) {
                 setMixinTypeNames(otherState.mixinTypeNames);
-                modified = true;
             }
         }
-        return new SimpleMergeResult(modified);
     }
 
     @Override

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java?rev=1183422&r1=1183421&r2=1183422&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
Fri Oct 14 16:57:35 2011
@@ -123,8 +123,7 @@ public class PropertyState extends ItemS
      *
      */
     @Override
-    public MergeResult merge(ItemState<?> state, boolean keepChanges) {
-        boolean modified = false;
+    public void merge(ItemState<?> state, boolean keepChanges) {
         if (state != null && state != this) {
             if (state.isNode()) {
                 IllegalArgumentException e = new IllegalArgumentException("Cannot merge property
state with node state");
@@ -133,23 +132,14 @@ public class PropertyState extends ItemS
             }
 
             PropertyData otherData = Unchecked.<PropertyState>cast(state).data;
-            PropertyDiffer result = new PropertyDiffer(data, otherData);
 
             // reset the pInfo to point to the pInfo of state.
             data = otherData;
-            // if transient changes should be preserved OR if there are not
-            // transient changes, return the differ and postpone the effort of
-            // calculating the diff (the test if this state got internally changed)).
-            if (keepChanges || transientData == null) {
-                return result;
-            } else {
-                result.dispose();
+            if (!keepChanges && transientData != null) {
                 transientData.discardValues();
                 transientData = null;
-                modified = true;
             }
         }
-        return new SimpleMergeResult(modified);
     }
 
     @Override
@@ -307,36 +297,6 @@ public class PropertyState extends ItemS
         ValueConstraint.checkValueConstraints(definition, values);
     }
 
-    /**
-     * Returns true, if type and/or values of the given property states differ.
-     *
-     * @param p1
-     * @param p2
-     * @return if the 2 {@code PropertyState}s are different in terms of
-     * type and/or values.
-     */
-    private static boolean diff(PropertyData p1, PropertyData p2) {
-        // compare type
-        if (p1.type != p2.type) {
-            return true;
-        }
-
-        QValue[] vs1 = p1.values;
-        QValue[] vs2 = p2.values;
-        if (vs1.length == vs2.length) {
-            for (int i = 0; i < vs1.length; i++) {
-                boolean eq = vs1[i] == null ? vs2[i] == null : vs1[i].equals(vs2[i]);
-                if (!eq) {
-                    return true;
-                }
-            }
-        } else {
-            return true;
-        }
-        // no difference
-        return false;
-    }
-
     //--------------------------------------------------------< inner class >---
 
     /**
@@ -381,36 +341,4 @@ public class PropertyState extends ItemS
         }
     }
 
-    /**
-     * Helper class for delayed determination of property differences.
-     */
-    private static class PropertyDiffer implements MergeResult {
-        private final PropertyData oldData;
-        private final PropertyData newData;
-
-        PropertyDiffer(PropertyData oldData, PropertyData newData) {
-            this.oldData = oldData;
-            this.newData = newData;
-        }
-
-        @Override
-        public boolean modified() {
-            if (oldData.discarded || newData.discarded) {
-                // cannot calculate the diff any more -> return true.
-                String msg = " Diff cannot be calculated: " + (oldData.discarded
-                    ? "Old property data"
-                    : "New property data") + " have already been discarded.";
-
-                log.debug(msg);
-                return true;
-            }
-            return diff(oldData, newData);
-        }
-
-        @Override
-        public void dispose() {
-            oldData.discardValues();
-        }
-    }
-
 }



Mime
View raw message