jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r957133 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ItemImpl.java ItemManager.java NodeImpl.java SessionImpl.java SystemSession.java session/SessionContext.java
Date Wed, 23 Jun 2010 07:43:57 GMT
Author: jukka
Date: Wed Jun 23 07:43:56 2010
New Revision: 957133

URL: http://svn.apache.org/viewvc?rev=957133&view=rev
Log:
JCR-890: concurrent read-only access to a session

Move SessionItemStateManager and HierarchyManager into SessionContext.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.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/SystemSession.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java?rev=957133&r1=957132&r2=957133&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
Wed Jun 23 07:43:56 2010
@@ -123,7 +123,7 @@ public abstract class ItemImpl implement
     ItemImpl(ItemManager itemMgr, SessionContext sessionContext, ItemData data) {
         this.sessionContext = sessionContext;
         this.session = sessionContext.getSessionImpl();
-        this.stateMgr = session.getItemStateManager();
+        this.stateMgr = sessionContext.getItemStateManager();
         this.id = data.getId();
         this.itemMgr = itemMgr;
         this.data = data;

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=957133&r1=957132&r2=957133&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 Jun 23 07:43:56 2010
@@ -121,20 +121,16 @@ public class ItemManager implements Dump
     /**
      * Creates a new per-session instance <code>ItemManager</code> instance.
      *
-     * @param sism        the item state manager associated with the new
-     *                    instance
-     * @param hierMgr     the hierarchy manager
      * @param sessionContext component context of the associated session
      * @param rootNodeDef the definition of the root node
      * @param rootNodeId  the id of the root node
      * @param dataStore   the data store of this repository, or <code>null</code>
      */
     protected ItemManager(
-            SessionItemStateManager sism, HierarchyManager hierMgr,
             SessionContext sessionContext, NodeDefinitionImpl rootNodeDef,
             NodeId rootNodeId, DataStore dataStore) {
-        this.sism = sism;
-        this.hierMgr = hierMgr;
+        this.sism = sessionContext.getItemStateManager();
+        this.hierMgr = sessionContext.getHierarchyManager();
         this.sessionContext = sessionContext;
         this.session = sessionContext.getSessionImpl();
         this.rootNodeDef = rootNodeDef;
@@ -151,9 +147,6 @@ public class ItemManager implements Dump
     /**
      * 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 sessionContext component context of the associated session
      * @param rootNodeDef       the definition of the root node
      * @param rootNodeId        the id of the root node
@@ -161,16 +154,13 @@ public class ItemManager implements Dump
      * @return the item manager instance.
      */
     public static ItemManager createInstance(
-            SessionItemStateManager itemStateProvider,
-            HierarchyManager hierMgr,
             SessionContext sessionContext,
             NodeDefinitionImpl rootNodeDef,
             NodeId rootNodeId,
             DataStore dataStore) {
         ItemManager mgr = new ItemManager(
-                itemStateProvider, hierMgr, sessionContext, rootNodeDef,
-                rootNodeId, dataStore);
-        itemStateProvider.addListener(mgr);
+                sessionContext, rootNodeDef, rootNodeId, dataStore);
+        sessionContext.getItemStateManager().addListener(mgr);
         return mgr;
     }
 
@@ -1134,12 +1124,11 @@ public class ItemManager implements Dump
                 case ItemState.STATUS_EXISTING_MODIFIED:
                 case ItemState.STATUS_STALE_MODIFIED:
                     ItemState persistentState = discarded.getOverlayedState();
-                    /**
-                     * the state is a transient wrapper for the underlying
-                     * persistent state, therefore restore the persistent state
-                     * and resurrect this item instance if necessary
-                     */
-                    SessionItemStateManager stateMgr = session.getItemStateManager();
+                    // the state is a transient wrapper for the underlying
+                    // persistent state, therefore restore the persistent state
+                    // and resurrect this item instance if necessary
+                    SessionItemStateManager stateMgr =
+                        sessionContext.getItemStateManager();
                     stateMgr.disconnectTransientItemState(discarded);
                     data.setState(persistentState);
                     return;

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=957133&r1=957132&r2=957133&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
Wed Jun 23 07:43:56 2010
@@ -3148,11 +3148,11 @@ public class NodeImpl extends ItemImpl i
                     return true;
                 }
                 state = (NodeState)
-                    session.getItemStateManager().getItemState(parentId);
+                    sessionContext.getItemStateManager().getItemState(parentId);
             }
             PropertyId id = new PropertyId(state.getNodeId(), JCR_ISCHECKEDOUT);
             PropertyState ps =
-                (PropertyState) session.getItemStateManager().getItemState(id);
+                (PropertyState) sessionContext.getItemStateManager().getItemState(id);
             return ps.getValues()[0].getBoolean();
         } catch (ItemStateException e) {
             throw new RepositoryException(e);

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=957133&r1=957132&r2=957133&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 Jun 23 07:43:56 2010
@@ -167,16 +167,6 @@ public class SessionImpl extends Abstrac
     protected AccessManager accessMgr;
 
     /**
-     * the item state mgr associated with this session
-     */
-    protected final SessionItemStateManager itemStateMgr;
-
-    /**
-     * the HierarchyManager associated with this session
-     */
-    protected final HierarchyManager hierMgr;
-
-    /**
      * the item mgr associated with this session
      */
     protected final ItemManager itemMgr;
@@ -283,10 +273,10 @@ public class SessionImpl extends Abstrac
                 repositoryContext.getNodeTypeRegistry(), this,
                 repositoryContext.getDataStore());
         wsp = createWorkspaceInstance(wspConfig);
-        itemStateMgr = createSessionItemStateManager(wsp.getItemStateManager());
-        hierMgr = itemStateMgr.getHierarchyMgr();
-        itemMgr = createItemManager(itemStateMgr, hierMgr);
-        accessMgr = createAccessManager(subject, itemStateMgr.getHierarchyMgr());
+        context.setItemStateManager(
+                createSessionItemStateManager(wsp.getItemStateManager()));
+        itemMgr = createItemManager();
+        accessMgr = createAccessManager(subject);
         versionMgr = createVersionManager();
         ntInstanceHandler = new NodeTypeInstanceHandler(userId);
     }
@@ -330,11 +320,9 @@ public class SessionImpl extends Abstrac
      * Create the item manager.
      * @return item manager
      */
-    protected ItemManager createItemManager(SessionItemStateManager itemStateMgr,
-                                            HierarchyManager hierMgr) {
+    protected ItemManager createItemManager() {
         return ItemManager.createInstance(
-                itemStateMgr, hierMgr, context,
-                ntMgr.getRootNodeDefinition(),
+                context, ntMgr.getRootNodeDefinition(),
                 repositoryContext.getRootNodeId(),
                 repositoryContext.getDataStore());
     }
@@ -353,14 +341,12 @@ public class SessionImpl extends Abstrac
      * Create the access manager.
      *
      * @param subject
-     * @param hierarchyManager
      * @return access manager
      * @throws AccessDeniedException if the current subject is not granted access
      *                               to the current workspace
      * @throws RepositoryException   if the access manager cannot be instantiated
      */
-    protected AccessManager createAccessManager(Subject subject,
-                                                HierarchyManager hierarchyManager)
+    protected AccessManager createAccessManager(Subject subject)
             throws AccessDeniedException, RepositoryException {
         String wspName = getWorkspace().getName();
         AMContext ctx = new AMContext(
@@ -368,7 +354,7 @@ public class SessionImpl extends Abstrac
                 repositoryContext.getFileSystem(),
                 this,
                 getSubject(),
-                hierarchyManager,
+                context.getHierarchyManager(),
                 this,
                 wspName);
         return repositoryContext.getSecurityManager().getAccessManager(this, ctx);
@@ -467,21 +453,12 @@ public class SessionImpl extends Abstrac
     }
 
     /**
-     * Returns the <code>SessionItemStateManager</code> associated with this
session.
-     *
-     * @return the <code>SessionItemStateManager</code> associated with this
session
-     */
-    protected SessionItemStateManager getItemStateManager() {
-        return itemStateMgr;
-    }
-
-    /**
      * Returns the <code>HierarchyManager</code> associated with this session.
      *
      * @return the <code>HierarchyManager</code> associated with this session
      */
     public HierarchyManager getHierarchyManager() {
-        return hierMgr;
+        return context.getHierarchyManager();
     }
 
     /**
@@ -905,7 +882,7 @@ public class SessionImpl extends Abstrac
                 if (hasPermission("/", ACTION_READ)) {
                     getItemManager().getRootNode().save();
                 } else {
-                    NodeId id = getItemStateManager().getIdOfRootTransientNodeState();
+                    NodeId id = context.getItemStateManager().getIdOfRootTransientNodeState();
                     getItemManager().getItem(id).save();
                 }
             }
@@ -932,7 +909,7 @@ public class SessionImpl extends Abstrac
                 }
 
                 if (!keepChanges) {
-                    itemStateMgr.disposeAllTransientItemStates();
+                    context.getItemStateManager().disposeAllTransientItemStates();
                 } else {
                     // FIXME should reset Item#status field to STATUS_NORMAL
                     // of all non-transient instances; maybe also
@@ -965,7 +942,7 @@ public class SessionImpl extends Abstrac
         // check sanity of this session
         sanityCheck();
 
-        return itemStateMgr.hasAnyTransientItemStates();
+        return context.getItemStateManager().hasAnyTransientItemStates();
     }
 
     /**
@@ -1027,7 +1004,7 @@ public class SessionImpl extends Abstrac
             throw new RepositoryException(msg, e);
         }
 
-        if (hierMgr.isShareAncestor(targetNode.getNodeId(), destParentNode.getNodeId()))
{
+        if (context.getHierarchyManager().isShareAncestor(targetNode.getNodeId(), destParentNode.getNodeId()))
{
             String msg = destAbsPath + ": invalid destination path (share cycle detected)";
             log.debug(msg);
             throw new RepositoryException(msg);
@@ -1215,13 +1192,13 @@ public class SessionImpl extends Abstrac
 
         // discard any pending changes first as those might
         // interfere with subsequent operations
-        itemStateMgr.disposeAllTransientItemStates();
+        context.getItemStateManager().disposeAllTransientItemStates();
 
         // notify listeners that session is about to be closed
         notifyLoggingOut();
 
         // dispose session item state manager
-        itemStateMgr.dispose();
+        context.getItemStateManager().dispose();
         // dispose item manager
         itemMgr.dispose();
         // dispose workspace
@@ -1658,7 +1635,7 @@ public class SessionImpl extends Abstrac
         ps.println();
         itemMgr.dump(ps);
         ps.println();
-        itemStateMgr.dump(ps);
+        context.getItemStateManager().dump(ps);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SystemSession.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SystemSession.java?rev=957133&r1=957132&r2=957133&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SystemSession.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SystemSession.java
Wed Jun 23 07:43:56 2010
@@ -96,17 +96,12 @@ class SystemSession extends SessionImpl 
      * Overridden in order to create custom access manager
      *
      * @return access manager for system session
-     * @throws AccessDeniedException is never thrown
-     * @throws RepositoryException   is never thrown
      */
-    protected AccessManager createAccessManager(Subject subject,
-                                                HierarchyManager hierMgr)
-            throws AccessDeniedException, RepositoryException {
-        /**
-         * use own AccessManager implementation rather than relying on
-         * configurable AccessManager to handle SystemPrincipal privileges
-         * correctly
-         */
+    @Override
+    protected AccessManager createAccessManager(Subject subject) {
+        // use own AccessManager implementation rather than relying on
+        // configurable AccessManager to handle SystemPrincipal privileges
+        // correctly
         return new SystemAccessManager();
     }
 
@@ -246,7 +241,7 @@ class SystemSession extends SessionImpl 
             if (!p.isAbsolute()) {
                 throw new RepositoryException("Absolute path expected.");
             }
-            if (hierMgr.resolveNodePath(p) == null) {
+            if (context.getHierarchyManager().resolveNodePath(p) == null) {
                 throw new PathNotFoundException("No such node " + absPath);
             }
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java?rev=957133&r1=957132&r2=957133&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionContext.java
Wed Jun 23 07:43:56 2010
@@ -16,7 +16,9 @@
  */
 package org.apache.jackrabbit.core.session;
 
+import org.apache.jackrabbit.core.HierarchyManager;
 import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.state.SessionItemStateManager;
 
 public class SessionContext {
 
@@ -24,6 +26,11 @@ public class SessionContext {
 
     private volatile SessionState state;
 
+    /**
+     * The item state manager associated with this session
+     */
+    private volatile SessionItemStateManager itemStateManager;
+
     public SessionContext(SessionImpl session) {
         this.session = session;
     }
@@ -40,4 +47,19 @@ public class SessionContext {
         this.state = state;
     }
 
+    public SessionItemStateManager getItemStateManager() {
+        assert itemStateManager != null;
+        return itemStateManager;
+    }
+
+    public void setItemStateManager(SessionItemStateManager itemStateManager) {
+        assert itemStateManager != null;
+        this.itemStateManager = itemStateManager;
+    }
+
+    public HierarchyManager getHierarchyManager() {
+        assert itemStateManager != null;
+        return itemStateManager.getHierarchyMgr();
+    }
+
 }



Mime
View raw message