jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1183414 - in /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ./ hierarchy/ lock/ state/
Date Fri, 14 Oct 2011 16:34:20 GMT
Author: mduerig
Date: Fri Oct 14 16:34:19 2011
New Revision: 1183414

URL: http://svn.apache.org/viewvc?rev=1183414&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP)
remove MODIFIED status

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCache.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemLifeCycleListener.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/lock/LockStateManagerImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.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/Status.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCache.java?rev=1183414&r1=1183413&r2=1183414&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCache.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCache.java
Fri Oct 14 16:34:19 2011
@@ -96,12 +96,6 @@ public class ItemCache implements ItemLi
     }
 
     @Override
-    public void itemUpdated(ItemImpl<?> item, boolean modified) {
-        // do nothing: we don't touch the cache here since the LRU
-        // should only be affected by client side operations.
-    }
-
-    @Override
     public void itemDestroyed(ItemImpl<?> item) {
         evictItem(item.getItemState());
     }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java?rev=1183414&r1=1183413&r2=1183414&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
Fri Oct 14 16:34:19 2011
@@ -235,37 +235,18 @@ public abstract class ItemImpl<STATE_TYP
             throw e;
         }
 
-        switch (state.getStatus()) {
-            // Notify listeners about an update (status was MODIFIED before)
-            // or a simple refresh without modification (status was INVALIDATED).
-            case EXISTING:
-                if (previousStatus == Status.INVALIDATED || previousStatus == Status.MODIFIED)
{
-                    notifyUpdated(previousStatus == Status.MODIFIED);
-                }
-                break;
-
-            // Notify listeners that this item is transiently or permanently destroyed.
-            // - Status#REMOVED : permanent removal. item will never get back to life
-            case REMOVED:
-                state.removeListener(this);
-                notifyDestroyed();
-                break;
-
-            // Invalid status. A state can never change its state to 'New'.
-            case NEW:
-                // should never happen.
-                log.error("invalid state change to STATUS_NEW");
-                break;
-
-            // Nothing to do here 
-            case EXISTING_MODIFIED:   // transient modification
-            case STALE_MODIFIED:      // external modifications while transient changes pending
-            case STALE_DESTROYED:     // external modifications while transient changes pending
-            case MODIFIED:            // externally modified -> marker for sessionISM
states only
-            case EXISTING_REMOVED:    // transient removal
-            case _UNDEFINED_:
-            case INVALIDATED:
-                break;
+        Status status = state.getStatus();
+        if (status == Status.NEW) {
+            // Invalid: state can never change to NEW
+            IllegalArgumentException e = new IllegalArgumentException("Invalid state change
to status NEW");
+            log.error(e.getMessage(), e);
+            throw e;
+        }
+
+        if (status == Status.REMOVED) {
+            // permanent removal. item will never get back to life
+            state.removeListener(this);
+            notifyDestroyed();
         }
     }
 
@@ -281,15 +262,6 @@ public abstract class ItemImpl<STATE_TYP
     }
 
     /**
-     * Notify the listeners that this instance has been updated.
-     */
-    private void notifyUpdated(boolean modified) {
-        if (listener != null) {
-            listener.itemUpdated(this, modified);
-        }
-    }
-
-    /**
      * Notify the listeners that this instance has been destroyed.
      */
     private void notifyDestroyed() {

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemLifeCycleListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemLifeCycleListener.java?rev=1183414&r1=1183413&r2=1183414&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemLifeCycleListener.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemLifeCycleListener.java
Fri Oct 14 16:34:19 2011
@@ -30,15 +30,6 @@ public interface ItemLifeCycleListener {
     void itemCreated(ItemImpl<?> item);
 
     /**
-     * Called when an {@code Item} instance has been refreshed. If
-     * {@code modified} is {@code true}, the refresh included
-     * some modification.
-     *
-     * @param item the instance which has been refreshed
-     */
-    void itemUpdated(ItemImpl<?> item, boolean modified);
-
-    /**
      * Called when an {@code ItemImpl} instance has been destroyed
      * (i.e. it has been permanently rendered 'invalid').
      * <p/>

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=1183414&r1=1183413&r2=1183414&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:34:19 2011
@@ -333,11 +333,9 @@ public abstract class HierarchyEntry<STA
             Status currentStatus = currentState.getStatus();
             boolean keepChanges = Status.isTransient(currentStatus) || Status.isStale(currentStatus);
             MergeResult mergeResult = currentState.merge(state, keepChanges);
-            if (currentStatus == Status.INVALIDATED) {
+            if (currentStatus == Status.INVALIDATED || mergeResult.modified()) {
                 currentState.setStatus(Status.EXISTING);
-            } else if (mergeResult.modified()) {
-                currentState.setStatus(Status.MODIFIED);
-            } // else: not modified. just leave status as it is.
+            }
             mergeResult.dispose();
         }
     }
@@ -403,7 +401,6 @@ public abstract class HierarchyEntry<STA
             case _UNDEFINED_:
             case INVALIDATED:
             case EXISTING:
-            case MODIFIED:
             case REMOVED:
                 // Cannot revert EXISTING, REMOVED, INVALIDATED, MODIFIED states.
                 // State was implicitly reverted or external modifications
@@ -495,7 +492,6 @@ public abstract class HierarchyEntry<STA
             case INVALIDATED:
             case EXISTING_REMOVED:
             case STALE_MODIFIED:
-            case MODIFIED:
                 throw new RepositoryException("Cannot transiently remove an ItemState with
status " + state.getStatus());
         }
     }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockStateManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockStateManagerImpl.java?rev=1183414&r1=1183413&r2=1183414&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockStateManagerImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/lock/LockStateManagerImpl.java
Fri Oct 14 16:34:19 2011
@@ -581,24 +581,10 @@ public class LockStateManagerImpl implem
                 return;
             }
 
-            switch (state.getStatus()) {
-                case REMOVED:
-                    // this lock has been release by someone else (and not by
-                    // a call to LockManager#unlock -> clean up and set isLive
-                    // flag to false.
-                    unlocked();
-                    break;
-                case _UNDEFINED_:
-                case INVALIDATED:
-                case EXISTING:
-                case EXISTING_MODIFIED:
-                case EXISTING_REMOVED:
-                case NEW:
-                case STALE_MODIFIED:
-                case STALE_DESTROYED:
-                case MODIFIED:
-                    // not interested
-                    break;
+            if (state.getStatus() == Status.REMOVED) {
+                // this lock has been release by someone else (and not by a call to LockManager#unlock
+                // -> clean up and set isLive flag to false.
+                unlocked();
             }
         }
     }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.java?rev=1183414&r1=1183413&r2=1183414&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.java
Fri Oct 14 16:34:19 2011
@@ -128,7 +128,6 @@ public class ChangeLog {
                     entry.invalidate(false);
                     break;
                 case NEW:
-                case MODIFIED:
                 case _UNDEFINED_:
                 case STALE_DESTROYED:
                 case STALE_MODIFIED:
@@ -159,7 +158,6 @@ public class ChangeLog {
                     state.getHierarchyEntry().revert();
                     break;
                 case NEW:
-                case MODIFIED:
                 case _UNDEFINED_:
                     IllegalStateException e = new IllegalStateException("ChangeLog contains
state (" + state.getName() +
                             ") with illegal status " + state.getStatus());

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=1183414&r1=1183413&r2=1183414&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:34:19 2011
@@ -248,12 +248,6 @@ public abstract class ItemState<ENTRY_TY
                 aLa.statusChanged(this, oldStatus);
             }
         }
-
-        if (status == Status.MODIFIED) {
-            // change back tmp MODIFIED status, that is used as marker only
-            // inform listeners about (external) changes.
-            status = Status.EXISTING;
-        }
     }
 
     /**

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/Status.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/Status.java?rev=1183414&r1=1183413&r2=1183414&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/Status.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/Status.java
Fri Oct 14 16:34:19 2011
@@ -41,13 +41,6 @@ public enum Status {
     STALE_DESTROYED,
 
     /**
-     * Temporary status used to mark a state, this is permanently modified
-     * either by saving transient changes, by workspace operations or by
-     * external modification.
-     */
-    MODIFIED,
-
-    /**
      * a new state was removed and is now 'removed'
      * or an existing item has been removed by a workspace operation or
      * by an external modification.
@@ -142,8 +135,7 @@ public enum Status {
                        || oldStatus == NEW                // save
                        || oldStatus == EXISTING_MODIFIED  // save, revert
                        || oldStatus == EXISTING_REMOVED   // revert
-                       || oldStatus == STALE_MODIFIED     // revert
-                       || oldStatus == MODIFIED;
+                       || oldStatus == STALE_MODIFIED;    // revert
                 // REMOVED, STALE_DESTROYED -> false
                 break;
             case EXISTING_MODIFIED:
@@ -159,12 +151,9 @@ public enum Status {
                        || oldStatus == EXISTING_REMOVED
                        || oldStatus == STALE_MODIFIED;
                 break;
-            case REMOVED:      // removal always possible -> getNewStatus(int, int)
+            case REMOVED:      // removal always possible -> getNewStatus(Status, Status)
                 isValid = true;
                 break;
-            case MODIFIED:     // except for NEW states an external modification is always
valid
-                isValid = oldStatus != NEW;
-                break;
             case NEW:          // cannot change state to NEW -> false
             case _UNDEFINED_:  // cannot change state to _UNDEFINED_ -> false
                 break;
@@ -182,37 +171,12 @@ public enum Status {
      * @return new status that takes transient modification/removal into account.
      */
     public static Status getNewStatus(Status oldStatus, Status newStatusHint) {
-        Status newStatus = newStatusHint;
-        switch (newStatusHint) {
-            case MODIFIED:
-                // underlying state has been modified by external changes
-                if (oldStatus == EXISTING || oldStatus == INVALIDATED) {
-                    // temporarily set the state to MODIFIED in order to inform listeners.
-                    newStatus = MODIFIED;
-                } else if (oldStatus == EXISTING_MODIFIED) {
-                    newStatus = STALE_MODIFIED;
-                } else {
-                    // old status is EXISTING_REMOVED (or any other) => ignore.
-                    // a NEW state may never be marked modified.
-                    newStatus = oldStatus;
-                }
-                break;
-            case REMOVED:
-                if (oldStatus == EXISTING_MODIFIED || oldStatus == STALE_MODIFIED) {
-                    newStatus = STALE_DESTROYED;
-                }
-                break;
-            case _UNDEFINED_:
-            case INVALIDATED:
-            case EXISTING:
-            case EXISTING_MODIFIED:
-            case EXISTING_REMOVED:
-            case NEW:
-            case STALE_MODIFIED:
-            case STALE_DESTROYED:
-                break;
+        if (newStatusHint == REMOVED && (oldStatus == EXISTING_MODIFIED || oldStatus
== STALE_MODIFIED)) {
+            return STALE_DESTROYED;
+        }
+        else {
+            return newStatusHint;
         }
-        return newStatus;
     }
 
 }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java?rev=1183414&r1=1183413&r2=1183414&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java
Fri Oct 14 16:34:19 2011
@@ -244,7 +244,6 @@ public class TransientItemStateManager i
                     case INVALIDATED:
                     case EXISTING:
                     case STALE_DESTROYED:
-                    case MODIFIED:
                     case REMOVED:
                         // INVALIDATED, MODIFIED ignore. no effect to transient modifications.
                         // any other status change is invalid -> see Status#isValidStatusChange(int,
int
@@ -277,7 +276,6 @@ public class TransientItemStateManager i
                     case EXISTING_MODIFIED:
                     case STALE_MODIFIED:
                     case STALE_DESTROYED:
-                    case MODIFIED:
                     case REMOVED:
                         break;
                 }
@@ -293,7 +291,6 @@ public class TransientItemStateManager i
                 modifiedStates.remove(state);
                 staleStates.add(state);
                 break;
-            case MODIFIED:
             case INVALIDATED:
                 // MODIFIED, INVALIDATED: ignore.
                 log.debug("Item " + state.getName() + " changed status from " + previousStatus
+



Mime
View raw message