jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1328607 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/configuration/ oak-run/src/main/java/org/ap...
Date Sat, 21 Apr 2012 08:06:57 GMT
Author: jukka
Date: Sat Apr 21 08:06:56 2012
New Revision: 1328607

URL: http://svn.apache.org/viewvc?rev=1328607&view=rev
Log:
OAK-18: Define Oak API

Rename TmpRepositoryService to KernelContentRepository to match the new interface name.
Streamline repository construction.

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentRepository.java
      - copied, changed from r1328604, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TmpRepositoryService.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TmpRepositoryService.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/configuration/OakRepositoryConfiguration.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/configuration/RepositoryConfiguration.java
Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/GlobalContext.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/OakRepositoryFactory.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentRepository.java
(from r1328604, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TmpRepositoryService.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentRepository.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentRepository.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TmpRepositoryService.java&r1=1328604&r2=1328607&rev=1328607&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TmpRepositoryService.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentRepository.java
Sat Apr 21 08:06:56 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.oak.core;
 
-import org.apache.jackrabbit.mk.MicroKernelFactory;
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.kernel.NodeState;
@@ -34,14 +33,14 @@ import javax.jcr.SimpleCredentials;
 import javax.security.auth.login.LoginException;
 
 /**
- * TmpRepositoryService...
+ * {@link MicroKernel}-based implementation of
+ * the {@link ContentRepository} interface.
  */
-public class TmpRepositoryService implements ContentRepository {
+public class KernelContentRepository implements ContentRepository {
 
-    /**
-     * logger instance
-     */
-    private static final Logger log = LoggerFactory.getLogger(TmpRepositoryService.class);
+    /** Logger instance */
+    private static final Logger log =
+            LoggerFactory.getLogger(KernelContentRepository.class);
 
     // TODO: retrieve default wsp-name from configuration
     private static final String DEFAULT_WORKSPACE_NAME = "default";
@@ -49,8 +48,8 @@ public class TmpRepositoryService implem
     private final MicroKernel microKernel;
     private final KernelNodeStore nodeStore;
 
-    public TmpRepositoryService(String microKernelUrl) {
-        microKernel = MicroKernelFactory.getInstance(microKernelUrl);
+    public KernelContentRepository(MicroKernel mk) {
+        microKernel = mk;
         nodeStore = new KernelNodeStore(microKernel);
     }
 
@@ -70,7 +69,7 @@ public class TmpRepositoryService implem
         } else {
             sc = null;
         }
-        
+
         if (sc == null) {
             throw new LoginException("login failed");
         }
@@ -103,4 +102,5 @@ public class TmpRepositoryService implem
         // TODO: define if/how desired revision can be passed in by the credentials object.
         return null;
     }
-}
\ No newline at end of file
+
+}

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/GlobalContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/GlobalContext.java?rev=1328607&r1=1328606&r2=1328607&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/GlobalContext.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/GlobalContext.java
Sat Apr 21 08:06:56 2012
@@ -19,15 +19,13 @@
 
 package org.apache.jackrabbit.oak.jcr;
 
+import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.oak.api.ContentRepository;
-import org.apache.jackrabbit.oak.core.TmpRepositoryService;
-import org.apache.jackrabbit.oak.jcr.configuration.OakRepositoryConfiguration;
-import org.apache.jackrabbit.oak.jcr.configuration.RepositoryConfiguration;
+import org.apache.jackrabbit.oak.core.KernelContentRepository;
 import org.apache.jackrabbit.oak.jcr.util.Unchecked;
 
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -41,23 +39,19 @@ import static java.text.MessageFormat.fo
  * time dependency injection mechanism.
  */
 public class GlobalContext {
+
     private final Map<Class<?>, Object> instances = new HashMap<Class<?>,
Object>();
-    
-    public GlobalContext(RepositoryConfiguration repositoryConfiguration) throws RepositoryException
{
-        put(RepositoryConfiguration.class, repositoryConfiguration);
-        put(ContentRepository.class, new TmpRepositoryService(repositoryConfiguration.getMicrokernelUrl()));
-        put(Repository.class, new RepositoryImpl(this));
-    }
 
-    public GlobalContext(String microKernelUrl) throws RepositoryException {
-        this(OakRepositoryConfiguration.create(Collections.singletonMap(
-                RepositoryConfiguration.MICROKERNEL_URL, microKernelUrl)));
+    public GlobalContext(MicroKernel mk) throws RepositoryException {
+        put(ContentRepository.class, new KernelContentRepository(mk));
+        put(Repository.class, new RepositoryImpl(this));
     }
 
     public <T> T getInstance(Class<T> forClass) {
         T instance = Unchecked.<T>cast(instances.get(forClass));
         if (instance == null) {
-            throw new IllegalStateException(format("Global context does not contain {0}",
forClass));
+            throw new IllegalStateException(
+                    format("Global context does not contain {0}", forClass));
         }
         return instance;
     }
@@ -66,9 +60,9 @@ public class GlobalContext {
 
     private <T, I extends T> void put(Class<T> classType, I instance) {
         if (instances.containsKey(classType)) {
-            throw new IllegalStateException(format("Global context already contains {0}",
classType));
+            throw new IllegalStateException(
+                    format("Global context already contains {0}", classType));
         }
-
         instances.put(classType, instance);
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/OakRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/OakRepositoryFactory.java?rev=1328607&r1=1328606&r2=1328607&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/OakRepositoryFactory.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/OakRepositoryFactory.java
Sat Apr 21 08:06:56 2012
@@ -16,12 +16,12 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
-import org.apache.jackrabbit.oak.jcr.configuration.OakRepositoryConfiguration;
-import org.apache.jackrabbit.oak.jcr.configuration.RepositoryConfiguration;
-
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.RepositoryFactory;
+
+import org.apache.jackrabbit.mk.core.MicroKernelImpl;
+
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Map;
@@ -48,12 +48,11 @@ public class OakRepositoryFactory implem
         return null;
     }
 
-    private static Repository getRepository(URI uri, Map<String, String> parameters)
+    private static Repository getRepository(
+            URI uri, Map<String, String> parameters)
             throws RepositoryException {
-
-        // todo correctly interpret uri
-        parameters.put(RepositoryConfiguration.MICROKERNEL_URL, "simple:target/repository-test/repository");
-        GlobalContext context = new GlobalContext(OakRepositoryConfiguration.create(parameters));
+        // TODO correctly interpret uri
+        GlobalContext context = new GlobalContext(new MicroKernelImpl());
         return context.getInstance(Repository.class);
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java?rev=1328607&r1=1328606&r2=1328607&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
Sat Apr 21 08:06:56 2012
@@ -42,14 +42,6 @@ public class RepositoryImpl implements R
     private final GlobalContext context;
     private final Descriptors descriptors = new Descriptors(new SimpleValueFactory());
 
-    /**
-     * Utility constructor that creates a JCR binding for an initially empty,
-     * newly constructed Oak repository.
-     */
-    public RepositoryImpl() throws RepositoryException {
-        context = new GlobalContext("mem:oak");
-    }
-
     public RepositoryImpl(GlobalContext context) {
         this.context = context;
     }

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java?rev=1328607&r1=1328606&r2=1328607&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java Sat
Apr 21 08:06:56 2012
@@ -16,14 +16,12 @@
  */
 package org.apache.jackrabbit.oak.run;
 
-import java.util.Collections;
-
 import javax.jcr.Repository;
 import javax.servlet.Servlet;
 
+import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.oak.jcr.GlobalContext;
-import org.apache.jackrabbit.oak.jcr.configuration.OakRepositoryConfiguration;
-import org.apache.jackrabbit.oak.jcr.configuration.RepositoryConfiguration;
+import org.apache.jackrabbit.oak.jcr.RepositoryImpl;
 import org.apache.jackrabbit.webdav.jcr.JCRWebdavServerServlet;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.servlet.ServletContextHandler;
@@ -32,16 +30,8 @@ import org.eclipse.jetty.servlet.Servlet
 public class Main {
 
     public static void main(String[] args) throws Exception {
-        String url = "mem:oak";
-        if (args.length > 0) {
-            url = args[0];
-        }
-
-        RepositoryConfiguration configuration =
-                OakRepositoryConfiguration.create(Collections.singletonMap(
-                        RepositoryConfiguration.MICROKERNEL_URL, url));
         final Repository repository =
-                new GlobalContext(configuration).getInstance(Repository.class);
+                new RepositoryImpl(new GlobalContext(new MicroKernelImpl()));
         Servlet servlet = new JCRWebdavServerServlet() {
             @Override
             protected Repository getRepository() {



Mime
View raw message