jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r957141 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ItemManager.java PropertyImpl.java RepositoryContext.java SessionImpl.java session/SessionContext.java state/SessionItemStateManager.java
Date Wed, 23 Jun 2010 08:19:15 GMT
Author: jukka
Date: Wed Jun 23 08:19:14 2010
New Revision: 957141

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

Leverage SessionContext in more places.

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/PropertyImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.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/session/SessionContext.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=957141&r1=957140&r2=957141&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 08:19:14 2010
@@ -91,7 +91,6 @@ public class ItemManager implements Dump
     private static Logger log = LoggerFactory.getLogger(ItemManager.class);
 
     private final org.apache.jackrabbit.spi.commons.nodetype.NodeDefinitionImpl rootNodeDef;
-    private final NodeId rootNodeId;
 
     /**
      * Component context of the associated session.
@@ -104,11 +103,6 @@ public class ItemManager implements Dump
     private final HierarchyManager hierMgr;
 
     /**
-     * The data store of this repository, or <code>null</code>
-     */
-    private final DataStore dataStore;
-
-    /**
      * A cache for item instances created by this <code>ItemManager</code>
      */
     private final Map<ItemId, ItemData> itemCache;
@@ -123,19 +117,14 @@ public class ItemManager implements Dump
      *
      * @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(
-            SessionContext sessionContext, NodeDefinitionImpl rootNodeDef,
-            NodeId rootNodeId, DataStore dataStore) {
+            SessionContext sessionContext, NodeDefinitionImpl rootNodeDef) {
         this.sism = sessionContext.getItemStateManager();
         this.hierMgr = sessionContext.getHierarchyManager();
         this.sessionContext = sessionContext;
         this.session = sessionContext.getSessionImpl();
         this.rootNodeDef = rootNodeDef;
-        this.rootNodeId = rootNodeId;
-        this.dataStore = dataStore;
 
         // setup item cache with weak references to items
         itemCache = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.WEAK);
@@ -145,26 +134,6 @@ public class ItemManager implements Dump
     }
 
     /**
-     * Creates a new per-session instance <code>ItemManager</code> instance.
-     *
-     * @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>
-     * @return the item manager instance.
-     */
-    public static ItemManager createInstance(
-            SessionContext sessionContext,
-            NodeDefinitionImpl rootNodeDef,
-            NodeId rootNodeId,
-            DataStore dataStore) {
-        ItemManager mgr = new ItemManager(
-                sessionContext, rootNodeDef, rootNodeId, dataStore);
-        sessionContext.getItemStateManager().addListener(mgr);
-        return mgr;
-    }
-
-    /**
      * Disposes this <code>ItemManager</code> and frees resources.
      */
     void dispose() {
@@ -176,7 +145,7 @@ public class ItemManager implements Dump
 
     NodeDefinitionImpl getDefinition(NodeState state)
             throws RepositoryException {
-        if (state.getId().equals(rootNodeId)) {
+        if (state.getId().equals(sessionContext.getRootNodeId())) {
             // special handling required for root node
             return rootNodeDef;
         }
@@ -551,7 +520,7 @@ public class ItemManager implements Dump
      * @throws RepositoryException
      */
     NodeImpl getRootNode() throws RepositoryException {
-        return (NodeImpl) getItem(rootNodeId);
+        return (NodeImpl) getItem(sessionContext.getRootNodeId());
     }
 
     /**
@@ -871,7 +840,7 @@ public class ItemManager implements Dump
 
     private PropertyImpl createPropertyInstance(PropertyData data) {
         // check special nodes
-        return new PropertyImpl(this, sessionContext, data, dataStore);
+        return new PropertyImpl(this, sessionContext, data);
     }
 
     //---------------------------------------------------< item cache methods >

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java?rev=957141&r1=957140&r2=957141&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
Wed Jun 23 08:19:14 2010
@@ -39,7 +39,6 @@ import javax.jcr.nodetype.ConstraintViol
 import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.version.VersionException;
 
-import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.security.authorization.Permission;
 import org.apache.jackrabbit.core.session.SessionContext;
@@ -69,24 +68,17 @@ public class PropertyImpl extends ItemIm
     private final PropertyData data;
 
     /**
-     * The data store of this repository, or <code>null</code>
-     */
-    private final DataStore dataStore;
-
-    /**
      * Package private constructor.
      *
      * @param itemMgr    the <code>ItemManager</code> that created this <code>Property</code>
      * @param sessionContext the component context of the associated session
      * @param data       the property data
-     * @param dataStore  the data store of this repository, or <code>null</code>
      */
     PropertyImpl(
             ItemManager itemMgr, SessionContext sessionContext,
-            PropertyData data, DataStore dataStore) {
+            PropertyData data) {
         super(itemMgr, sessionContext, data);
         this.data = data;
-        this.dataStore = dataStore;
         // value will be read on demand
     }
 
@@ -361,7 +353,8 @@ public class PropertyImpl extends ItemIm
             Value targetValue = ValueHelper.convert(
                     ValueFormat.getJCRValue(InternalValue.create(name), session, session.getValueFactory()),
                     reqType, session.getValueFactory());
-            internalValue = InternalValue.create(targetValue, session, dataStore);
+            internalValue = InternalValue.create(
+                    targetValue, session, sessionContext.getDataStore());
         } else {
             // no type conversion required
             internalValue = InternalValue.create(name);
@@ -412,7 +405,9 @@ public class PropertyImpl extends ItemIm
                         Value targetValue = ValueHelper.convert(
                                 ValueFormat.getJCRValue(InternalValue.create(name), session,
session.getValueFactory()),
                                 reqType, session.getValueFactory());
-                        internalValue = InternalValue.create(targetValue, session, dataStore);
+                        internalValue = InternalValue.create(
+                                targetValue, session,
+                                sessionContext.getDataStore());
                     } else {
                         // no type conversion required
                         internalValue = InternalValue.create(name);
@@ -699,10 +694,12 @@ public class PropertyImpl extends ItemIm
             // type conversion required
             Value targetVal = ValueHelper.convert(
                     value, reqType, session.getValueFactory());
-            internalValue = InternalValue.create(targetVal, session, dataStore);
+            internalValue = InternalValue.create(
+                    targetVal, session, sessionContext.getDataStore());
         } else {
             // no type conversion required
-            internalValue = InternalValue.create(value, session, dataStore);
+            internalValue = InternalValue.create(
+                    value, session, sessionContext.getDataStore());
         }
         internalSetValue(new InternalValue[]{internalValue}, reqType);
     }
@@ -771,8 +768,8 @@ public class PropertyImpl extends ItemIm
                         value = ValueHelper.convert(
                                 value, reqType, session.getValueFactory());
                     }
-                    internalValues[i] =
-                        InternalValue.create(value, session, dataStore);
+                    internalValues[i] = InternalValue.create(
+                            value, session, sessionContext.getDataStore());
                 } else {
                     internalValues[i] = null;
                 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java?rev=957141&r1=957140&r2=957141&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java
Wed Jun 23 08:19:14 2010
@@ -213,7 +213,7 @@ public class RepositoryContext {
      * Returns the data store of this repository, or <code>null</code>
      * if a data store is not configured.
      *
-     * @return data store
+     * @return data store, or <code>null</code>
      */
     public DataStore getDataStore() {
         return dataStore;

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=957141&r1=957140&r2=957141&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 08:19:14 2010
@@ -41,7 +41,6 @@ import org.apache.jackrabbit.core.sessio
 import org.apache.jackrabbit.core.session.ClosedSessionState;
 import org.apache.jackrabbit.core.session.SessionContext;
 import org.apache.jackrabbit.core.session.SessionOperation;
-import org.apache.jackrabbit.core.state.LocalItemStateManager;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.SessionItemStateManager;
 import org.apache.jackrabbit.core.util.Dumpable;
@@ -127,7 +126,7 @@ public class SessionImpl extends Abstrac
     /**
      * The component context of this session.
      */
-    protected final SessionContext context = new SessionContext(this);
+    protected final SessionContext context;
 
     /**
      * The component context of the repository that issued this session.
@@ -257,6 +256,7 @@ public class SessionImpl extends Abstrac
             RepositoryContext repositoryContext, Subject subject,
             WorkspaceConfig wspConfig)
             throws AccessDeniedException, RepositoryException {
+        this.context = new SessionContext(repositoryContext, this);
         this.context.setSessionState(new ActiveSessionState(context));
         this.repositoryContext = repositoryContext;
         this.subject = subject;
@@ -268,8 +268,7 @@ public class SessionImpl extends Abstrac
                 repositoryContext.getNodeTypeRegistry(), this,
                 repositoryContext.getDataStore());
         wsp = createWorkspaceInstance(wspConfig);
-        context.setItemStateManager(
-                createSessionItemStateManager(wsp.getItemStateManager()));
+        context.setItemStateManager(createSessionItemStateManager());
         context.setItemManager(createItemManager());
         accessMgr = createAccessManager(subject);
         versionMgr = createVersionManager();
@@ -291,11 +290,13 @@ public class SessionImpl extends Abstrac
      *
      * @return session item state manager
      */
-    protected SessionItemStateManager createSessionItemStateManager(LocalItemStateManager
manager) {
-        return SessionItemStateManager.createInstance(
-                repositoryContext.getRootNodeId(),
-                manager,
+    protected SessionItemStateManager createSessionItemStateManager() {
+        SessionItemStateManager mgr = new SessionItemStateManager(
+                context.getRootNodeId(),
+                wsp.getItemStateManager(),
                 repositoryContext.getNodeTypeRegistry());
+        wsp.getItemStateManager().addListener(mgr);
+        return mgr;
     }
 
     /**
@@ -316,10 +317,10 @@ public class SessionImpl extends Abstrac
      * @return item manager
      */
     protected ItemManager createItemManager() {
-        return ItemManager.createInstance(
-                context, ntMgr.getRootNodeDefinition(),
-                repositoryContext.getRootNodeId(),
-                repositoryContext.getDataStore());
+        ItemManager mgr =
+            new ItemManager(context, ntMgr.getRootNodeDefinition());
+        context.getItemStateManager().addListener(mgr);
+        return mgr;
     }
 
     /**
@@ -1235,7 +1236,7 @@ public class SessionImpl extends Abstrac
     public ValueFactory getValueFactory() {
         if (valueFactory == null) {
             valueFactory =
-                new ValueFactoryImpl(this, repositoryContext.getDataStore());
+                new ValueFactoryImpl(this, context.getDataStore());
         }
         return valueFactory;
     }

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=957141&r1=957140&r2=957141&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 08:19:14 2010
@@ -18,11 +18,16 @@ package org.apache.jackrabbit.core.sessi
 
 import org.apache.jackrabbit.core.HierarchyManager;
 import org.apache.jackrabbit.core.ItemManager;
+import org.apache.jackrabbit.core.RepositoryContext;
 import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.data.DataStore;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.state.SessionItemStateManager;
 
 public class SessionContext {
 
+    private final RepositoryContext repositoryContext;
+
     private final SessionImpl session;
 
     private volatile SessionState state;
@@ -38,10 +43,37 @@ public class SessionContext {
     private volatile ItemManager itemManager;
 
 
-    public SessionContext(SessionImpl session) {
+    public SessionContext(
+            RepositoryContext repositoryContext, SessionImpl session) {
+        assert repositoryContext != null;
+        assert session != null;
+        this.repositoryContext = repositoryContext;
         this.session = session;
     }
 
+    public RepositoryContext getRepositoryContext() {
+        return repositoryContext;
+    }
+
+    /**
+     * Returns the root node identifier of the repository.
+     *
+     * @return root node identifier
+     */
+    public NodeId getRootNodeId() {
+        return repositoryContext.getRootNodeId();
+    }
+
+    /**
+     * Returns the data store of this repository, or <code>null</code>
+     * if a data store is not configured.
+     *
+     * @return data store, or <code>null</code>
+     */
+    public DataStore getDataStore() {
+        return repositoryContext.getDataStore();
+    }
+
     public SessionImpl getSessionImpl() {
         return session;
     }

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=957141&r1=957140&r2=957141&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 Jun 23 08:19:14 2010
@@ -95,7 +95,7 @@ public class SessionItemStateManager
      * @param stateMgr the local item state manager
      * @param ntReg node type registry
      */
-    protected SessionItemStateManager(NodeId rootNodeId,
+    public SessionItemStateManager(NodeId rootNodeId,
                                    LocalItemStateManager stateMgr,
                                    NodeTypeRegistry ntReg) {
         transientStore = new ItemStateMap();
@@ -111,24 +111,6 @@ public class SessionItemStateManager
     }
 
     /**
-     * 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