jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r948874 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: RepositoryContext.java RepositoryImpl.java SessionImpl.java WorkspaceImpl.java WorkspaceManager.java XASessionImpl.java XAWorkspace.java
Date Thu, 27 May 2010 16:08:53 GMT
Author: jukka
Date: Thu May 27 16:08:52 2010
New Revision: 948874

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

Use the RepositoryContext to track the ItemStateCacheFactory instance.
Remove the RepositoryImpl member variables from SessionImpl and WorkspaceImpl.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryContext.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/SessionImpl.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/WorkspaceManager.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

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=948874&r1=948873&r2=948874&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
Thu May 27 16:08:52 2010
@@ -22,6 +22,7 @@ import org.apache.jackrabbit.core.fs.Fil
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.security.JackrabbitSecurityManager;
+import org.apache.jackrabbit.core.state.ItemStateCacheFactory;
 import org.apache.jackrabbit.core.version.InternalVersionManagerImpl;
 
 /**
@@ -84,6 +85,11 @@ public class RepositoryContext {
     private JackrabbitSecurityManager securityManager;
 
     /**
+     * Item state cache factory of this repository.
+     */
+    private ItemStateCacheFactory itemStateCacheFactory;
+
+    /**
      * Creates a component context for the given repository.
      *
      * @param repository repository instance
@@ -283,4 +289,24 @@ public class RepositoryContext {
         this.securityManager = securityManager;
     }
 
+    /**
+     * Returns the item state cache factory of this repository.
+     *
+     * @return item state cache factory
+     */
+    public ItemStateCacheFactory getItemStateCacheFactory() {
+        assert itemStateCacheFactory != null;
+        return itemStateCacheFactory;
+    }
+
+    /**
+     * Sets the item state cache factory of this repository.
+     *
+     * @param itemStateCacheFactory item state cache factory
+     */
+    void setItemStateCacheFactory(ItemStateCacheFactory itemStateCacheFactory) {
+        assert itemStateCacheFactory != null;
+        this.itemStateCacheFactory = itemStateCacheFactory;
+    }
+
 }

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=948874&r1=948873&r2=948874&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 16:08:52 2010
@@ -226,11 +226,6 @@ public class RepositoryImpl extends Abst
     private final CacheManager cacheMgr = new CacheManager();
 
     /**
-     * There is only one item state cache factory
-     */
-    private final ItemStateCacheFactory cacheFactory = new ManagedMLRUItemStateCacheFactory(cacheMgr);
-
-    /**
      * Chanel for posting create workspace messages.
      */
     private WorkspaceEventChannel createWorkspaceEventChannel;
@@ -301,6 +296,10 @@ public class RepositoryImpl extends Abst
             context.setNodeTypeRegistry(new NodeTypeRegistry(
                     context.getNamespaceRegistry(), context.getFileSystem()));
 
+            // Create item state cache manager
+            context.setItemStateCacheFactory(
+                    new ManagedMLRUItemStateCacheFactory(cacheMgr));
+
             DataStore dataStore = repConfig.getDataStore();
             if (dataStore != null) {
                 context.setDataStore(dataStore);
@@ -425,15 +424,6 @@ public class RepositoryImpl extends Abst
     }
 
     /**
-     * Get the item state cache factory of this repository.
-     *
-     * @return the cache factory
-     */
-    public ItemStateCacheFactory getItemStateCacheFactory() {
-        return cacheFactory;
-    }
-
-    /**
      * Creates the {@link org.apache.jackrabbit.core.security.JackrabbitSecurityManager SecurityManager}
      * of this <code>Repository</code>
      *
@@ -490,7 +480,7 @@ public class RepositoryImpl extends Abst
                 SYSTEM_ROOT_NODE_ID,
                 VERSION_STORAGE_NODE_ID,
                 ACTIVITIES_NODE_ID,
-                cacheFactory,
+                context.getItemStateCacheFactory(),
                 ismLocking);
     }
 
@@ -1329,19 +1319,19 @@ public class RepositoryImpl extends Abst
      * @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
-     * @param cacheFactory   cache factory
      * @return item state manager
      * @throws ItemStateException if an error occurs
      */
     protected SharedItemStateManager createItemStateManager(
             PersistenceManager persistMgr, boolean usesReferences,
-            ItemStateCacheFactory cacheFactory, ISMLocking locking)
-            throws ItemStateException {
+            ISMLocking locking) throws ItemStateException {
         return new SharedItemStateManager(
                 persistMgr,
                 context.getRootNodeId(),
                 context.getNodeTypeRegistry(),
-                true, cacheFactory, locking);
+                true,
+                context.getItemStateCacheFactory(),
+                locking);
     }
 
     /**
@@ -1961,8 +1951,8 @@ public class RepositoryImpl extends Abst
 
             // create item state manager
             try {
-                itemStateMgr = createItemStateManager(
-                        persistMgr, true, cacheFactory, ismLocking);
+                itemStateMgr =
+                    createItemStateManager(persistMgr, true, ismLocking);
                 try {
                     itemStateMgr.addVirtualItemStateProvider(
                             context.getInternalVersionManager().getVirtualItemStateProvider());

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=948874&r1=948873&r2=948874&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 16:08:52 2010
@@ -133,11 +133,6 @@ public class SessionImpl extends Abstrac
     protected final RepositoryContext repositoryContext;
 
     /**
-     * the repository that issued this session
-     */
-    protected final RepositoryImpl rep;
-
-    /**
      * the AuthContext of this session (can be null if this
      * session was not instantiated through a login process)
      */
@@ -277,7 +272,6 @@ public class SessionImpl extends Abstrac
             throws AccessDeniedException, RepositoryException {
         alive = true;
         this.repositoryContext = repositoryContext;
-        this.rep = repositoryContext.getRepository();
         this.subject = subject;
 
         userId = retrieveUserId(subject, wspConfig.getName());
@@ -367,7 +361,8 @@ public class SessionImpl extends Abstrac
                                                 HierarchyManager hierarchyManager)
             throws AccessDeniedException, RepositoryException {
         String wspName = getWorkspace().getName();
-        AMContext ctx = new AMContext(new File(rep.getConfig().getHomeDir()),
+        AMContext ctx = new AMContext(
+                new File(repositoryContext.getRepository().getConfig().getHomeDir()),
                 repositoryContext.getFileSystem(),
                 this,
                 getSubject(),
@@ -436,7 +431,8 @@ public class SessionImpl extends Abstrac
         }
         Subject old = getSubject();
         Subject newSubject = new Subject(old.isReadOnly(), old.getPrincipals(), old.getPublicCredentials(),
old.getPrivateCredentials());
-        return rep.createSession(newSubject, workspaceName);
+        return repositoryContext.getWorkspaceManager().createSession(
+                newSubject, workspaceName);
     }
 
     /**
@@ -660,7 +656,8 @@ public class SessionImpl extends Abstrac
      * @throws RepositoryException
      */
     public GarbageCollector createDataStoreGarbageCollector() throws RepositoryException
{
-        final GarbageCollector gc = rep.createDataStoreGarbageCollector();
+        final GarbageCollector gc =
+            repositoryContext.getRepository().createDataStoreGarbageCollector();
         // Auto-close if the main session logs out
         addListener(new SessionListener() {
             public void loggedOut(SessionImpl session) {
@@ -1247,7 +1244,7 @@ public class SessionImpl extends Abstrac
      * {@inheritDoc}
      */
     public Repository getRepository() {
-        return rep;
+        return repositoryContext.getRepository();
     }
 
     /**

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=948874&r1=948873&r2=948874&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 16:08:52 2010
@@ -80,11 +80,6 @@ public class WorkspaceImpl extends Abstr
     protected final RepositoryContext repositoryContext;
 
     /**
-     * The repository that created this workspace instance
-     */
-    protected final RepositoryImpl rep;
-
-    /**
      * The persistent state mgr associated with the workspace represented by <i>this</i>
      * <code>Workspace</code> instance.
      */
@@ -147,7 +142,6 @@ public class WorkspaceImpl extends Abstr
             SessionImpl session) throws RepositoryException {
         this.wspConfig = wspConfig;
         this.repositoryContext = repositoryContext;
-        this.rep = repositoryContext.getRepository();
         this.stateMgr = createItemStateManager();
         this.hierMgr = new CachingHierarchyManager(
                 repositoryContext.getRootNodeId(), this.stateMgr);
@@ -213,7 +207,8 @@ public class WorkspaceImpl extends Abstr
         SessionImpl tmpSession = null;
         try {
             // create a temporary session on new workspace for current subject
-            tmpSession = rep.createSession(session.getSubject(), name);
+            tmpSession = repositoryContext.getWorkspaceManager().createSession(
+                    session.getSubject(), name);
             WorkspaceImpl newWsp = (WorkspaceImpl) tmpSession.getWorkspace();
 
             // Workspace#clone(String, String, String, booelan) doesn't
@@ -244,7 +239,7 @@ public class WorkspaceImpl extends Abstr
     public void deleteWorkspace(String name) throws AccessDeniedException,
             UnsupportedRepositoryOperationException, RepositoryException {
         // check if workspace exists (will throw NoSuchWorkspaceException if not)
-        rep.getWorkspaceInfo(name);
+        repositoryContext.getRepository().getWorkspaceInfo(name);
         // todo implement deleteWorkspace
         throw new UnsupportedRepositoryOperationException("not yet implemented");
     }
@@ -508,7 +503,8 @@ public class WorkspaceImpl extends Abstr
         sanityCheck();
 
         if (lockMgr == null) {
-            lockMgr = rep.getLockManager(wspConfig.getName());
+            lockMgr = repositoryContext.getRepository().getLockManager(
+                    wspConfig.getName());
         }
         return lockMgr;
     }
@@ -524,7 +520,8 @@ public class WorkspaceImpl extends Abstr
         // check state of this instance
         sanityCheck();
         if (retentionRegistry == null) {
-            retentionRegistry = rep.getRetentionRegistry(wspConfig.getName());
+            retentionRegistry =
+                repositoryContext.getRepository().getRetentionRegistry(wspConfig.getName());
         }
         return retentionRegistry;
     }
@@ -601,7 +598,8 @@ public class WorkspaceImpl extends Abstr
         try {
             // create session on other workspace for current subject
             // (may throw NoSuchWorkspaceException and AccessDeniedException)
-            srcSession = rep.createSession(session.getSubject(), srcWorkspace);
+            srcSession = repositoryContext.getWorkspaceManager().createSession(
+                    session.getSubject(), srcWorkspace);
             WorkspaceImpl srcWsp = (WorkspaceImpl) srcSession.getWorkspace();
 
             // do cross-workspace copy
@@ -662,7 +660,8 @@ public class WorkspaceImpl extends Abstr
         try {
             // create session on other workspace for current subject
             // (may throw NoSuchWorkspaceException and AccessDeniedException)
-            srcSession = rep.createSession(session.getSubject(), srcWorkspace);
+            srcSession = repositoryContext.getWorkspaceManager().createSession(
+                    session.getSubject(), srcWorkspace);
             WorkspaceImpl srcWsp = (WorkspaceImpl) srcSession.getWorkspace();
 
             // do cross-workspace copy
@@ -752,7 +751,7 @@ public class WorkspaceImpl extends Abstr
         if (obsMgr == null) {
             try {
                 obsMgr = new ObservationManagerImpl(
-                        rep.getObservationDispatcher(wspConfig.getName()),
+                        repositoryContext.getRepository().getObservationDispatcher(wspConfig.getName()),
                         session,
                         session.getItemManager(),
                         repositoryContext.getClusterNode());
@@ -777,7 +776,7 @@ public class WorkspaceImpl extends Abstr
         if (queryManager == null) {
             SearchManager searchManager;
             try {
-                searchManager = rep.getSearchManager(wspConfig.getName());
+                searchManager = repositoryContext.getRepository().getSearchManager(wspConfig.getName());
                 if (searchManager == null) {
                     String msg = "no search manager configured for this workspace";
                     log.debug(msg);
@@ -868,7 +867,8 @@ public class WorkspaceImpl extends Abstr
     protected LocalItemStateManager createItemStateManager()
             throws RepositoryException {
         return LocalItemStateManager.createInstance(
-                getSharedItemStateManager(), this, rep.getItemStateCacheFactory());
+                getSharedItemStateManager(), this,
+                repositoryContext.getItemStateCacheFactory());
     }
 
     //------------------------------------------< EventStateCollectionFactory >

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceManager.java?rev=948874&r1=948873&r2=948874&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceManager.java
Thu May 27 16:08:52 2010
@@ -16,8 +16,10 @@
  */
 package org.apache.jackrabbit.core;
 
+import javax.jcr.AccessDeniedException;
 import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.RepositoryException;
+import javax.security.auth.Subject;
 
 import org.apache.jackrabbit.core.state.SharedItemStateManager;
 import org.xml.sax.InputSource;
@@ -85,4 +87,10 @@ public class WorkspaceManager {
         return repository.getWorkspaceStateManager(workspaceName);
     }
 
+    // FIXME: There should be a better place for this. Refactor...
+    public SessionImpl createSession(Subject subject, String workspaceName)
+        throws RepositoryException {
+        return repository.createSession(subject, workspaceName);
+    }
+
 }

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=948874&r1=948873&r2=948874&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 16:08:52 2010
@@ -172,7 +172,8 @@ public class XASessionImpl extends Sessi
         return new InternalXAVersionManager(
                 repositoryContext.getInternalVersionManager(),
                 repositoryContext.getNodeTypeRegistry(),
-                this, rep.getItemStateCacheFactory());
+                this,
+                repositoryContext.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=948874&r1=948873&r2=948874&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 16:08:52 2010
@@ -45,6 +45,6 @@ public class XAWorkspace extends Workspa
             throws RepositoryException {
         return XAItemStateManager.createInstance(
                 getSharedItemStateManager(), this, null,
-                rep.getItemStateCacheFactory());
+                repositoryContext.getItemStateCacheFactory());
     }
 }



Mime
View raw message