jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1173073 - /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelFactory.java
Date Tue, 20 Sep 2011 10:37:49 GMT
Author: thomasm
Date: Tue Sep 20 10:37:49 2011
New Revision: 1173073

URL: http://svn.apache.org/viewvc?rev=1173073&view=rev
Log:
Use the file system abstraction.

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelFactory.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelFactory.java?rev=1173073&r1=1173072&r2=1173073&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelFactory.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelFactory.java
Tue Sep 20 10:37:49 2011
@@ -16,14 +16,15 @@
  */
 package org.apache.jackrabbit.mk;
 
-import org.apache.jackrabbit.mk.api.MicroKernel;
-import org.apache.jackrabbit.mk.client.Client;
-import org.apache.jackrabbit.mk.mem.MemoryKernelImpl;
-
-import java.io.File;
+import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.URI;
 import java.net.URISyntaxException;
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.mk.client.Client;
+import org.apache.jackrabbit.mk.fs.FileUtils;
+import org.apache.jackrabbit.mk.mem.MemoryKernelImpl;
+import org.apache.jackrabbit.mk.util.ExceptionFactory;
 
 /**
  * A factory to create a MicroKernel instance.
@@ -43,24 +44,22 @@ public class MicroKernelFactory {
      * @return a new instance
      */
     public static MicroKernel getInstance(String url) {
-        boolean clean = false;
-        if (url.endsWith(";clean")) {
-            url = url.substring(0, url.length() - ";clean".length());
-            clean = true;
-        }
         if (url.startsWith("mem:")) {
-            String dir = url.substring("mem:".length());
-            dir = dir.replaceAll("\\{homeDir\\}", System.getProperty("homeDir", "."));
-            MemoryKernelImpl impl = MemoryKernelImpl.get(dir);
-            if (clean) {
-                impl.clear();
-            }
-            return impl;
+            return MemoryKernelImpl.get(url);
         } else if (url.startsWith("fs:")) {
+            boolean clean = false;
+            if (url.endsWith(";clean")) {
+                url = url.substring(0, url.length() - ";clean".length());
+                clean = true;
+            }
             String dir = url.substring("fs:".length());
             dir = dir.replaceAll("\\{homeDir\\}", System.getProperty("homeDir", "."));
             if (clean) {
-                rm(new File(dir, ".mk"));
+                try {
+                    FileUtils.deleteRecursive(dir + "/" + ".mk", false);
+                } catch (IOException e) {
+                    throw ExceptionFactory.convert(e);
+                }
             }
             return new MicroKernelImpl(dir);
         } else if (url.startsWith("http:")) {
@@ -75,15 +74,4 @@ public class MicroKernelFactory {
         }
     }
 
-    static boolean rm(File f) {
-        if (f.isDirectory()) {
-            for (String child : f.list()) {
-                if (! rm(new File(f, child))) {
-                    return false;
-                }
-            }
-        }
-
-        return f.delete();
-    }
 }



Mime
View raw message