jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r948803 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: RepositoryContext.java RepositoryImpl.java SessionImpl.java
Date Thu, 27 May 2010 12:28:06 GMT
Author: jukka
Date: Thu May 27 12:28:06 2010
New Revision: 948803

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

Add repository file system to RepositoryContext. No more need for the separate metaDataStore
fs.

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

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=948803&r1=948802&r2=948803&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 12:28:06 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core;
 
+import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.version.InternalVersionManagerImpl;
@@ -55,6 +56,11 @@ public class RepositoryContext {
     private NodeId rootNodeId;
 
     /**
+     * The repository file system.
+     */
+    private FileSystem fileSystem;
+
+    /**
      * Creates a component context for the given repository.
      *
      * @param repository repository instance
@@ -154,4 +160,24 @@ public class RepositoryContext {
         this.rootNodeId = rootNodeId;
     }
 
+    /**
+     * Returns the repository file system.
+     *
+     * @return repository file system
+     */
+    public FileSystem getFileSystem() {
+        assert fileSystem != null;
+        return fileSystem;
+    }
+
+    /**
+     * Sets the repository file system.
+     *
+     * @param fileSystem repository file system
+     */
+    public void setFileSystem(FileSystem fileSystem) {
+        assert fileSystem != null;
+        this.fileSystem = fileSystem;
+    }
+
 }

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=948803&r1=948802&r2=948803&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 12:28:06 2010
@@ -102,7 +102,6 @@ import org.apache.jackrabbit.core.state.
 import org.apache.jackrabbit.core.state.ManagedMLRUItemStateCacheFactory;
 import org.apache.jackrabbit.core.state.SharedItemStateManager;
 import org.apache.jackrabbit.core.util.RepositoryLockMechanism;
-import org.apache.jackrabbit.core.version.InternalVersionManager;
 import org.apache.jackrabbit.core.version.InternalVersionManagerImpl;
 import org.apache.jackrabbit.core.xml.ClonedInputSource;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
@@ -184,12 +183,6 @@ public class RepositoryImpl extends Abst
     // configuration of the repository
     protected final RepositoryConfig repConfig;
 
-    // the virtual repository file system
-    private final FileSystem repStore;
-
-    // sub file system where the repository stores meta data such as uuid of root node, etc.
-    private final FileSystem metaDataStore;
-
     /**
      * Data store for binary properties.
      */
@@ -304,21 +297,11 @@ public class RepositoryImpl extends Abst
             this.repConfig = repConfig;
 
             // setup file systems
-            repStore = repConfig.getFileSystem();
-            String fsRootPath = "/meta";
-            try {
-                if (!repStore.exists(fsRootPath) || !repStore.isFolder(fsRootPath)) {
-                    repStore.createFolder(fsRootPath);
-                }
-            } catch (FileSystemException fse) {
-                String msg = "failed to create folder for repository meta data";
-                log.error(msg, fse);
-                throw new RepositoryException(msg, fse);
-            }
-            metaDataStore = new BasedFileSystem(repStore, fsRootPath);
+            FileSystem repStore = repConfig.getFileSystem();
+            context.setFileSystem(repStore);
 
             // init root node uuid
-            context.setRootNodeId(loadRootNodeId(metaDataStore));
+            context.setRootNodeId(loadRootNodeId(repStore));
 
             // initialize repository descriptors
             initRepositoryDescriptors();
@@ -563,6 +546,18 @@ public class RepositoryImpl extends Abst
      * @throws RepositoryException
      */
     protected NodeId loadRootNodeId(FileSystem fs) throws RepositoryException {
+        String fsRootPath = "/meta";
+        try {
+            if (!fs.exists(fsRootPath) || !fs.isFolder(fsRootPath)) {
+                fs.createFolder(fsRootPath);
+            }
+        } catch (FileSystemException fse) {
+            String msg = "failed to create folder for repository meta data";
+            log.error(msg, fse);
+            throw new RepositoryException(msg, fse);
+        }
+        fs = new BasedFileSystem(fs, fsRootPath);
+
         FileSystemResource uuidFile = new FileSystemResource(fs, "rootUUID");
         try {
             if (uuidFile.exists()) {
@@ -1189,13 +1184,11 @@ public class RepositoryImpl extends Abst
             }
         }
 
-        if (repStore != null) {
-            try {
-                // close repository file system
-                repStore.close();
-            } catch (FileSystemException e) {
-                log.error("error while closing repository file system", e);
-            }
+        try {
+            // close repository file system
+            context.getFileSystem().close();
+        } catch (FileSystemException e) {
+            log.error("error while closing repository file system", e);
         }
 
         // make sure this instance is not used anymore
@@ -1239,14 +1232,6 @@ public class RepositoryImpl extends Abst
     }
 
     /**
-     * Returns the repository file system.
-     * @return repository file system
-     */
-    protected FileSystem getFileSystem() {
-        return repStore;
-    }
-
-    /**
      * Initializes the repository descriptors by executing the following steps:
      * <ul>
      * <li>Sets standard descriptors</li>

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=948803&r1=948802&r2=948803&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 12:28:06 2010
@@ -372,7 +372,7 @@ public class SessionImpl extends Abstrac
             throws AccessDeniedException, RepositoryException {
         String wspName = getWorkspace().getName();
         AMContext ctx = new AMContext(new File(rep.getConfig().getHomeDir()),
-                rep.getFileSystem(),
+                repositoryContext.getFileSystem(),
                 this,
                 getSubject(),
                 hierarchyManager,



Mime
View raw message