jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r948757 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/
Date Thu, 27 May 2010 10:18:57 GMT
Author: jukka
Date: Thu May 27 10:18:56 2010
New Revision: 948757

URL: http://svn.apache.org/viewvc?rev=948757&view=rev
Log:
JCR-2640: Internal repository context

Commit the first draft patch, more updates to come...

Added:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryManagerImpl.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/WorkspaceImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java

Added: 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=948757&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java
Thu May 27 10:18:56 2010
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core;
+
+import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
+import org.apache.jackrabbit.core.version.InternalVersionManagerImpl;
+
+/**
+ * Internal component context of a Jackrabbit content repository.
+ * A repository context consists of the internal repository-level
+ * components and resources like the namespace and node type
+ * registries. Access to these resources is available only to objects
+ * with a reference to the context object.
+ */
+public class RepositoryContext {
+
+    /**
+     * The repository instance to which this context is associated.
+     */
+    private final RepositoryImpl repository;
+
+    /**
+     * The namespace registry of this repository.
+     */
+    private NamespaceRegistryImpl namespaceRegistry;
+
+    /**
+     * The node type registry of this repository.
+     */
+    private NodeTypeRegistry nodeTypeRegistry;
+
+    /**
+     * The internal version manager of this repository.
+     */
+    private InternalVersionManagerImpl internalVersionManager;
+
+    /**
+     * The root node identifier of this repository.
+     */
+    private NodeId rootNodeId;
+
+    /**
+     * Creates a component context for the given repository.
+     *
+     * @param repository repository instance
+     */
+    RepositoryContext(RepositoryImpl repository) {
+        assert repository != null;
+        this.repository = repository;
+    }
+
+    /**
+     * Returns the repository instance to which this context is associated.
+     *
+     * @return repository instance
+     */
+    public RepositoryImpl getRepository() {
+        return repository;
+    }
+
+    /**
+     * Returns the namespace registry of this repository.
+     *
+     * @return namespace registry
+     */
+    public NamespaceRegistryImpl getNamespaceRegistry() {
+        assert namespaceRegistry != null;
+        return namespaceRegistry;
+    }
+
+    /**
+     * Sets the namespace registry of this repository.
+     *
+     * @param namespaceRegistry namespace registry
+     */
+    void setNamespaceRegistry(NamespaceRegistryImpl namespaceRegistry) {
+        assert namespaceRegistry != null;
+        this.namespaceRegistry = namespaceRegistry;
+    }
+
+    /**
+     * Returns the namespace registry of this repository.
+     *
+     * @return node type registry
+     */
+    public NodeTypeRegistry getNodeTypeRegistry() {
+        assert nodeTypeRegistry != null;
+        return nodeTypeRegistry;
+    }
+
+    /**
+     * Sets the node type registry of this repository.
+     *
+     * @param nodeTypeRegistry node type registry
+     */
+    void setNodeTypeRegistry(NodeTypeRegistry nodeTypeRegistry) {
+        assert nodeTypeRegistry != null;
+        this.nodeTypeRegistry = nodeTypeRegistry;
+    }
+
+    /**
+     * Returns the internal version manager of this repository.
+     *
+     * @return internal version manager
+     */
+    public InternalVersionManagerImpl getInternalVersionManager() {
+        assert internalVersionManager != null;
+        return internalVersionManager;
+    }
+
+    /**
+     * Sets the internal version manager of this repository.
+     *
+     * @param internalVersionManager internal version manager
+     */
+    void setInternalVersionManager(
+            InternalVersionManagerImpl internalVersionManager) {
+        assert internalVersionManager != null;
+        this.internalVersionManager = internalVersionManager;
+    }
+
+    /**
+     * Returns the root node identifier of this repository.
+     *
+     * @return root node identifier
+     */
+    public NodeId getRootNodeId() {
+        assert rootNodeId != null;
+        return rootNodeId;
+    }
+
+    /**
+     * Sets the root node identifier of this repository.
+     *
+     * @param rootNodeId root node identifier
+     */
+    void setRootNodeId(NodeId rootNodeId) {
+        assert rootNodeId != null;
+        this.rootNodeId = rootNodeId;
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java?rev=948757&r1=948756&r2=948757&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryCopier.java
Thu May 27 10:18:56 2010
@@ -209,8 +209,8 @@ public class RepositoryCopier {
     }
 
     private void copyNamespaces() throws RepositoryException {
-        NamespaceRegistry sourceRegistry = source.getNamespaceRegistry();
-        NamespaceRegistry targetRegistry = target.getNamespaceRegistry();
+        NamespaceRegistry sourceRegistry = source.context.getNamespaceRegistry();
+        NamespaceRegistry targetRegistry = target.context.getNamespaceRegistry();
 
         logger.info("Copying registered namespaces");
         Collection<String> existing = Arrays.asList(targetRegistry.getURIs());
@@ -224,8 +224,8 @@ public class RepositoryCopier {
     }
 
     private void copyNodeTypes() throws RepositoryException {
-        NodeTypeRegistry sourceRegistry = source.getNodeTypeRegistry();
-        NodeTypeRegistry targetRegistry = target.getNodeTypeRegistry();
+        NodeTypeRegistry sourceRegistry = source.context.getNodeTypeRegistry();
+        NodeTypeRegistry targetRegistry = target.context.getNodeTypeRegistry();
 
         logger.info("Copying registered node types");
         Collection<Name> existing =
@@ -247,8 +247,8 @@ public class RepositoryCopier {
     private void copyVersionStore() throws RepositoryException {
         logger.info("Copying version histories");
         PersistenceCopier copier = new PersistenceCopier(
-                source.getVersionManagerImpl().getPersistenceManager(),
-                target.getVersionManagerImpl().getPersistenceManager(),
+                source.context.getInternalVersionManager().getPersistenceManager(),
+                target.context.getInternalVersionManager().getPersistenceManager(),
                 target.getDataStore());
         copier.copy(RepositoryImpl.VERSION_STORAGE_NODE_ID);
         copier.copy(RepositoryImpl.ACTIVITIES_NODE_ID);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=948757&r1=948756&r2=948757&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Thu May 27 10:18:56 2010
@@ -42,7 +42,6 @@ import java.util.concurrent.atomic.Atomi
 import javax.jcr.AccessDeniedException;
 import javax.jcr.Credentials;
 import javax.jcr.LoginException;
-import javax.jcr.NamespaceRegistry;
 import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.PropertyType;
 import javax.jcr.Repository;
@@ -167,11 +166,8 @@ public class RepositoryImpl extends Abst
      */
     private final Map<String, DescriptorValue> repDescriptors = new HashMap<String,
DescriptorValue>();
 
-    private NodeId rootNodeId;
+    protected final RepositoryContext context = new RepositoryContext(this);
 
-    private final NamespaceRegistryImpl nsReg;
-    private final NodeTypeRegistry ntReg;
-    private final InternalVersionManagerImpl vMgr;
     private final VirtualNodeTypeStateManager virtNTMgr;
 
     /**
@@ -322,14 +318,16 @@ public class RepositoryImpl extends Abst
             metaDataStore = new BasedFileSystem(repStore, fsRootPath);
 
             // init root node uuid
-            rootNodeId = loadRootNodeId(metaDataStore);
+            context.setRootNodeId(loadRootNodeId(metaDataStore));
 
             // initialize repository descriptors
             initRepositoryDescriptors();
 
             // create registries
-            nsReg = createNamespaceRegistry(new BasedFileSystem(repStore, "/namespaces"));
-            ntReg = createNodeTypeRegistry(nsReg, new BasedFileSystem(repStore, "/nodetypes"));
+            context.setNamespaceRegistry(createNamespaceRegistry(
+                    new BasedFileSystem(repStore, "/namespaces")));
+            context.setNodeTypeRegistry(createNodeTypeRegistry(
+                    new BasedFileSystem(repStore, "/nodetypes")));
 
             dataStore = repConfig.getDataStore();
 
@@ -344,22 +342,24 @@ public class RepositoryImpl extends Abst
             // will be interested in
             if (repConfig.getClusterConfig() != null) {
                 clusterNode = createClusterNode();
-                nsReg.setEventChannel(clusterNode);
-                ntReg.setEventChannel(clusterNode);
+                context.getNamespaceRegistry().setEventChannel(clusterNode);
+                context.getNodeTypeRegistry().setEventChannel(clusterNode);
 
                 createWorkspaceEventChannel = clusterNode;
                 clusterNode.setListener(this);
             }
 
             // init version manager
-            vMgr = createVersionManager(repConfig.getVersioningConfig(),
-                    delegatingDispatcher);
+            InternalVersionManagerImpl vMgr = createVersionManager(
+                    repConfig.getVersioningConfig(), delegatingDispatcher);
+            context.setInternalVersionManager(vMgr);
             if (clusterNode != null) {
                 vMgr.setEventChannel(clusterNode.createUpdateChannel(null));
             }
 
             // init virtual node type manager
-            virtNTMgr = new VirtualNodeTypeStateManager(getNodeTypeRegistry(),
+            virtNTMgr = new VirtualNodeTypeStateManager(
+                    context.getNodeTypeRegistry(),
                     delegatingDispatcher, NODETYPES_NODE_ID, SYSTEM_ROOT_NODE_ID);
 
             // initialize startup workspaces
@@ -499,17 +499,14 @@ public class RepositoryImpl extends Abst
 
 
         FileSystem fs = vConfig.getFileSystem();
-        PersistenceManager pm = createPersistenceManager(vConfig.getHomeDir(),
-                fs,
-                vConfig.getPersistenceManagerConfig(),
-                rootNodeId,
-                nsReg,
-                ntReg,
-                dataStore);
+        PersistenceManager pm = createPersistenceManager(
+                vConfig.getHomeDir(), fs,
+                vConfig.getPersistenceManagerConfig(), dataStore);
 
         ISMLocking ismLocking = vConfig.getISMLocking();
 
-        return new InternalVersionManagerImpl(pm, fs, ntReg, delegatingDispatcher,
+        return new InternalVersionManagerImpl(
+                pm, fs, context.getNodeTypeRegistry(), delegatingDispatcher,
                 SYSTEM_ROOT_NODE_ID,
                 VERSION_STORAGE_NODE_ID,
                 ACTIVITIES_NODE_ID,
@@ -654,10 +651,9 @@ public class RepositoryImpl extends Abst
      * @return
      * @throws RepositoryException
      */
-    protected NodeTypeRegistry createNodeTypeRegistry(NamespaceRegistry nsReg,
-                                                      FileSystem fs)
+    protected NodeTypeRegistry createNodeTypeRegistry(FileSystem fs)
             throws RepositoryException {
-        return NodeTypeRegistry.create(nsReg, fs);
+        return NodeTypeRegistry.create(context.getNamespaceRegistry(), fs);
     }
 
     /**
@@ -696,9 +692,12 @@ public class RepositoryImpl extends Abst
         if (systemSearchMgr == null) {
             if (repConfig.isSearchEnabled()) {
                 systemSearchMgr = new SearchManager(
-                        repConfig, nsReg, ntReg,
+                        repConfig,
+                        context.getNamespaceRegistry(),
+                        context.getNodeTypeRegistry(),
                         getWorkspaceInfo(wspName).itemStateMgr,
-                        vMgr.getPersistenceManager(), SYSTEM_ROOT_NODE_ID,
+                        context.getInternalVersionManager().getPersistenceManager(),
+                        SYSTEM_ROOT_NODE_ID,
                         null, null, executor);
 
                 SystemSession defSysSession = getSystemSession(wspName);
@@ -728,22 +727,6 @@ public class RepositoryImpl extends Abst
         }
     }
 
-    protected NamespaceRegistryImpl getNamespaceRegistry() {
-        return nsReg;
-    }
-
-    protected NodeTypeRegistry getNodeTypeRegistry() {
-        return ntReg;
-    }
-
-    protected InternalVersionManager getVersionManager() {
-        return vMgr;
-    }
-
-    protected NodeId getRootNodeId() {
-        return rootNodeId;
-    }
-
     /**
      * Returns the names of <i>all</i> workspaces in this repository.
      *
@@ -1176,12 +1159,10 @@ public class RepositoryImpl extends Abst
             }
         }
 
-        if (vMgr != null) {
-            try {
-                vMgr.close();
-            } catch (Exception e) {
-                log.error("Error while closing Version Manager.", e);
-            }
+        try {
+            context.getInternalVersionManager().close();
+        } catch (Exception e) {
+            log.error("Error while closing Version Manager.", e);
         }
 
         repDescriptors.clear();
@@ -1244,10 +1225,6 @@ public class RepositoryImpl extends Abst
         return repConfig;
     }
 
-    InternalVersionManagerImpl getVersionManagerImpl() {
-        return vMgr;
-    }
-
     /**
      * Returns the repository file system.
      * @return repository file system
@@ -1416,17 +1393,17 @@ public class RepositoryImpl extends Abst
      * @throws RepositoryException if the persistence manager could
      *                             not be instantiated/initialized
      */
-    private static PersistenceManager createPersistenceManager(File homeDir,
-                                                               FileSystem fs,
-                                                               PersistenceManagerConfig pmConfig,
-                                                               NodeId rootNodeId,
-                                                               NamespaceRegistry nsReg,
-                                                               NodeTypeRegistry ntReg,
-                                                               DataStore dataStore)
-            throws RepositoryException {
+    private PersistenceManager createPersistenceManager(
+            File homeDir, FileSystem fs, PersistenceManagerConfig pmConfig,
+            DataStore dataStore) throws RepositoryException {
         try {
             PersistenceManager pm = pmConfig.newInstance(PersistenceManager.class);
-            pm.init(new PMContext(homeDir, fs, rootNodeId, nsReg, ntReg, dataStore));
+            pm.init(new PMContext(
+                    homeDir, fs,
+                    context.getRootNodeId(),
+                    context.getNamespaceRegistry(),
+                    context.getNodeTypeRegistry(),
+                    dataStore));
             return pm;
         } catch (Exception e) {
             String msg = "Cannot instantiate persistence manager " + pmConfig.getClassName();
@@ -1438,8 +1415,6 @@ public class RepositoryImpl extends Abst
      * Creates a <code>SharedItemStateManager</code> or derivative.
      *
      * @param persistMgr     persistence manager
-     * @param rootNodeId     root node id
-     * @param ntReg          node type registry
      * @param usesReferences <code>true</code> if the item state manager should
use
      *                       node references to verify integrity of its reference properties;
      *                       <code>false</code> otherwise
@@ -1447,15 +1422,15 @@ public class RepositoryImpl extends Abst
      * @return item state manager
      * @throws ItemStateException if an error occurs
      */
-    protected SharedItemStateManager createItemStateManager(PersistenceManager persistMgr,
-                                                            NodeId rootNodeId,
-                                                            NodeTypeRegistry ntReg,
-                                                            boolean usesReferences,
-                                                            ItemStateCacheFactory cacheFactory,
-                                                            ISMLocking locking)
+    protected SharedItemStateManager createItemStateManager(
+            PersistenceManager persistMgr, boolean usesReferences,
+            ItemStateCacheFactory cacheFactory, ISMLocking locking)
             throws ItemStateException {
-
-        return new SharedItemStateManager(persistMgr, rootNodeId, ntReg, true, cacheFactory,
locking);
+        return new SharedItemStateManager(
+                persistMgr,
+                context.getRootNodeId(),
+                context.getNodeTypeRegistry(),
+                true, cacheFactory, locking);
     }
 
     //-----------------------------------------------------------< Repository >
@@ -1598,8 +1573,7 @@ public class RepositoryImpl extends Abst
     protected SessionImpl createSessionInstance(AuthContext loginContext,
                                                 WorkspaceConfig wspConfig)
             throws AccessDeniedException, RepositoryException {
-
-        return new XASessionImpl(this, loginContext, wspConfig);
+        return new XASessionImpl(context, loginContext, wspConfig);
     }
 
     /**
@@ -1616,8 +1590,7 @@ public class RepositoryImpl extends Abst
     protected SessionImpl createSessionInstance(Subject subject,
                                                 WorkspaceConfig wspConfig)
             throws AccessDeniedException, RepositoryException {
-
-        return new XASessionImpl(this, subject, wspConfig);
+        return new XASessionImpl(context, subject, wspConfig);
     }
 
     /**
@@ -1868,8 +1841,12 @@ public class RepositoryImpl extends Abst
                 if (searchMgr == null && config.isSearchEnabled()) {
                     // search manager is lazily instantiated in order to avoid
                     // 'chicken & egg' bootstrap problems
-                    searchMgr = new SearchManager(config,
-                            nsReg, ntReg, itemStateMgr, persistMgr, rootNodeId,
+                    searchMgr = new SearchManager(
+                            config,
+                            context.getNamespaceRegistry(),
+                            context.getNodeTypeRegistry(),
+                            itemStateMgr, persistMgr,
+                            context.getRootNodeId(),
                             getSystemSearchManager(getName()),
                             SYSTEM_ROOT_NODE_ID, executor);
                 }
@@ -1938,8 +1915,7 @@ public class RepositoryImpl extends Abst
                 // system session is lazily instantiated in order to avoid
                 // 'chicken & egg' bootstrap problems
                 if (systemSession == null) {
-                    systemSession =
-                            SystemSession.create(RepositoryImpl.this, config);
+                    systemSession = SystemSession.create(context, config);
                 }
                 return systemSession;
             }
@@ -2011,18 +1987,16 @@ public class RepositoryImpl extends Abst
         protected void doInitialize() throws RepositoryException {
             fs = config.getFileSystem();
 
-            persistMgr = createPersistenceManager(new File(config.getHomeDir()),
+            persistMgr = createPersistenceManager(
+                    new File(config.getHomeDir()),
                     fs,
                     config.getPersistenceManagerConfig(),
-                    rootNodeId,
-                    nsReg,
-                    ntReg,
                     dataStore);
 
             // JCR-2551: Recovery from a lost version history
             if (Boolean.getBoolean("org.apache.jackrabbit.version.recovery")) {
-                RepositoryChecker checker =
-                    new RepositoryChecker(persistMgr, vMgr);
+                RepositoryChecker checker = new RepositoryChecker(
+                        persistMgr, context.getInternalVersionManager());
                 checker.check(ROOT_NODE_ID, true);
                 checker.fix();
             }
@@ -2031,11 +2005,11 @@ public class RepositoryImpl extends Abst
 
             // create item state manager
             try {
-                itemStateMgr = createItemStateManager(persistMgr, rootNodeId,
-                        ntReg, true, cacheFactory, ismLocking);
+                itemStateMgr = createItemStateManager(
+                        persistMgr, true, cacheFactory, ismLocking);
                 try {
                     itemStateMgr.addVirtualItemStateProvider(
-                            vMgr.getVirtualItemStateProvider());
+                            context.getInternalVersionManager().getVirtualItemStateProvider());
                     itemStateMgr.addVirtualItemStateProvider(
                             virtNTMgr.getVirtualItemStateProvider());
                 } catch (Exception e) {
@@ -2384,7 +2358,7 @@ public class RepositoryImpl extends Abst
          * {@inheritDoc}
          */
         public NamespaceResolver getNamespaceResolver() {
-            return new RegistryNamespaceResolver(getNamespaceRegistry());
+            return new RegistryNamespaceResolver(context.getNamespaceRegistry());
         }
 
         /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryManagerImpl.java?rev=948757&r1=948756&r2=948757&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryManagerImpl.java
Thu May 27 10:18:56 2010
@@ -46,7 +46,7 @@ public class RepositoryManagerImpl imple
             throw new RepositoryException("Repository is stopped");
         }
         ArrayList<PersistenceManager> pmList = new ArrayList<PersistenceManager>();
-        InternalVersionManagerImpl vm = (InternalVersionManagerImpl) rep.getVersionManager();
+        InternalVersionManagerImpl vm = rep.context.getInternalVersionManager();
         PersistenceManager pm = vm.getPersistenceManager();
         pmList.add(pm);
         String[] wspNames = rep.getWorkspaceNames();
@@ -55,7 +55,8 @@ public class RepositoryManagerImpl imple
             String wspName = wspNames[i];
             WorkspaceInfo wspInfo = rep.getWorkspaceInfo(wspName);
             // this will initialize the workspace if required
-            SessionImpl session = SystemSession.create(rep, wspInfo.getConfig());
+            SessionImpl session =
+                SystemSession.create(rep.context, wspInfo.getConfig());
             // mark this session as 'active' so the workspace does not get disposed
             // by the workspace-janitor until the garbage collector is done
             rep.onSessionCreated(session);

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=948757&r1=948756&r2=948757&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
Thu May 27 10:18:56 2010
@@ -133,6 +133,11 @@ public class SessionImpl extends Abstrac
     protected boolean alive;
 
     /**
+     * The component context of the repository that issued this session.
+     */
+    protected final RepositoryContext repositoryContext;
+
+    /**
      * the repository that issued this session
      */
     protected final RepositoryImpl rep;
@@ -245,7 +250,7 @@ public class SessionImpl extends Abstrac
     /**
      * Protected constructor.
      *
-     * @param rep
+     * @param repositoryContext repository context
      * @param loginContext
      * @param wspConfig
      * @throws AccessDeniedException if the subject of the given login context
@@ -253,37 +258,41 @@ public class SessionImpl extends Abstrac
      *                               workspace
      * @throws RepositoryException   if another error occurs
      */
-    protected SessionImpl(RepositoryImpl rep, AuthContext loginContext,
-                          WorkspaceConfig wspConfig)
+    protected SessionImpl(
+            RepositoryContext repositoryContext, AuthContext loginContext,
+            WorkspaceConfig wspConfig)
             throws AccessDeniedException, RepositoryException {
-        this(rep, loginContext.getSubject(), wspConfig);
+        this(repositoryContext, loginContext.getSubject(), wspConfig);
         this.loginContext = loginContext;
     }
 
     /**
      * Protected constructor.
      *
-     * @param rep
+     * @param repositoryContext repository context
      * @param subject
      * @param wspConfig
      * @throws AccessDeniedException if the given subject is not granted access
      *                               to the specified workspace
      * @throws RepositoryException   if another error occurs
      */
-    protected SessionImpl(RepositoryImpl rep, Subject subject,
-                          WorkspaceConfig wspConfig)
+    protected SessionImpl(
+            RepositoryContext repositoryContext, Subject subject,
+            WorkspaceConfig wspConfig)
             throws AccessDeniedException, RepositoryException {
         alive = true;
-        this.rep = rep;
+        this.repositoryContext = repositoryContext;
+        this.rep = repositoryContext.getRepository();
         this.subject = subject;
 
         userId = retrieveUserId(subject, wspConfig.getName());
 
         namePathResolver = new DefaultNamePathResolver(this, this, true);
-        ntMgr = new NodeTypeManagerImpl(rep.getNodeTypeRegistry(), this, rep.getDataStore());
+        ntMgr = new NodeTypeManagerImpl(
+                repositoryContext.getNodeTypeRegistry(), this, rep.getDataStore());
         String wspName = wspConfig.getName();
-        wsp = createWorkspaceInstance(wspConfig,
-                rep.getWorkspaceStateManager(wspName), rep, this);
+        wsp = createWorkspaceInstance(
+                wspConfig, rep.getWorkspaceStateManager(wspName));
         itemStateMgr = createSessionItemStateManager(wsp.getItemStateManager());
         hierMgr = itemStateMgr.getHierarchyMgr();
         itemMgr = createItemManager(itemStateMgr, hierMgr);
@@ -308,7 +317,9 @@ public class SessionImpl extends Abstrac
      */
     protected SessionItemStateManager createSessionItemStateManager(LocalItemStateManager
manager) {
         return SessionItemStateManager.createInstance(
-                rep.getRootNodeId(), manager, rep.getNodeTypeRegistry());
+                repositoryContext.getRootNodeId(),
+                manager,
+                repositoryContext.getNodeTypeRegistry());
     }
 
     /**
@@ -316,16 +327,12 @@ public class SessionImpl extends Abstrac
      *
      * @param wspConfig The workspace configuration
      * @param stateMgr  The shared item state manager
-     * @param rep       The repository
-     * @param session   The session
      * @return An instance of the {@link WorkspaceImpl} class or an extension
      *         thereof.
      */
-    protected WorkspaceImpl createWorkspaceInstance(WorkspaceConfig wspConfig,
-                                                    SharedItemStateManager stateMgr,
-                                                    RepositoryImpl rep,
-                                                    SessionImpl session) {
-        return new WorkspaceImpl(wspConfig, stateMgr, rep, session);
+    protected WorkspaceImpl createWorkspaceInstance(
+            WorkspaceConfig wspConfig, SharedItemStateManager stateMgr) {
+        return new WorkspaceImpl(wspConfig, stateMgr, repositoryContext, this);
     }
 
     /**
@@ -334,8 +341,10 @@ public class SessionImpl extends Abstrac
      */
     protected ItemManager createItemManager(SessionItemStateManager itemStateMgr,
                                             HierarchyManager hierMgr) {
-        return ItemManager.createInstance(itemStateMgr, hierMgr, this,
-                ntMgr.getRootNodeDefinition(), rep.getRootNodeId());
+        return ItemManager.createInstance(
+                itemStateMgr, hierMgr, this,
+                ntMgr.getRootNodeDefinition(),
+                repositoryContext.getRootNodeId());
     }
 
     /**
@@ -345,8 +354,7 @@ public class SessionImpl extends Abstrac
      */
     protected InternalVersionManager createVersionManager(RepositoryImpl rep)
             throws RepositoryException {
-
-        return rep.getVersionManager();
+        return repositoryContext.getInternalVersionManager();
     }
 
     /**
@@ -393,7 +401,9 @@ public class SessionImpl extends Abstrac
      */
     public synchronized ItemValidator getValidator() throws RepositoryException {
         if (validator == null) {
-            validator = new ItemValidator(rep.getNodeTypeRegistry(), getHierarchyManager(),
this);
+            validator = new ItemValidator(
+                    repositoryContext.getNodeTypeRegistry(),
+                    getHierarchyManager(), this);
         }
         return validator;
     }
@@ -654,7 +664,7 @@ public class SessionImpl extends Abstrac
      */
     public GarbageCollector createDataStoreGarbageCollector() throws RepositoryException
{
         ArrayList<PersistenceManager> pmList = new ArrayList<PersistenceManager>();
-        InternalVersionManagerImpl vm = (InternalVersionManagerImpl) rep.getVersionManager();
+        InternalVersionManagerImpl vm = repositoryContext.getInternalVersionManager();
         PersistenceManager pm = vm.getPersistenceManager();
         pmList.add(pm);
         String[] wspNames = rep.getWorkspaceNames();
@@ -663,7 +673,8 @@ public class SessionImpl extends Abstrac
             String wspName = wspNames[i];
             WorkspaceInfo wspInfo = rep.getWorkspaceInfo(wspName);
             // this will initialize the workspace if required
-            SessionImpl session = SystemSession.create(rep, wspInfo.getConfig());
+            SessionImpl session =
+                SystemSession.create(repositoryContext, wspInfo.getConfig());
             // mark this session as 'active' so the workspace does not get disposed
             // by the workspace-janitor until the garbage collector is done
             rep.onSessionCreated(session);

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=948757&r1=948756&r2=948757&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
Thu May 27 10:18:56 2010
@@ -53,7 +53,8 @@ class SystemSession extends SessionImpl 
      * @return
      * @throws RepositoryException
      */
-    static SystemSession create(RepositoryImpl rep, WorkspaceConfig wspConfig)
+    static SystemSession create(
+            RepositoryContext repositoryContext, WorkspaceConfig wspConfig)
             throws RepositoryException {
         // create subject with SystemPrincipal
         Set<SystemPrincipal> principals = new HashSet<SystemPrincipal>();
@@ -61,19 +62,19 @@ class SystemSession extends SessionImpl 
         Subject subject =
                 new Subject(true, principals, Collections.EMPTY_SET,
                         Collections.EMPTY_SET);
-        return new SystemSession(rep, subject, wspConfig);
+        return new SystemSession(repositoryContext, subject, wspConfig);
     }
 
     /**
      * private constructor
      *
-     * @param rep
+     * @param repositoryContext repository context
      * @param wspConfig
      */
-    private SystemSession(RepositoryImpl rep, Subject subject,
-                          WorkspaceConfig wspConfig)
-            throws RepositoryException {
-        super(rep, subject, wspConfig);
+    private SystemSession(
+            RepositoryContext repositoryContext, Subject subject,
+            WorkspaceConfig wspConfig) throws RepositoryException {
+        super(repositoryContext, subject, wspConfig);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java?rev=948757&r1=948756&r2=948757&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
Thu May 27 10:18:56 2010
@@ -75,6 +75,11 @@ public class WorkspaceImpl extends Abstr
     protected final WorkspaceConfig wspConfig;
 
     /**
+     * The component context of the repository that created this workspace.
+     */
+    protected final RepositoryContext repositoryContext;
+
+    /**
      * The repository that created this workspace instance
      */
     protected final RepositoryImpl rep;
@@ -137,14 +142,15 @@ public class WorkspaceImpl extends Abstr
      * @param rep       The repository
      * @param session   The session
      */
-    protected WorkspaceImpl(WorkspaceConfig wspConfig,
-                            SharedItemStateManager stateMgr, RepositoryImpl rep,
-                            SessionImpl session) {
+    protected WorkspaceImpl(
+            WorkspaceConfig wspConfig, SharedItemStateManager stateMgr,
+            RepositoryContext repositoryContext, SessionImpl session) {
         this.wspConfig = wspConfig;
-        this.rep = rep;
+        this.repositoryContext = repositoryContext;
+        this.rep = repositoryContext.getRepository();
         this.stateMgr = createItemStateManager(stateMgr);
-        this.hierMgr =
-            new CachingHierarchyManager(rep.getRootNodeId(), this.stateMgr);
+        this.hierMgr = new CachingHierarchyManager(
+                repositoryContext.getRootNodeId(), this.stateMgr);
         this.stateMgr.addListener(hierMgr);
         this.session = session;
     }
@@ -387,8 +393,8 @@ public class WorkspaceImpl extends Abstr
         }
 
         BatchedItemOperations ops = new BatchedItemOperations(
-                stateMgr, rep.getNodeTypeRegistry(), session.getLockManager(),
-                session, hierMgr);
+                stateMgr, repositoryContext.getNodeTypeRegistry(),
+                session.getLockManager(), session, hierMgr);
 
         try {
             ops.edit();
@@ -463,8 +469,8 @@ public class WorkspaceImpl extends Abstr
         }
 
         BatchedItemOperations ops = new BatchedItemOperations(
-                stateMgr, rep.getNodeTypeRegistry(), session.getLockManager(),
-                session, hierMgr);
+                stateMgr, repositoryContext.getNodeTypeRegistry(),
+                session.getLockManager(), session, hierMgr);
 
         try {
             ops.edit();
@@ -545,7 +551,7 @@ public class WorkspaceImpl extends Abstr
         // check state of this instance
         sanityCheck();
 
-        return rep.getNamespaceRegistry();
+        return repositoryContext.getNamespaceRegistry();
     }
 
     /**
@@ -706,8 +712,8 @@ public class WorkspaceImpl extends Abstr
         }
 
         BatchedItemOperations ops = new BatchedItemOperations(
-                stateMgr, rep.getNodeTypeRegistry(), session.getLockManager(),
-                session, hierMgr);
+                stateMgr, repositoryContext.getNodeTypeRegistry(),
+                session.getLockManager(), session, hierMgr);
 
         try {
             ops.edit();
@@ -834,8 +840,10 @@ public class WorkspaceImpl extends Abstr
             throw new RepositoryException("not an absolute path: " + parentAbsPath);
         }
 
-        Importer importer = new WorkspaceImporter(parentPath, this,
-                rep.getNodeTypeRegistry(), uuidBehavior, wspConfig.getImportConfig());
+        Importer importer = new WorkspaceImporter(
+                parentPath, this,
+                repositoryContext.getNodeTypeRegistry(),
+                uuidBehavior, wspConfig.getImportConfig());
         return new ImportHandler(importer, session);
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java?rev=948757&r1=948756&r2=948757&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XASessionImpl.java
Thu May 27 10:18:56 2010
@@ -25,7 +25,6 @@ import org.apache.jackrabbit.core.securi
 import org.apache.jackrabbit.core.state.SharedItemStateManager;
 import org.apache.jackrabbit.core.state.XAItemStateManager;
 import org.apache.jackrabbit.core.version.InternalVersionManager;
-import org.apache.jackrabbit.core.version.InternalVersionManagerImpl;
 import org.apache.jackrabbit.core.version.InternalXAVersionManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -92,7 +91,7 @@ public class XASessionImpl extends Sessi
     /**
      * Create a new instance of this class.
      *
-     * @param rep          repository
+     * @param repositoryContext repository context
      * @param loginContext login context containing authenticated subject
      * @param wspConfig    workspace configuration
      * @throws AccessDeniedException if the subject of the given login context
@@ -100,31 +99,29 @@ public class XASessionImpl extends Sessi
      *                               workspace
      * @throws RepositoryException   if another error occurs
      */
-    protected XASessionImpl(RepositoryImpl rep, AuthContext loginContext,
-                            WorkspaceConfig wspConfig)
+    protected XASessionImpl(
+            RepositoryContext repositoryContext, AuthContext loginContext,
+            WorkspaceConfig wspConfig)
             throws AccessDeniedException, RepositoryException {
-
-        super(rep, loginContext, wspConfig);
-
+        super(repositoryContext, loginContext, wspConfig);
         init();
     }
 
     /**
      * Create a new instance of this class.
      *
-     * @param rep       repository
+     * @param repositoryContext repository context
      * @param subject   authenticated subject
      * @param wspConfig workspace configuration
      * @throws AccessDeniedException if the given subject is not granted access
      *                               to the specified workspace
      * @throws RepositoryException   if another error occurs
      */
-    protected XASessionImpl(RepositoryImpl rep, Subject subject,
-                            WorkspaceConfig wspConfig)
+    protected XASessionImpl(
+            RepositoryContext repositoryContext, Subject subject,
+            WorkspaceConfig wspConfig)
             throws AccessDeniedException, RepositoryException {
-
-        super(rep, subject, wspConfig);
-
+        super(repositoryContext, subject, wspConfig);
         init();
     }
 
@@ -160,11 +157,10 @@ public class XASessionImpl extends Sessi
     /**
      * {@inheritDoc}
      */
-    protected WorkspaceImpl createWorkspaceInstance(WorkspaceConfig wspConfig,
-                                                    SharedItemStateManager stateMgr,
-                                                    RepositoryImpl rep,
-                                                    SessionImpl session) {
-        return new XAWorkspace(wspConfig, stateMgr, rep, session);
+    @Override
+    protected WorkspaceImpl createWorkspaceInstance(
+            WorkspaceConfig wspConfig, SharedItemStateManager stateMgr) {
+        return new XAWorkspace(wspConfig, stateMgr, repositoryContext, this);
     }
 
     /**
@@ -172,9 +168,10 @@ public class XASessionImpl extends Sessi
      */
     protected InternalVersionManager createVersionManager(RepositoryImpl rep)
             throws RepositoryException {
-
-        InternalVersionManagerImpl vMgr = (InternalVersionManagerImpl) rep.getVersionManager();
-        return new InternalXAVersionManager(vMgr, rep.getNodeTypeRegistry(), this, rep.getItemStateCacheFactory());
+        return new InternalXAVersionManager(
+                repositoryContext.getInternalVersionManager(),
+                repositoryContext.getNodeTypeRegistry(),
+                this, rep.getItemStateCacheFactory());
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java?rev=948757&r1=948756&r2=948757&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/XAWorkspace.java
Thu May 27 10:18:56 2010
@@ -31,14 +31,13 @@ public class XAWorkspace extends Workspa
      *
      * @param wspConfig The workspace configuration
      * @param stateMgr  The shared item state manager
-     * @param rep       The repository
+     * @param repositoryContext repository context
      * @param session   The session
      */
-    protected XAWorkspace(WorkspaceConfig wspConfig,
-                          SharedItemStateManager stateMgr, RepositoryImpl rep,
-                          SessionImpl session) {
-
-        super(wspConfig, stateMgr, rep, session);
+    protected XAWorkspace(
+            WorkspaceConfig wspConfig, SharedItemStateManager stateMgr,
+            RepositoryContext repositoryContext, SessionImpl session) {
+        super(wspConfig, stateMgr, repositoryContext, session);
     }
 
     /**



Mime
View raw message