jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1309721 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/MicroKernelFactory.java
Date Thu, 05 Apr 2012 09:33:30 GMT
Author: jukka
Date: Thu Apr  5 09:33:29 2012
New Revision: 1309721

URL: http://svn.apache.org/viewvc?rev=1309721&view=rev
Log:
OAK-32: Drop MicroKernel.dispose()

Merge duplicate code in MKF.getInstance()

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

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/MicroKernelFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/MicroKernelFactory.java?rev=1309721&r1=1309720&r2=1309721&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/MicroKernelFactory.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/MicroKernelFactory.java
Thu Apr  5 09:33:29 2012
@@ -61,7 +61,7 @@ public class MicroKernelFactory {
 
         String head = url.substring(0, colon);
         String tail = url.substring(colon + 1);
-        if (head.equals("mem") || head.equals("simple")) {
+        if (head.equals("mem") || head.equals("simple") || head.equals("fs")) {
             boolean clean = false;
             if (tail.endsWith(";clean")) {
                 tail = tail.substring(0, tail.length() - ";clean".length());
@@ -71,21 +71,31 @@ public class MicroKernelFactory {
             tail = tail.replaceAll("\\{homeDir\\}", System.getProperty("homeDir", "."));
 
             if (clean) {
-                String dir = tail.substring(tail.lastIndexOf(':') + 1);
+                String dir;
+                if (head.equals("fs")) {
+                    dir = tail + "/.mk";
+                } else {
+                    dir = tail.substring(tail.lastIndexOf(':') + 1);
+                    INSTANCES.remove(tail);
+                }
+
                 try {
                     FileUtils.deleteRecursive(dir, false);
                 } catch (Exception e) {
                     throw ExceptionFactory.convert(e);
                 }
-                INSTANCES.remove(tail);
             }
 
-            SimpleKernelImpl instance = INSTANCES.get(tail);
-            if (instance == null) {
-                instance = new SimpleKernelImpl(tail);
-                INSTANCES.put(tail, instance);
+            if (head.equals("fs")) {
+                return new MicroKernelImpl(tail);
+            } else {
+                SimpleKernelImpl instance = INSTANCES.get(tail);
+                if (instance == null) {
+                    instance = new SimpleKernelImpl(tail);
+                    INSTANCES.put(tail, instance);
+                }
+                return instance;
             }
-            return instance;
         } else if (head.equals("log")) {
             return new LogWrapper(getInstance(tail));
         } else if (head.equals("sec")) {
@@ -94,24 +104,6 @@ public class MicroKernelFactory {
             return VirtualRepositoryWrapper.get(url);
         } else if (head.equals("index")) {
             return new IndexWrapper(getInstance(tail));
-        } else if (head.equals("fs:")) {
-            boolean clean = false;
-            if (tail.endsWith(";clean")) {
-                tail = tail.substring(0, tail.length() - ";clean".length());
-                clean = true;
-            }
-
-            tail = tail.replaceAll("\\{homeDir\\}", System.getProperty("homeDir", "."));
-
-            if (clean) {
-                try {
-                    FileUtils.deleteRecursive(tail + "/" + ".mk", false);
-                } catch (IOException e) {
-                    throw ExceptionFactory.convert(e);
-                }
-            }
-
-            return new MicroKernelImpl(tail);
         } else if (head.equals("http")) {
             return new Client(url);
         } else if (head.equals("http-bridge")) {



Mime
View raw message