jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r423943 - /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/
Date Thu, 20 Jul 2006 14:20:27 GMT
Author: tripod
Date: Thu Jul 20 07:20:26 2006
New Revision: 423943

URL: http://svn.apache.org/viewvc?rev=423943&view=rev
Log:
JCR-486: Removed version is not invalidated

Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFreezeImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNode.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenVHImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionItemImpl.java
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java?rev=423943&r1=423942&r2=423943&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/AbstractVersionManager.java
Thu Jul 20 07:20:26 2006
@@ -451,4 +451,13 @@
      */
     protected void versionDestroyed(InternalVersion version) {
     }
+
+    /**
+     * Invoked by the internal version item itself, when it's underlying
+     * persistence state was discarded.
+     *
+     * @param item
+     */
+    protected void itemDiscarded(InternalVersionItem item) {
+    }
 }

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFreezeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFreezeImpl.java?rev=423943&r1=423942&r2=423943&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFreezeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFreezeImpl.java
Thu Jul 20 07:20:26 2006
@@ -33,8 +33,8 @@
      * @param vMgr
      * @param parent
      */
-    protected InternalFreezeImpl(AbstractVersionManager vMgr, InternalVersionItem parent)
{
-        super(vMgr);
+    protected InternalFreezeImpl(AbstractVersionManager vMgr, NodeStateEx node, InternalVersionItem
parent) {
+        super(vMgr, node);
         this.parent = parent;
     }
 

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNode.java?rev=423943&r1=423942&r2=423943&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNode.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNode.java
Thu Jul 20 07:20:26 2006
@@ -72,6 +72,6 @@
      * @return <code>true</code> if this node has the history;
      *         <code>false</code> otherwise.
      */
-    boolean hasFrozenHistory(UUID uud);
+    boolean hasFrozenHistory(UUID uuid);
 
 }

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java?rev=423943&r1=423942&r2=423943&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java
Thu Jul 20 07:20:26 2006
@@ -61,11 +61,6 @@
     private static final int MODE_COPY_RECURSIVE = 3;
 
     /**
-     * the underlying persistance node
-     */
-    private NodeStateEx node;
-
-    /**
      * the list of frozen properties
      */
     private PropertyState[] frozenProperties;
@@ -99,8 +94,7 @@
     public InternalFrozenNodeImpl(AbstractVersionManager vMgr, NodeStateEx node,
                                   InternalVersionItem parent)
             throws RepositoryException {
-        super(vMgr, parent);
-        this.node = node;
+        super(vMgr, node, parent);
 
         // init the frozen properties
         PropertyState[] props;

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenVHImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenVHImpl.java?rev=423943&r1=423942&r2=423943&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenVHImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenVHImpl.java
Thu Jul 20 07:20:26 2006
@@ -30,19 +30,13 @@
         implements InternalFrozenVersionHistory {
 
     /**
-     * the underlying persistence node
-     */
-    private NodeStateEx node;
-
-    /**
      * Creates a new frozen version history.
      *
      * @param node
      */
     public InternalFrozenVHImpl(AbstractVersionManager vMgr, NodeStateEx node,
                                 InternalVersionItem parent) {
-        super(vMgr, parent);
-        this.node = node;
+        super(vMgr, node, parent);
     }
 
 

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java?rev=423943&r1=423942&r2=423943&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
Thu Jul 20 07:20:26 2006
@@ -74,11 +74,6 @@
     private HashMap tempVersionCache = new HashMap();
 
     /**
-     * The nodes state of this version history
-     */
-    private NodeStateEx node;
-
-    /**
      * the node that holds the label nodes
      */
     private NodeStateEx labelNode;
@@ -98,8 +93,7 @@
      */
     public InternalVersionHistoryImpl(AbstractVersionManager vMgr, NodeStateEx node)
             throws RepositoryException {
-        super(vMgr);
-        this.node = node;
+        super(vMgr, node);
         init();
     }
 

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java?rev=423943&r1=423942&r2=423943&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionImpl.java
Thu Jul 20 07:20:26 2006
@@ -37,11 +37,6 @@
         implements InternalVersion {
 
     /**
-     * the underlying persistance node of this version
-     */
-    private NodeStateEx node;
-
-    /**
      * the date when this version was created
      */
     private Calendar created;
@@ -74,9 +69,8 @@
      * @param node
      */
     public InternalVersionImpl(InternalVersionHistoryImpl vh, NodeStateEx node, QName name)
{
-        super(vh.getVersionManager());
+        super(vh.getVersionManager(), node);
         this.versionHistory = vh;
-        this.node = node;
         this.name = name;
 
         // init internal values

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionItemImpl.java?rev=423943&r1=423942&r2=423943&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionItemImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/InternalVersionItemImpl.java
Thu Jul 20 07:20:26 2006
@@ -17,11 +17,18 @@
 package org.apache.jackrabbit.core.version;
 
 import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.state.ItemStateListener;
+import org.apache.jackrabbit.core.state.ItemState;
 
 /**
  * Implements a <code>InternalVersionItem</code>.
  */
-abstract class InternalVersionItemImpl implements InternalVersionItem {
+abstract class InternalVersionItemImpl implements InternalVersionItem, ItemStateListener
{
+
+    /**
+     * the underlying persistance node
+     */
+    protected final NodeStateEx node;
 
     /**
      * the version manager
@@ -33,8 +40,13 @@
      *
      * @param vMgr
      */
-    protected InternalVersionItemImpl(AbstractVersionManager vMgr) {
+    protected InternalVersionItemImpl(AbstractVersionManager vMgr, NodeStateEx node) {
         this.vMgr = vMgr;
+        this.node = node;
+        // register as listener. this is not the best solution since this item
+        // could be discarded by the GC and then later be recreated. this will
+        // unnecessarily increase the number of listeners.
+        node.getState().addListener(this);
     }
 
     /**
@@ -59,5 +71,41 @@
      * @return the parent version item or <code>null</code>.
      */
     public abstract InternalVersionItem getParent();
+
+    //-----------------------------------------------------< ItemStateListener >
+    // handle notifications from underlying item states. currently, we only need
+    // to care about removals, since the versioning items do not cache their
+    // values
+
+    /**
+     * {@inheritDoc}
+     */
+    public void stateCreated(ItemState item) {
+        // ignore
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void stateModified(ItemState item) {
+        // ignore
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void stateDestroyed(ItemState item) {
+        vMgr.itemDiscarded(this);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void stateDiscarded(ItemState item) {
+        // ignore
+    }
+
+
+
 
 }

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java?rev=423943&r1=423942&r2=423943&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Thu Jul 20 07:20:26 2006
@@ -252,6 +252,8 @@
                         } else {
                             return null;
                         }
+                    } else {
+                        return null;
                     }
                     versionItems.put(id, item);
                 }
@@ -368,6 +370,16 @@
         } finally {
             releaseReadLock();
         }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void itemDiscarded(InternalVersionItem item) {
+        // evict removed item from cache
+        aquireReadLock();
+        versionItems.remove(item.getId());
+        releaseReadLock();
     }
 
     /**



Mime
View raw message