jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpfis...@apache.org
Subject svn commit: r1304266 - in /jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core: MicroKernelImpl.java Repository.java
Date Fri, 23 Mar 2012 10:27:34 GMT
Author: dpfister
Date: Fri Mar 23 10:27:34 2012
New Revision: 1304266

URL: http://svn.apache.org/viewvc?rev=1304266&view=rev
Log:
OAK-31 - In-memory MicroKernel for testing
- add default constructor to MicroKernelImpl that uses in-memory mode

Modified:
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/Repository.java

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java?rev=1304266&r1=1304265&r2=1304266&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java
Fri Mar 23 10:27:34 2012
@@ -60,6 +60,13 @@ public class MicroKernelImpl implements 
     }
     
     /**
+     * Argument-less constructor, used for in-memory kernel.
+     */
+    public MicroKernelImpl() {
+        this(new Repository());
+    }
+    
+    /**
      * Alternate constructor, used for testing.
      * 
      * @param rep repository, already initialized

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/Repository.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/Repository.java?rev=1304266&r1=1304265&r2=1304266&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/Repository.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/Repository.java
Fri Mar 23 10:27:34 2012
@@ -21,11 +21,13 @@ import java.io.File;
 
 import org.apache.jackrabbit.mk.blobs.BlobStore;
 import org.apache.jackrabbit.mk.blobs.FileBlobStore;
+import org.apache.jackrabbit.mk.blobs.MemoryBlobStore;
 import org.apache.jackrabbit.mk.model.CommitBuilder;
 import org.apache.jackrabbit.mk.model.Id;
 import org.apache.jackrabbit.mk.model.NodeState;
 import org.apache.jackrabbit.mk.model.StoredCommit;
 import org.apache.jackrabbit.mk.persistence.H2Persistence;
+import org.apache.jackrabbit.mk.persistence.InMemPersistence;
 import org.apache.jackrabbit.mk.store.DefaultRevisionStore;
 import org.apache.jackrabbit.mk.store.NotFoundException;
 import org.apache.jackrabbit.mk.store.RevisionStore;
@@ -51,7 +53,8 @@ public class Repository {
     /**
      * Alternate constructor, used for testing.
      * 
-     * @param rs revision store, already initialized
+     * @param rs revision store
+     * @param bs blob store
      */
     public Repository(RevisionStore rs, BlobStore bs) {
         this.homeDir = null;
@@ -60,6 +63,26 @@ public class Repository {
 
         initialized = true;
     }
+
+    /**
+     * Argument-less constructor, used for in-memory kernel.
+     */
+    protected Repository() {
+        this.homeDir = null;
+        
+        DefaultRevisionStore rs = new DefaultRevisionStore(new InMemPersistence());
+        
+        try {
+            rs.initialize();
+        } catch (Exception e) {
+            /* Not plausible for in-memory operation */
+            throw new InternalError("Unable to initialize in-memory store");
+        }
+        this.rs = rs;
+        this.bs = new MemoryBlobStore();
+        
+        initialized = true;
+    }
     
     public void init() throws Exception {
         if (initialized) {



Mime
View raw message