You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by al...@apache.org on 2013/09/12 09:19:19 UTC

svn commit: r1522466 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java

Author: alexparvulescu
Date: Thu Sep 12 07:19:19 2013
New Revision: 1522466

URL: http://svn.apache.org/r1522466
Log:
OAK-1010 Unify the repository home config for the OSGi setup
 - fixed the persistence selection mechanism

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java?rev=1522466&r1=1522465&r2=1522466&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java Thu Sep 12 07:19:19 2013
@@ -55,7 +55,7 @@ public class SegmentNodeStoreService ext
     @Property(description="TarMK directory (if unset, use MongoDB)")
     public static final String DIRECTORY = "repository.home";
 
-    @Property(description="MongoDB host", value="localhost")
+    @Property(description="MongoDB host")
     public static final String HOST = "host";
 
     @Property(description="MongoDB host", intValue=27017)
@@ -90,13 +90,12 @@ public class SegmentNodeStoreService ext
         Dictionary<?, ?> properties = context.getProperties();
         name = "" + properties.get(NAME);
 
-        String directory = readDirectory(context);
-        if (directory != null) {
-
+        String host = lookup(context, HOST);
+        if (host == null) {
+            String directory = lookup(context, DIRECTORY);
             mongo = null;
             store = new FileStore(directory);
         } else {
-            String host = String.valueOf(properties.get(HOST));
             int port = Integer.parseInt(String.valueOf(properties.get(PORT)));
             String db = String.valueOf(properties.get(DB));
             int cache = Integer.parseInt(String.valueOf(properties.get(CACHE)));
@@ -112,12 +111,12 @@ public class SegmentNodeStoreService ext
         delegate = new SegmentNodeStore(store);
     }
 
-    private static String readDirectory(ComponentContext context) {
-        if (context.getProperties().get(DIRECTORY) != null) {
-            return context.getProperties().get(DIRECTORY).toString();
+    private static String lookup(ComponentContext context, String property) {
+        if (context.getProperties().get(property) != null) {
+            return context.getProperties().get(property).toString();
         }
-        if (context.getBundleContext().getProperty(DIRECTORY) != null) {
-            return context.getBundleContext().getProperty(DIRECTORY).toString();
+        if (context.getBundleContext().getProperty(property) != null) {
+            return context.getBundleContext().getProperty(property).toString();
         }
         return null;
     }