jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1133775 - in /jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel: RepositoryServiceFactoryImpl.java RepositoryServiceImpl.java
Date Thu, 09 Jun 2011 10:23:26 GMT
Author: thomasm
Date: Thu Jun  9 10:23:25 2011
New Revision: 1133775

URL: http://svn.apache.org/viewvc?rev=1133775&view=rev
Log:
Use factory.

Modified:
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceFactoryImpl.java
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceFactoryImpl.java?rev=1133775&r1=1133774&r2=1133775&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceFactoryImpl.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceFactoryImpl.java
Thu Jun  9 10:23:25 2011
@@ -18,50 +18,21 @@
  */
 package org.apache.jackrabbit.spi2microkernel;
 
-import org.apache.jackrabbit.mk.MicroKernelImpl;
+import java.util.Map;
+import javax.jcr.RepositoryException;
+import org.apache.jackrabbit.mk.MicroKernelFactory;
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.spi.RepositoryService;
 import org.apache.jackrabbit.spi.RepositoryServiceFactory;
 
-import javax.jcr.RepositoryException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Map;
-
 public class RepositoryServiceFactoryImpl implements RepositoryServiceFactory {
-    public static final String PARAM_HOME_DIR = "org.apache.jackrabbit.spi2microkernel.home-dir";
-    
-    public RepositoryService createRepositoryService(Map<?, ?> parameters) throws RepositoryException
{
-        String homeDir = getHomeDir(parameters);
-
-        // todo use factory to create actual micro kernel instance
-        MicroKernel microKernel = new MicroKernelImpl(homeDir);
+    public static final String PARAM_URL = "org.apache.jackrabbit.spi2microkernel.url";
 
+    public RepositoryService createRepositoryService(Map<?, ?> parameters) throws RepositoryException
{
+        Object u = parameters.get(PARAM_URL);
+        String url = u == null ? null : u.toString();
+        MicroKernel microKernel = MicroKernelFactory.getInstance(url);
         return new RepositoryServiceImpl(microKernel);
     }
 
-    //------------------------------------------< private >---
-
-    private static String getHomeDir(Map<?, ?> parameters) {
-        Object uri = parameters.get(PARAM_HOME_DIR);
-        URI homeDir;
-        if (uri instanceof URI) {
-            homeDir = (URI) uri;
-        }
-        else if (uri instanceof String) {
-            try {
-                homeDir = new URI((String) uri);
-            }
-            catch (URISyntaxException e) {
-                return null; 
-            }
-        }
-        else {
-            return null;
-        }
-
-        return "file".equals(homeDir.getScheme())
-            ? homeDir.getPath()
-            : null;
-    }
 }

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java?rev=1133775&r1=1133774&r2=1133775&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
Thu Jun  9 10:23:25 2011
@@ -86,10 +86,10 @@ public class RepositoryServiceImpl exten
 
             String head = microKernel.getHeadRevision();
             createWorkspace(head, Paths.DEFAULT_WORKSPACE, true);
-            createWorkspace(head, Paths.SYSTEM_WORKSPACE, true);            
+            createWorkspace(head, Paths.SYSTEM_WORKSPACE, true);
         }
         catch (MicroKernelException e) {
-            throw new RepositoryException(e.getMessage(), e); 
+            throw new RepositoryException(e.getMessage(), e);
         }
     }
 
@@ -359,7 +359,7 @@ public class RepositoryServiceImpl exten
         try {
             String wspName = Paths.getWorkspaceName(name);
             if (!microKernel.nodeExists('/' + wspName, revisionId)) {
-                throw new NoSuchWorkspaceException("No such workspace: " + name);       
        
+                throw new NoSuchWorkspaceException("No such workspace: " + name);
             }
 
             microKernel.commit("/", '-' + wspName + " : ", revisionId);



Mime
View raw message