jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r801104 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ItemManager.java SessionImpl.java state/SessionItemStateManager.java
Date Wed, 05 Aug 2009 09:32:12 GMT
Author: mreutegg
Date: Wed Aug  5 09:32:11 2009
New Revision: 801104

URL: http://svn.apache.org/viewvc?rev=801104&view=rev
Log:
JCR-2237: ItemManager registers itself as listener too early

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java?rev=801104&r1=801103&r2=801104&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
Wed Aug  5 09:32:11 2009
@@ -125,13 +125,35 @@
 
         // setup item cache with weak references to items
         itemCache = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.WEAK);
-        itemStateProvider.addListener(this);
 
         // setup shareable nodes cache
         shareableNodesCache = new ShareableNodesCache();
     }
 
     /**
+     * Creates a new per-session instance <code>ItemManager</code> instance.
+     *
+     * @param itemStateProvider the item state provider associated with
+     *                          the new instance
+     * @param hierMgr           the hierarchy manager
+     * @param session           the session associated with the new instance
+     * @param rootNodeDef       the definition of the root node
+     * @param rootNodeId        the id of the root node
+     * @return the item manager instance.
+     */
+    public static ItemManager createInstance(
+            SessionItemStateManager itemStateProvider,
+            HierarchyManager hierMgr,
+            SessionImpl session,
+            NodeDefinition rootNodeDef,
+            NodeId rootNodeId) {
+        ItemManager mgr = new ItemManager(itemStateProvider, hierMgr,
+                session, rootNodeDef, rootNodeId);
+        itemStateProvider.addListener(mgr);
+        return mgr;
+    }
+
+    /**
      * Disposes this <code>ItemManager</code> and frees resources.
      */
     void dispose() {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=801104&r1=801103&r2=801104&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
Wed Aug  5 09:32:11 2009
@@ -307,7 +307,7 @@
      * @return session item state manager
      */
     protected SessionItemStateManager createSessionItemStateManager(LocalItemStateManager
manager) {
-        return new SessionItemStateManager(
+        return SessionItemStateManager.createInstance(
                 rep.getRootNodeId(), manager, rep.getNodeTypeRegistry());
     }
 
@@ -334,7 +334,7 @@
      */
     protected ItemManager createItemManager(SessionItemStateManager itemStateMgr,
                                             HierarchyManager hierMgr) {
-        return new ItemManager(itemStateMgr, hierMgr, this,
+        return ItemManager.createInstance(itemStateMgr, hierMgr, this,
                 ntMgr.getRootNodeDefinition(), rep.getRootNodeId());
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java?rev=801104&r1=801103&r2=801104&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
Wed Aug  5 09:32:11 2009
@@ -93,14 +93,13 @@
      * @param stateMgr the local item state manager
      * @param ntReg node type registry
      */
-    public SessionItemStateManager(NodeId rootNodeId,
+    protected SessionItemStateManager(NodeId rootNodeId,
                                    LocalItemStateManager stateMgr,
                                    NodeTypeRegistry ntReg) {
         transientStore = new ItemStateMap();
         atticStore = new ItemStateMap();
 
         this.stateMgr = stateMgr;
-        stateMgr.addListener(this);
 
         // create hierarchy manager that uses both transient and persistent state
         hierMgr = new CachingHierarchyManager(rootNodeId, this);
@@ -110,6 +109,24 @@
     }
 
     /**
+     * Creates a new <code>SessionItemStateManager</code> instance.
+     *
+     * @param rootNodeId the root node id
+     * @param stateMgr the local item state manager
+     * @param ntReg node type registry
+     * @return the session item state manager.
+     */
+    public static SessionItemStateManager createInstance(
+            NodeId rootNodeId,
+            LocalItemStateManager stateMgr,
+            NodeTypeRegistry ntReg) {
+        SessionItemStateManager mgr = new SessionItemStateManager(
+                rootNodeId, stateMgr, ntReg);
+        stateMgr.addListener(mgr);
+        return mgr;
+    }
+
+    /**
      * Returns the hierarchy manager
      *
      * @return the hierarchy manager



Mime
View raw message