Index: ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreHelper.java
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreHelper.java	(date 1394682836000)
+++ ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreHelper.java	(date 1394682836000)
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.blob;
-
-import org.apache.jackrabbit.oak.spi.blob.BlobStore;
-import org.apache.jackrabbit.oak.plugins.blob.cloud.CloudBlobStore;
-import org.apache.jackrabbit.oak.plugins.blob.cloud.CloudBlobStoreBuilder;
-import org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore;
-import org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStoreBuilder;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Strings;
-
-/**
- * A factory helper for creating BlobStore objects.
- */
-public class BlobStoreHelper {
-    /**
-     * Creates the appropriate BlobStoreBuilder instance based on the blobType.
-     * 
-     * @param blobStoreType
-     *            the blob type
-     * @return the BlobStoreBuilder wrapped as {@link Optional} to indicate that
-     *         the builder returned may be null in the case of a default
-     *         BlobStoreType
-     * @throws Exception
-     *             the exception
-     */
-    public static Optional<BlobStoreBuilder> createFactory(BlobStoreConfiguration config)
-            throws Exception {
-
-        BlobStoreBuilder builder = null;
-        if (!Strings.isNullOrEmpty(
-                config.getProperty(BlobStoreConfiguration.PROP_BLOB_STORE_PROVIDER))) {
-            String blobStoreProvider =
-                    config.getProperty(BlobStoreConfiguration.PROP_BLOB_STORE_PROVIDER);
-            if (blobStoreProvider.equals(CloudBlobStore.class.getName())) {
-                builder = CloudBlobStoreBuilder.newInstance();
-            } else if (blobStoreProvider.equals(DataStoreBlobStore.class.getName())) {
-                builder = DataStoreBlobStoreBuilder.newInstance();
-            }
-        }
-
-        return Optional.fromNullable(builder);
-    }
-
-    /**
-     * Creates the appropriate BlobStore instance based on the blobType and the
-     * configuration.
-     * 
-     * @param blobStoreType
-     *            the blob type
-     * @param config
-     *            the config
-     * @return the BlobStoreBuilder wrapped as {@link Optional} to indicate that
-     *         the builder returned may be null in the case of a default
-     *         BlobStoreType or an invalid config
-     * @throws Exception
-     *             the exception
-     */
-    public static Optional<BlobStore> create(BlobStoreConfiguration config)
-            throws Exception {
-        BlobStore blobStore = null;
-        BlobStoreBuilder builder = createFactory(config).orNull();
-
-        if ((builder != null) && (config != null)) {
-            blobStore = builder.build(config).orNull();
-        }
-        return Optional.fromNullable(blobStore);
-    }
-}
Index: ../../../git/apache/jackrabbit-oak/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/osgi/FileBlobStoreService.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/osgi/FileBlobStoreService.java	(revision )
+++ ../../../git/apache/jackrabbit-oak/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/osgi/FileBlobStoreService.java	(revision )
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.jackrabbit.oak.spi.blob.osgi;
+
+
+import java.util.Map;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.ConfigurationPolicy;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.jackrabbit.oak.commons.PropertiesUtil;
+import org.apache.jackrabbit.oak.spi.blob.BlobStore;
+import org.apache.jackrabbit.oak.spi.blob.FileBlobStore;
+import org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Component(policy = ConfigurationPolicy.REQUIRE, name = FileBlobStoreService.NAME)
+public class FileBlobStoreService {
+    public static final String NAME = "org.apache.jackrabbit.oak.spi.blob.FileBlobStore";
+
+    private static final String PROP_HOME = "repository.home";
+
+    private ServiceRegistration reg;
+
+    private Logger log = LoggerFactory.getLogger(getClass());
+
+    @Activate
+    protected void activate(ComponentContext context, Map<String, Object> config) {
+        String homeDir = lookup(context, PROP_HOME);
+        if (homeDir != null) {
+            log.info("Initializing the FileBlobStore with homeDir [{}]", homeDir);
+        }
+        BlobStore blobStore = new FileBlobStore(FilenameUtils.concat(homeDir,"datastore"));
+        PropertiesUtil.populate(blobStore, config, false);
+        reg = context.getBundleContext().registerService(new String[]{
+                BlobStore.class.getName(),
+                GarbageCollectableBlobStore.class.getName()
+        }, blobStore, null);
+    }
+
+    @Deactivate
+    protected void deactivate() {
+        if (reg != null) {
+            reg.unregister();
+        }
+    }
+
+    protected static String lookup(ComponentContext context, String property) {
+        //Prefer property from BundleContext first
+        if (context.getBundleContext().getProperty(property) != null) {
+            return context.getBundleContext().getProperty(property).toString();
+        }
+
+        if (context.getProperties().get(property) != null) {
+            return context.getProperties().get(property).toString();
+        }
+        return null;
+    }
+}
Index: ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DbDataStoreService.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DbDataStoreService.java	(revision )
+++ ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DbDataStoreService.java	(revision )
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.jackrabbit.oak.plugins.blob.datastore;
+
+import java.util.Map;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.ConfigurationPolicy;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.jackrabbit.core.data.DataStore;
+import org.apache.jackrabbit.core.data.db.DbDataStore;
+import org.apache.jackrabbit.core.util.db.ConnectionFactory;
+import org.osgi.service.component.ComponentContext;
+
+@Component(policy = ConfigurationPolicy.REQUIRE, name=DbDataStoreService.NAME)
+public class DbDataStoreService extends AbstractDataStoreService{
+    public static final String NAME = "org.apache.jackrabbit.oak.plugins.blob.datastore.DbDataStore";
+
+    @Reference
+    private ConnectionFactory connectionFactory;
+
+    @Override
+    protected DataStore createDataStore(ComponentContext context, Map<String, Object> config) {
+        DbDataStore dataStore = new DbDataStore();
+        dataStore.setConnectionFactory(connectionFactory);
+        return dataStore;
+    }
+}
+
Index: ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreConfiguration.java
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreConfiguration.java	(date 1394682836000)
+++ ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreConfiguration.java	(date 1394682836000)
@@ -1,172 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.blob;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.annotation.Nullable;
-
-import com.google.common.base.Strings;
-import org.osgi.framework.BundleContext;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-/**
- * Defines the configuration needed by a BlobStore.
- */
-public class BlobStoreConfiguration {
-
-    public static final String PRIMARY_DATA_STORE = "primary";
-
-    public static final String ARCHIVE_DATA_STORE = "archive";
-
-    public static final String PROP_DATA_STORE = "dataStoreProvider";
-
-    public static final String PROP_BLOB_STORE_PROVIDER = "blobStoreProvider";
-
-    public static final String DEFAULT_BLOB_STORE_PROVIDER = "";
-
-    private Map<String, String> configMap;
-
-    private Set<String> propKeys;
-
-    /**
-     * Instantiates a new data store configuration.
-     */
-    private BlobStoreConfiguration() {
-        configMap = Maps.newHashMap();
-        propKeys = Sets.newHashSet();
-
-        // get default props
-        Properties props = new Properties();
-        try {
-            props.load(this.getClass().getResourceAsStream("blobstore.properties"));
-        } catch (IOException ignore) {
-        }
-
-        // populate keys from the default set
-        Map<String, String> defaultMap = Maps.fromProperties(props);
-        propKeys.addAll(defaultMap.keySet());
-
-        // Remove empty default properties from the map
-        getConfigMap().putAll(
-                Maps.filterValues(defaultMap, new Predicate<String>() {
-                    @Override
-                    public boolean apply(@Nullable String input) {
-                        if ((input == null) || input.trim().length() == 0) {
-                            return false;
-                        }
-                        return true;
-                    }
-                }));
-    }
-
-    /**
-     * Creates a new configuration object with default values.
-     * 
-     * @return the data store configuration
-     */
-    public static BlobStoreConfiguration newInstance() {
-        return new BlobStoreConfiguration();
-    }
-
-    /**
-     * Load configuration from the system props.
-     * 
-     * @return the configuration
-     */
-    public BlobStoreConfiguration loadFromSystemProps() {
-        // remove all jvm set properties to trim the map
-        getConfigMap().putAll(Maps.filterKeys(Maps.fromProperties(System.getProperties()), new Predicate<String>() {
-            @Override
-            public boolean apply(@Nullable String input) {
-                if (input.startsWith("java.") || input.startsWith("sun.") || input.startsWith("user.")
-                        || input.startsWith("file.") || input.startsWith("line.") || input.startsWith("os.")
-                        || input.startsWith("awt.") || input.startsWith("path.")) {
-                    return false;
-                } else {
-                    return true;
-                }
-            }
-        }));
-        return this;
-    }
-
-    /**
-     * Load configuration from a map.
-     * 
-     * @param map
-     *            the map
-     * @return the configuration
-     */
-    @SuppressWarnings("unchecked")
-    public BlobStoreConfiguration loadFromMap(Map<String, ?> cfgMap) {
-        getConfigMap().putAll((Map<? extends String, ? extends String>) cfgMap);
-        loadFromSystemProps();
-
-        return this;
-    }
-
-    /**
-     * Load configuration from a BundleContext or the map provided.
-     * 
-     * @param map
-     *            the map
-     * @param context
-     *            the context
-     * @return the configuration
-     */
-    public BlobStoreConfiguration loadFromContextOrMap(Map<String, ?> map, BundleContext context) {
-        loadFromMap(map);
-
-        for (String key : getPropKeys()) {
-            if (context.getProperty(key) != null) {
-                configMap.put(key, context.getProperty(key));
-            }
-        }
-        return this;
-    }
-
-    public String getProperty(String key) {
-        return getConfigMap().get(key);
-    }
-
-    public void addProperty(String key, String val) {
-        getConfigMap().put(key, val);
-    }
-
-    public Map<String, String> getConfigMap() {
-        return configMap;
-    }
-
-    public void setConfigMap(Map<String, String> configMap) {
-        this.configMap = configMap;
-    }
-
-    public Set<String> getPropKeys() {
-        return propKeys;
-    }
-
-    public void setPropKeys(Set<String> propKeys) {
-        this.propKeys = propKeys;
-    }
-}
Index: ../../../git/apache/jackrabbit-oak/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakFixture.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakFixture.java	(date 1394682836000)
+++ ../../../git/apache/jackrabbit-oak/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakFixture.java	(revision )
@@ -17,14 +17,16 @@
 package org.apache.jackrabbit.oak.fixture;
 
 import java.io.File;
+import java.util.Map;
 
+import com.google.common.collect.Maps;
 import org.apache.commons.io.FileUtils;
+import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.oak.Oak;
+import org.apache.jackrabbit.oak.commons.PropertiesUtil;
 import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
-import org.apache.jackrabbit.oak.plugins.blob.BlobStoreConfiguration;
-import org.apache.jackrabbit.oak.plugins.blob.BlobStoreHelper;
 import org.apache.jackrabbit.oak.plugins.blob.cloud.CloudBlobStore;
 import org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore;
 import org.apache.jackrabbit.oak.plugins.document.DocumentMK;
@@ -142,15 +144,35 @@
             private BlobStore blobStore;
 
             private BlobStore getBlobStore() {
-                BlobStoreConfiguration config =
-                        BlobStoreConfiguration.newInstance().loadFromSystemProps();
+
                 try {
-                    blobStore = BlobStoreHelper.create(config).orNull();
+                    String className = System.getProperty("dataStore");
+                    if(className != null){
+                        DataStore ds = Class.forName(className).asSubclass(DataStore.class).newInstance();
+                        ds.init(null);
+                        PropertiesUtil.populate(ds, getConfig(), false);
+                        blobStore = new DataStoreBlobStore(ds);
+                    }
                 } catch (Exception e) {
                     throw new RuntimeException(e);
                 }
 
                 return blobStore;
+            }
+
+            /**
+             * Taken from org.apache.jackrabbit.oak.plugins.document.blob.ds.DataStoreUtils
+             */
+            private Map<String,?> getConfig(){
+                Map<String,Object> result = Maps.newHashMap();
+                for(Map.Entry<String,?> e : Maps.fromProperties(System.getProperties()).entrySet()){
+                    String key = e.getKey();
+                    if(key.startsWith("ds.") || key.startsWith("bs.")){
+                        key = key.substring(3); //length of bs.
+                        result.put(key, e.getValue());
+                    }
+                }
+                return result;
             }
 
             @Override
\ No newline at end of file
Index: ../../../git/apache/jackrabbit-oak/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/cloud/CloudStoreUtils.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/cloud/CloudStoreUtils.java	(date 1394682836000)
+++ ../../../git/apache/jackrabbit-oak/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/cloud/CloudStoreUtils.java	(revision )
@@ -17,9 +17,6 @@
 package org.apache.jackrabbit.oak.plugins.document.blob.cloud;
 
 import org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore;
-import org.apache.jackrabbit.oak.plugins.blob.BlobStoreConfiguration;
-import org.apache.jackrabbit.oak.plugins.blob.BlobStoreHelper;
-import org.apache.jackrabbit.oak.plugins.blob.cloud.CloudBlobStore;
 
 /**
  * Helper class for retrieving the appropriate blobStore instance
@@ -34,10 +31,7 @@
      *             the exception
      */
     public static AbstractBlobStore getBlobStore() throws Exception {
-        BlobStoreConfiguration config =
-                BlobStoreConfiguration.newInstance().loadFromSystemProps();
-        config.addProperty(
-                BlobStoreConfiguration.PROP_BLOB_STORE_PROVIDER, CloudBlobStore.class.getName());
-        return (AbstractBlobStore) BlobStoreHelper.create(config).orNull();
+        //TODO Need to be implemented
+        return null;
     }
 }
\ No newline at end of file
Index: ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/cloud/CloudBlobStoreBuilder.java
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/cloud/CloudBlobStoreBuilder.java	(date 1394682836000)
+++ ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/cloud/CloudBlobStoreBuilder.java	(date 1394682836000)
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.blob.cloud;
-
-import org.apache.jackrabbit.oak.commons.PropertiesUtil;
-import org.apache.jackrabbit.oak.spi.blob.BlobStore;
-import org.apache.jackrabbit.oak.plugins.blob.BlobStoreBuilder;
-import org.apache.jackrabbit.oak.plugins.blob.BlobStoreConfiguration;
-
-import com.google.common.base.Optional;
-
-/**
- * A factory helper for creating CloudBlobStore instance.
- */
-public class CloudBlobStoreBuilder implements BlobStoreBuilder {
-
-    private static final CloudBlobStoreBuilder INSTANCE = new CloudBlobStoreBuilder();
-
-    public static CloudBlobStoreBuilder newInstance() {
-        return INSTANCE;
-    }
-
-    /**
-     * Creates the {@link CloudBlobStore} instance.
-     * 
-     * @param configuration
-     *            the configuration
-     * @return the blob store wrapped as {@link Optional} to indicate that the
-     *         value might be null when a valid configuration object not
-     *         available
-     * @throws Exception
-     *             the exception
-     */
-    @Override
-    public Optional<BlobStore> build(
-            BlobStoreConfiguration configuration)
-            throws Exception {
-        BlobStore blobStore = null;
-
-        blobStore = new CloudBlobStore();
-        PropertiesUtil.populate(blobStore, configuration.getConfigMap(), false);
-        ((CloudBlobStore) blobStore).init();
-
-        return Optional.of(blobStore);
-    }
-}
\ No newline at end of file
Index: ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java	(date 1394682836000)
+++ ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java	(revision )
@@ -20,12 +20,13 @@
 
 import static org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.registerMBean;
 
+import java.io.IOException;
+import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
-import javax.annotation.CheckForNull;
 
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
@@ -38,19 +39,20 @@
 import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
 import org.apache.jackrabbit.oak.osgi.ObserverTracker;
 import org.apache.jackrabbit.oak.osgi.OsgiWhiteboard;
-import org.apache.jackrabbit.oak.plugins.blob.BlobStoreConfiguration;
-import org.apache.jackrabbit.oak.plugins.blob.BlobStoreHelper;
 import org.apache.jackrabbit.oak.plugins.document.cache.CachingDocumentStore;
 import org.apache.jackrabbit.oak.plugins.document.util.MongoConnection;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.apache.jackrabbit.oak.spi.whiteboard.Registration;
 import org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Strings;
 import com.mongodb.DB;
 import com.mongodb.MongoClient;
 import com.mongodb.MongoClientOptions;
@@ -99,48 +101,63 @@
     @Property(intValue = DEFAULT_OFF_HEAP_CACHE)
     private static final String PROP_OFF_HEAP_CACHE = "offHeapCache";
 
+    /**
+     * Boolean value indicating a blobStore is to be used
+     */
+    public static final String CUSTOM_BLOB_STORE = "customBlobStore";
+
     private static final long MB = 1024 * 1024;
 
-    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+    private final Logger log = LoggerFactory.getLogger(this.getClass());
 
     private ServiceRegistration reg;
     private final List<Registration> registrations = new ArrayList<Registration>();
     private DocumentMK mk;
     private ObserverTracker observerTracker;
-    private BundleContext bundleContext;
+    private ComponentContext context;
+    private ServiceTracker blobStoreTracker;
 
     @Activate
-    protected void activate(BundleContext context, Map<String, ?> config) throws Exception {
-        this.bundleContext = context;
+    protected void activate(ComponentContext context, Map<String, ?> config) throws Exception {
+        this.context = context;
 
-        String uri = PropertiesUtil.toString(prop(config, PROP_URI, FWK_PROP_URI), DEFAULT_URI);
-        String db = PropertiesUtil.toString(prop(config, PROP_DB, FWK_PROP_DB), DEFAULT_DB);
+        if(PropertiesUtil.toBoolean(prop(CUSTOM_BLOB_STORE), false)){
+            log.info("BlobStore use enabled. DocumentNodeStoreService would be initialized when BlobStore would be available");
+            blobStoreTracker = new ServiceTracker(context.getBundleContext(),
+                    BlobStore.class.getName(), new BlobStoreTracker());
+            blobStoreTracker.open();
+        }else{
+            initialize(context, null);
+        }
+    }
 
-        int offHeapCache = PropertiesUtil.toInteger(prop(config, PROP_OFF_HEAP_CACHE), DEFAULT_OFF_HEAP_CACHE);
-        int cacheSize = PropertiesUtil.toInteger(prop(config, PROP_CACHE), DEFAULT_CACHE);
-        boolean useMK = PropertiesUtil.toBoolean(config.get(PROP_USE_MK), false);
+    protected void initialize(ComponentContext context, BlobStore blobStore) throws UnknownHostException {
 
 
+        String uri = PropertiesUtil.toString(prop(PROP_URI, FWK_PROP_URI), DEFAULT_URI);
+        String db = PropertiesUtil.toString(prop(PROP_DB, FWK_PROP_DB), DEFAULT_DB);
+
+        int offHeapCache = PropertiesUtil.toInteger(prop(PROP_OFF_HEAP_CACHE), DEFAULT_OFF_HEAP_CACHE);
+        int cacheSize = PropertiesUtil.toInteger(prop(PROP_CACHE), DEFAULT_CACHE);
+        boolean useMK = PropertiesUtil.toBoolean(context.getProperties().get(PROP_USE_MK), false);
+
+
         MongoClientOptions.Builder builder = MongoConnection.getDefaultBuilder();
         MongoClientURI mongoURI = new MongoClientURI(uri, builder);
 
-        if (logger.isInfoEnabled()) {
+        if (log.isInfoEnabled()) {
             // Take care around not logging the uri directly as it
             // might contain passwords
             String type = useMK ? "MK" : "NodeStore";
-            logger.info("Starting Document{} with host={}, db={}, cache size (MB)={}, Off Heap Cache size (MB)={}",
+            log.info("Starting Document{} with host={}, db={}, cache size (MB)={}, Off Heap Cache size (MB)={}",
-                    new Object[] {type, mongoURI.getHosts(), db, cacheSize, offHeapCache});
+                    new Object[]{type, mongoURI.getHosts(), db, cacheSize, offHeapCache});
-            logger.info("Mongo Connection details {}", MongoConnection.toString(mongoURI.getOptions()));
+            log.info("Mongo Connection details {}", MongoConnection.toString(mongoURI.getOptions()));
         }
 
         MongoClient client = new MongoClient(mongoURI);
         DB mongoDB = client.getDB(db);
 
-        // Check if any valid external BlobStore is defined.
-        // If not then use the default which is MongoBlobStore
-        BlobStore blobStore = createBlobStore(config);
-
-        DocumentMK.Builder mkBuilder = 
+        DocumentMK.Builder mkBuilder =
                 new DocumentMK.Builder().
                 memoryCacheSize(cacheSize * MB).
                 offHeapCacheSize(offHeapCache * MB);
@@ -154,9 +171,9 @@
 
         mk = mkBuilder.open();
 
-        logger.info("Connected to database {}", mongoDB);
+        log.info("Connected to database {}", mongoDB);
 
-        registerJMXBeans(mk.getNodeStore(), context);
+        registerJMXBeans(mk.getNodeStore(), context.getBundleContext());
 
         NodeStore store;
         if (useMK) {
@@ -169,40 +186,23 @@
             observerTracker = new ObserverTracker(mns);
         }
 
-        observerTracker.start(context);
-        reg = context.registerService(NodeStore.class.getName(), store, new Properties());
+        observerTracker.start(context.getBundleContext());
+        reg = context.getBundleContext().registerService(NodeStore.class.getName(), store, new Properties());
     }
 
-    @CheckForNull
-    private BlobStore createBlobStore(Map<String, ?> config) throws Exception {
-        String blobStoreType = PropertiesUtil.toString(
-                prop(config, BlobStoreConfiguration.PROP_BLOB_STORE_PROVIDER),
-                BlobStoreConfiguration.DEFAULT_BLOB_STORE_PROVIDER);
-
-        BlobStore blobStore = null;
-        if (!Strings.isNullOrEmpty(blobStoreType)) {
-            blobStore = BlobStoreHelper.create(
-                    BlobStoreConfiguration.newInstance().
-                            loadFromContextOrMap(config, bundleContext))
-                    .orNull();
-            logger.info("BlobStore Configured {}", blobStore);
+    private Object prop(String propName) {
+        return prop(propName, PREFIX + propName);
-        }
+    }
-        return blobStore;
-    }
 
-    private Object prop(Map<String, ?> config, String propName) {
-        return prop(config, propName, PREFIX + propName);
-    }
-
-    private Object prop(Map<String, ?> config, String propName, String fwkPropName) {
+    private Object prop(String propName, String fwkPropName) {
         //Prefer framework property first
-        Object value = bundleContext.getProperty(fwkPropName);
+        Object value = context.getBundleContext().getProperty(fwkPropName);
         if (value != null) {
             return value;
         }
 
         //Fallback to one from config
-        return config.get(propName);
+        return context.getProperties().get(propName);
     }
 
     @Deactivate
@@ -211,6 +211,13 @@
             observerTracker.stop();
         }
 
+        blobStoreTracker.close();
+        blobStoreTracker = null;
+
+        unregisterNodeStore();
+    }
+
+    private void unregisterNodeStore() {
         for (Registration r : registrations) {
             r.unregister();
         }
@@ -266,5 +273,30 @@
         }
 
         //TODO Register JMX bean for Off Heap Cache stats
+    }
+
+    private class BlobStoreTracker implements ServiceTrackerCustomizer {
+
+        @Override
+        public Object addingService(ServiceReference reference) {
+            BlobStore blobStore = (BlobStore) context.getBundleContext().getService(reference);
+            try {
+                initialize(context, blobStore);
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+            return blobStore;
+        }
+
+        @Override
+        public void modifiedService(ServiceReference reference, Object service) {
+
+        }
+
+        @Override
+        public void removedService(ServiceReference reference, Object service) {
+            log.info("BlobStore services unregistered. Unregistered the DocumentNodeStore");
+            unregisterNodeStore();
+        }
     }
 }
Index: ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreBlobStoreBuilder.java
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreBlobStoreBuilder.java	(date 1394682836000)
+++ ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreBlobStoreBuilder.java	(date 1394682836000)
@@ -1,136 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.blob.datastore;
-
-import javax.jcr.RepositoryException;
-
-import org.apache.jackrabbit.core.data.Backend;
-import org.apache.jackrabbit.core.data.CachingDataStore;
-import org.apache.jackrabbit.core.data.DataStore;
-import org.apache.jackrabbit.core.data.FileDataStore;
-import org.apache.jackrabbit.core.data.MultiDataStore;
-import org.apache.jackrabbit.core.data.db.DbDataStore;
-import org.apache.jackrabbit.core.util.db.ConnectionFactory;
-import org.apache.jackrabbit.oak.commons.PropertiesUtil;
-import org.apache.jackrabbit.oak.spi.blob.BlobStore;
-import org.apache.jackrabbit.oak.plugins.blob.BlobStoreBuilder;
-import org.apache.jackrabbit.oak.plugins.blob.BlobStoreConfiguration;
-
-import com.google.common.base.Optional;
-
-/**
- * Helper class to create {@link DataStoreBlobStore} instance and inject the
- * appropriate Jackrabbit {@link DataStore} instance based on the configuration.
- */
-public class DataStoreBlobStoreBuilder implements BlobStoreBuilder {
-
-    private static final DataStoreBlobStoreBuilder INSTANCE = new DataStoreBlobStoreBuilder();
-
-    public static DataStoreBlobStoreBuilder newInstance() {
-        return INSTANCE;
-    }
-
-    /**
-     * Creates the wrapper {@link BlobStore} instance for Jackrabbit
-     * {@link DataStore}.
-     * 
-     * @param configuration
-     *            the configuration
-     * @return the dS blob store wrapped as{@link Optional} indicating that the
-     *         value can be null when a valid configuration is not available
-     * @throws Exception
-     *             the exception
-     */
-    @Override
-    public Optional<BlobStore> build(BlobStoreConfiguration configuration) throws Exception {
-        BlobStore blobStore = null;
-
-        DataStore store = getDataStore(configuration);
-        if (store != null) {
-            blobStore = new DataStoreBlobStore();
-            PropertiesUtil.populate(blobStore, configuration.getConfigMap(), false);
-            ((DataStoreBlobStore) blobStore).init(store);
-        }
-        return Optional.fromNullable(blobStore);
-    }
-
-    /**
-     * Gets the data store based on the DataStoreProvider.
-     * 
-     * @param config
-     *            the data store config
-     * @return the data store
-     * @throws RepositoryException
-     *             the repository exception
-     */
-    private DataStore getDataStore(BlobStoreConfiguration config) throws Exception {
-        return getDataStore(
-                 config.getProperty(BlobStoreConfiguration.PROP_DATA_STORE), config);
-    }
-
-    private DataStore getDataStore(String dataStoreType, BlobStoreConfiguration config) throws Exception {
-        DataStore dataStore = (DataStore) Class.forName(dataStoreType).newInstance();
-        PropertiesUtil.populate(dataStore, config.getConfigMap(), false);
-
-        if (dataStore instanceof DbDataStore) {
-            ((DbDataStore) dataStore)
-                    .setConnectionFactory(new ConnectionFactory());
-        }
-
-        if (dataStore instanceof MultiDataStore) {
-            DataStore primary =
-                    getDataStore(
-                            (String) config.getProperty(BlobStoreConfiguration.PRIMARY_DATA_STORE), config);
-            DataStore archive =
-                    getDataStore(
-                            (String) config.getProperty(BlobStoreConfiguration.ARCHIVE_DATA_STORE), config);
-            ((MultiDataStore) dataStore)
-                    .setPrimaryDataStore(primary);
-            ((MultiDataStore) dataStore)
-                    .setArchiveDataStore(archive);
-            dataStore.init(null);
-        } else if (!(dataStore instanceof FileDataStore)
-                && !(dataStore instanceof CachingDataStore)) {
-            dataStore.init(null);
-            return wrapInCachingDataStore(dataStore, config);
-        }
-        else {
-            dataStore.init(null);
-        }
-
-        return dataStore;
-    }
-
-    private DataStore wrapInCachingDataStore(final DataStore dataStore, BlobStoreConfiguration config) throws Exception {
-        CachingDataStore cachingStore = new CachingDataStore() {
-            @Override
-            protected Backend createBackend() {
-                return new DataStoreWrapperBackend(dataStore);
-            }
-
-            @Override
-            protected String getMarkerFile() {
-                return "db.init.done";
-            }
-        };
-
-        PropertiesUtil.populate(cachingStore, config.getConfigMap(), false);
-        cachingStore.init(null);
-
-        return cachingStore;
-    }
-}
Index: ../../../git/apache/jackrabbit-oak/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/PropertiesUtilTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/PropertiesUtilTest.java	(date 1394682836000)
+++ ../../../git/apache/jackrabbit-oak/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/PropertiesUtilTest.java	(revision )
@@ -127,7 +127,7 @@
 
     @Test
     public void testPopulate() {
-        Map<String, String> props = new HashMap<String, String>();
+        Map<String, Object> props = new HashMap<String, Object>();
         props.put("string", "foo");
         props.put("bool", "true");
         props.put("integer", "7");
@@ -144,7 +144,7 @@
 
     @Test(expected = IllegalArgumentException.class)
     public void testPopulateAndValidate() {
-        Map<String, String> props = new HashMap<String, String>();
+        Map<String, Object> props = new HashMap<String, Object>();
         props.put("something", "foo");
 
         TestBeanA bean = new TestBeanA();
Index: ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreBuilder.java
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreBuilder.java	(date 1394682836000)
+++ ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreBuilder.java	(date 1394682836000)
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jackrabbit.oak.plugins.blob;
-
-import org.apache.jackrabbit.oak.spi.blob.BlobStore;
-
-import com.google.common.base.Optional;
-
-/**
- * Interface for building blob stores.
- */
-public interface BlobStoreBuilder {
-
-    /**
-     * Builds the appropriate BlobStore.
-     * 
-     * @param config
-     *            the config
-     * @return the blob store wrapped as {@link Optional} to indicate that the
-     *         value might be null
-     * @throws Exception
-     *             the exception
-     */
-    public Optional<BlobStore> build(BlobStoreConfiguration config) throws Exception;
-}
Index: ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/AbstractDataStoreService.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/AbstractDataStoreService.java	(revision )
+++ ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/AbstractDataStoreService.java	(revision )
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.jackrabbit.oak.plugins.blob.datastore;
+
+import java.util.Map;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.jackrabbit.core.data.DataStore;
+import org.apache.jackrabbit.oak.commons.PropertiesUtil;
+import org.apache.jackrabbit.oak.spi.blob.BlobStore;
+import org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Component(componentAbstract = true)
+public abstract class AbstractDataStoreService {
+    private static final String PROP_HOME = "repository.home";
+
+    private ServiceRegistration reg;
+
+    private Logger log = LoggerFactory.getLogger(getClass());
+
+    @Activate
+    protected void activate(ComponentContext context, Map<String, Object> config) throws RepositoryException {
+        DataStore dataStore = createDataStore(context, config);
+
+        String homeDir = lookup(context, PROP_HOME);
+        if (homeDir != null) {
+            log.debug("Initializing the DataStore with homeDir [{}]", homeDir);
+        }
+        PropertiesUtil.populate(dataStore, config, false);
+        dataStore.init(lookup(context, PROP_HOME));
+        reg = context.getBundleContext().registerService(new String[]{
+                DataStore.class.getName(),
+                BlobStore.class.getName(),
+                GarbageCollectableBlobStore.class.getName()
+        }, new DataStoreBlobStore(dataStore), null);
+    }
+
+    @Deactivate
+    protected void deactivate() {
+        if (reg != null) {
+            reg.unregister();
+        }
+    }
+
+    protected abstract DataStore createDataStore(ComponentContext context, Map<String, Object> config);
+
+    protected static String lookup(ComponentContext context, String property) {
+        //Prefer property from BundleContext first
+        if (context.getBundleContext().getProperty(property) != null) {
+            return context.getBundleContext().getProperty(property).toString();
+        }
+
+        if (context.getProperties().get(property) != null) {
+            return context.getProperties().get(property).toString();
+        }
+        return null;
+    }
+}
Index: ../../../git/apache/jackrabbit-oak/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MongoCloudBlobMicroKernelFixture.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MongoCloudBlobMicroKernelFixture.java	(date 1394682836000)
+++ ../../../git/apache/jackrabbit-oak/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MongoCloudBlobMicroKernelFixture.java	(revision )
@@ -16,23 +16,23 @@
  */
 package org.apache.jackrabbit.mk.test;
 
+import java.util.Map;
+
+import com.google.common.collect.Maps;
+import com.mongodb.DB;
 import org.apache.jackrabbit.mk.api.MicroKernel;
-import org.apache.jackrabbit.oak.spi.blob.BlobStore;
-import org.apache.jackrabbit.oak.plugins.blob.BlobStoreConfiguration;
+import org.apache.jackrabbit.oak.commons.PropertiesUtil;
 import org.apache.jackrabbit.oak.plugins.blob.cloud.CloudBlobStore;
-import org.apache.jackrabbit.oak.plugins.blob.cloud.CloudBlobStoreBuilder;
 import org.apache.jackrabbit.oak.plugins.document.Collection;
 import org.apache.jackrabbit.oak.plugins.document.DocumentMK;
 import org.apache.jackrabbit.oak.plugins.document.mongo.MongoBlobStore;
 import org.apache.jackrabbit.oak.plugins.document.util.MongoConnection;
+import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 
-import com.mongodb.DB;
-
 /**
  * The Class MongoCloudBlobMicroKernelFixture.
  */
 public class MongoCloudBlobMicroKernelFixture extends BaseMongoMicroKernelFixture {
-
     /** The blob store. */
     private BlobStore blobStore;
 
@@ -43,13 +43,16 @@
      */
     protected void openConnection() throws Exception {
         if (blobStore == null) {
-            blobStore =
-                    CloudBlobStoreBuilder
-                            .newInstance()
-                            .build(
-                                    BlobStoreConfiguration.newInstance().loadFromSystemProps()).get();
+            Map<String,?> config = getConfig();
+            if(!config.isEmpty()){
+                CloudBlobStore cbs  = new CloudBlobStore();
+                PropertiesUtil.populate(cbs, config, false);
+                cbs.init();
+                blobStore = cbs;
-        }
+            }
+            blobStore = null;
-    }
+        }
+    }
 
     @Override
     protected BlobStore getBlobStore(com.mongodb.DB db) {
@@ -74,5 +77,20 @@
         db.getCollection(MongoBlobStore.COLLECTION_BLOBS).drop();
         db.getCollection(Collection.NODES.toString()).drop();
         ((CloudBlobStore) blobStore).deleteBucket();
+    }
+
+    /**
+     * See org.apache.jackrabbit.oak.plugins.document.blob.ds.DataStoreUtils#getConfig()
+     */
+    private static Map<String,?> getConfig(){
+        Map<String,Object> result = Maps.newHashMap();
+        for(Map.Entry<String,?> e : Maps.fromProperties(System.getProperties()).entrySet()){
+            String key = e.getKey();
+            if(key.startsWith("bs.")){
+                key = key.substring(3); //length of bs.
+                result.put(key, e.getValue());
+            }
+        }
+        return result;
     }
 }
Index: ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/S3DataStoreService.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/S3DataStoreService.java	(revision )
+++ ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/S3DataStoreService.java	(revision )
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.jackrabbit.oak.plugins.blob.datastore;
+
+import java.util.Map;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.ConfigurationPolicy;
+import org.apache.jackrabbit.core.data.DataStore;
+import org.osgi.service.component.ComponentContext;
+
+@Component(policy = ConfigurationPolicy.REQUIRE, name=S3DataStoreService.NAME)
+public class S3DataStoreService extends AbstractDataStoreService{
+    public static final String NAME = "org.apache.jackrabbit.oak.plugins.blob.datastore.S3DataStore";
+
+    @Override
+    protected DataStore createDataStore(ComponentContext context, Map<String, Object> config) {
+        //TODO Looks like there is no release of jackrabbit-aws-ext so far
+        //So need to wait for that
+//        return new S3DataStore();
+        throw new IllegalStateException("S3 support not complete");
+    }
+}
Index: ../../../git/apache/jackrabbit-oak/oak-blob/pom.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-blob/pom.xml	(date 1394682836000)
+++ ../../../git/apache/jackrabbit-oak/oak-blob/pom.xml	(revision )
@@ -34,6 +34,10 @@
     <plugins>
       <plugin>
         <groupId>org.apache.felix</groupId>
+        <artifactId>maven-scr-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
         <configuration>
           <instructions>
Index: ../../../git/apache/jackrabbit-oak/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/ds/DataStoreUtils.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/ds/DataStoreUtils.java	(date 1394682836000)
+++ ../../../git/apache/jackrabbit-oak/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/ds/DataStoreUtils.java	(revision )
@@ -16,32 +16,69 @@
  */
 package org.apache.jackrabbit.oak.plugins.document.blob.ds;
 
+import java.io.File;
+import java.util.Map;
+
+import com.google.common.collect.Maps;
 import org.apache.jackrabbit.core.data.DataStore;
-import org.apache.jackrabbit.oak.plugins.blob.BlobStoreConfiguration;
-import org.apache.jackrabbit.oak.plugins.blob.BlobStoreHelper;
+import org.apache.jackrabbit.core.data.FileDataStore;
+import org.apache.jackrabbit.oak.commons.PropertiesUtil;
 import org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore;
 import org.apache.jackrabbit.oak.plugins.document.AbstractMongoConnectionTest;
+import org.junit.Test;
 
+import static org.apache.commons.io.FilenameUtils.concat;
+import static org.junit.Assert.assertEquals;
+
 /**
- * Helper for retrieving the {@link DataStoreBlobStore} instantiated with the
- * appropriate {@link DataStore}.
+ * Helper for retrieving the {@link DataStoreBlobStore} instantiated via system properties
+ *
+ * User must specify the class of DataStore to use via 'dataStore' system property
+ *
+ * Further to configure properties of DataStore instance one can specify extra system property
+ * where the key has a prefix 'ds.' or 'bs.'. So to set 'minRecordLength' of FileDataStore specify
+ * the system property as 'ds.minRecordLength'
  */
 public class DataStoreUtils extends AbstractMongoConnectionTest {
+    public static final String DS_CLASS_NAME = "dataStore";
     public static final String PATH = "./target/repository/";
 
-    /**
-     * Gets the blob store.
-     * 
-     * @return the blob store
-     * @throws Exception
-     *             the exception
-     */
+    private static final String DS_PROP_PREFIX = "ds.";
+    private static final String BS_PROP_PREFIX = "bs.";
+
     public static DataStoreBlobStore getBlobStore() throws Exception {
-        BlobStoreConfiguration config =
-                BlobStoreConfiguration.newInstance().loadFromSystemProps();
-        config.addProperty(
-                BlobStoreConfiguration.PROP_BLOB_STORE_PROVIDER, DataStoreBlobStore.class.getName());
-        config.addProperty("path", PATH + "datastore");
-        return (DataStoreBlobStore) BlobStoreHelper.create(config).orNull();
+        String className = System.getProperty(DS_CLASS_NAME);
+        if(className != null){
+            DataStore ds = Class.forName(className).asSubclass(DataStore.class).newInstance();
+            ds.init(getHomeDir());
+            PropertiesUtil.populate(ds, getConfig() , false);
+            return new DataStoreBlobStore(ds);
+        }
+        return null;
+    }
+
+    private static Map<String,?> getConfig(){
+        Map<String,Object> result = Maps.newHashMap();
+        for(Map.Entry<String,?> e : Maps.fromProperties(System.getProperties()).entrySet()){
+            String key = e.getKey();
+            if(key.startsWith(DS_PROP_PREFIX) || key.startsWith(BS_PROP_PREFIX)){
+                key = key.substring(3); //length of bs.
+                result.put(key, e.getValue());
+            }
+        }
+        return result;
+    }
+
+    private static String getHomeDir() {
+        return concat( new File(".").getAbsolutePath(), "target/blobstore/"+System.currentTimeMillis());
+    }
+
+    @Test
+    public void testPropertySetup() throws Exception {
+        System.setProperty(DS_CLASS_NAME, FileDataStore.class.getName());
+        System.setProperty("ds.minRecordLength", "1000");
+
+        DataStoreBlobStore dbs = getBlobStore();
+        assertEquals(1000, dbs.getDataStore().getMinRecordLength());
     }
 }
Index: ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/FileDataStoreService.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/FileDataStoreService.java	(revision )
+++ ../../../git/apache/jackrabbit-oak/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/FileDataStoreService.java	(revision )
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.jackrabbit.oak.plugins.blob.datastore;
+
+import java.util.Map;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.ConfigurationPolicy;
+import org.apache.jackrabbit.core.data.DataStore;
+import org.apache.jackrabbit.core.data.FileDataStore;
+import org.osgi.service.component.ComponentContext;
+
+@Component(policy = ConfigurationPolicy.REQUIRE, name=FileDataStoreService.NAME)
+public class FileDataStoreService extends AbstractDataStoreService{
+    public static final String NAME = "org.apache.jackrabbit.oak.plugins.blob.datastore.FileDataStore";
+
+    @Override
+    protected DataStore createDataStore(ComponentContext context, Map<String, Object> config) {
+        return new FileDataStore();
+    }
+}
Index: ../../../git/apache/jackrabbit-oak/oak-commons/pom.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-commons/pom.xml	(date 1394682836000)
+++ ../../../git/apache/jackrabbit-oak/oak-commons/pom.xml	(revision )
@@ -66,11 +66,15 @@
       <groupId>com.google.code.findbugs</groupId>
       <artifactId>jsr305</artifactId>
     </dependency>
-      <dependency>
-          <groupId>biz.aQute.bnd</groupId>
-          <artifactId>bndlib</artifactId>
-          <scope>provided</scope>
-      </dependency>
+    <dependency>
+        <groupId>biz.aQute.bnd</groupId>
+        <artifactId>bndlib</artifactId>
+        <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
+    </dependency>
 
       <!-- Test dependencies -->
     <dependency>
Index: ../../../git/apache/jackrabbit-oak/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MongoDataStoreBlobMicroKernelFixture.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MongoDataStoreBlobMicroKernelFixture.java	(date 1394682836000)
+++ ../../../git/apache/jackrabbit-oak/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MongoDataStoreBlobMicroKernelFixture.java	(revision )
@@ -16,19 +16,19 @@
  */
 package org.apache.jackrabbit.mk.test;
 
+import java.io.File;
+
+import com.mongodb.DB;
 import org.apache.jackrabbit.core.data.DataStoreException;
+import org.apache.jackrabbit.core.data.FileDataStore;
 import org.apache.jackrabbit.mk.api.MicroKernel;
-import org.apache.jackrabbit.oak.spi.blob.BlobStore;
-import org.apache.jackrabbit.oak.plugins.blob.BlobStoreConfiguration;
 import org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore;
-import org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStoreBuilder;
 import org.apache.jackrabbit.oak.plugins.document.Collection;
 import org.apache.jackrabbit.oak.plugins.document.DocumentMK;
 import org.apache.jackrabbit.oak.plugins.document.mongo.MongoBlobStore;
 import org.apache.jackrabbit.oak.plugins.document.util.MongoConnection;
+import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 
-import com.mongodb.DB;
-
 /**
  * The Class MongoCloudBlobMicroKernelFixture.
  */
@@ -44,11 +44,9 @@
      */
     protected void openConnection() throws Exception {
         if (blobStore == null) {
-            blobStore =
-                    DataStoreBlobStoreBuilder
-                            .newInstance()
-                            .build(
-                                    BlobStoreConfiguration.newInstance().loadFromSystemProps()).get();
+            FileDataStore fds = new FileDataStore();
+            fds.init(new File("target", "BlobStoreTest").getAbsolutePath());
+            blobStore = new DataStoreBlobStore(fds);
         }
     }
 
Index: ../../../git/apache/jackrabbit-oak/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PropertiesUtil.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../../../git/apache/jackrabbit-oak/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PropertiesUtil.java	(date 1394682836000)
+++ ../../../git/apache/jackrabbit-oak/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PropertiesUtil.java	(revision )
@@ -28,9 +28,12 @@
 import java.util.Locale;
 import java.util.Map;
 
+import com.google.common.base.Objects;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static com.google.common.base.Objects.ToStringHelper;
+
 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 // !! THIS UTILITY CLASS IS A COPY FROM APACHE SLING !!
 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -230,7 +233,9 @@
     }
 
     /**
-     * Populates the bean properties from properties instance
+     * Populates the bean properties from config instance. It supports coercing
+     *  values for simple types like Number, Integer, Long, Boolean etc. Complex
+     *  objects are not supported
      *
      * @param instance bean to populate
      * @param config propertires to set in the passed bean
@@ -238,12 +243,13 @@
      *                 the configured bean class
      */
     @SuppressWarnings("unchecked")
-    public static void populate(Object instance, Map<String,String> config, boolean validate){
+    public static void populate(Object instance, Map<String,?> config, boolean validate){
         Class<?> objectClass = instance.getClass();
 
         // Set all configured bean properties
         Map<String, Method> setters = getSetters(objectClass);
-        for(Map.Entry<String,String> e : config.entrySet()) {
+        ToStringHelper toStringHelper = Objects.toStringHelper(instance);
+        for(Map.Entry<String,?> e : config.entrySet()) {
             String name = e.getKey();
             Method setter = setters.get(name);
             if (setter != null) {
@@ -251,14 +257,17 @@
                     log.warn("Parameter {} of {} has been deprecated",
                             name, objectClass.getName());
                 }
-                String value = e.getValue();
+                Object value = e.getValue();
                 setProperty(instance, name, setter, value);
+                toStringHelper.add(name,value);
             } else if (validate) {
                 throw new IllegalArgumentException(
                         "Configured class " + objectClass.getName()
                                 + " does not contain a property named " + name);
             }
         }
+
+        log.debug("Configured object with properties {}", toStringHelper);
     }
 
     private static Map<String, Method> getSetters(Class<?> klass) {
@@ -279,7 +288,7 @@
     }
 
     private static void setProperty(
-            Object instance, String name, Method setter, String value) {
+            Object instance, String name, Method setter, Object value) {
         String className = instance.getClass().getName();
         Class<?> type = setter.getParameterTypes()[0];
         try {
@@ -288,16 +297,16 @@
                 setter.invoke(instance, value);
             } else if (type.isAssignableFrom(Boolean.TYPE)
                     || type.isAssignableFrom(Boolean.class)) {
-                setter.invoke(instance, Boolean.valueOf(value));
+                setter.invoke(instance, toBoolean(value, false));
             } else if (type.isAssignableFrom(Integer.TYPE)
                     || type.isAssignableFrom(Integer.class)) {
-                setter.invoke(instance, Integer.valueOf(value));
+                setter.invoke(instance, toInteger(value,0));
             } else if (type.isAssignableFrom(Long.TYPE)
                     || type.isAssignableFrom(Long.class)) {
-                setter.invoke(instance, Long.valueOf(value));
+                setter.invoke(instance, toLong(value, 0));
             } else if (type.isAssignableFrom(Double.TYPE)
                     || type.isAssignableFrom(Double.class)) {
-                setter.invoke(instance, Double.valueOf(value));
+                setter.invoke(instance, toDouble(value,0));
             } else {
                 throw new RuntimeException(
                         "The type (" + type.getName()
