jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1577447 - in /jackrabbit/oak/trunk: oak-blob/ oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/osgi/ oak-commons/ oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/ oak-commons/src/test/java/org/apache/jackrabbit/oak/com...
Date Fri, 14 Mar 2014 08:39:42 GMT
Author: chetanm
Date: Fri Mar 14 08:39:41 2014
New Revision: 1577447

URL: http://svn.apache.org/r1577447
Log:
OAK-1502 - Make DataStores available to NodeStores

-- Removed earlier way of configuring BlobStore/DataStore via system property/config with OSGi config
-- Introduced specific OSGi components for various types of DataStore and BlobStore such that they can be configured via OSGi

Added:
    jackrabbit/oak/trunk/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/osgi/
    jackrabbit/oak/trunk/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/osgi/FileBlobStoreService.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/AbstractDataStoreService.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DbDataStoreService.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/FileDataStoreService.java   (with props)
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/S3DataStoreService.java   (with props)
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreConfiguration.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreHelper.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/cloud/CloudBlobStoreBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DataStoreBlobStoreBuilder.java
Modified:
    jackrabbit/oak/trunk/oak-blob/pom.xml
    jackrabbit/oak/trunk/oak-commons/pom.xml
    jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PropertiesUtil.java
    jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/PropertiesUtilTest.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/cloud/CloudStoreUtils.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/ds/DataStoreUtils.java
    jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MongoCloudBlobMicroKernelFixture.java
    jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MongoDataStoreBlobMicroKernelFixture.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakFixture.java

Modified: jackrabbit/oak/trunk/oak-blob/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-blob/pom.xml?rev=1577447&r1=1577446&r2=1577447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-blob/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-blob/pom.xml Fri Mar 14 08:39:41 2014
@@ -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>

Added: jackrabbit/oak/trunk/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/osgi/FileBlobStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/osgi/FileBlobStoreService.java?rev=1577447&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/osgi/FileBlobStoreService.java (added)
+++ jackrabbit/oak/trunk/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/osgi/FileBlobStoreService.java Fri Mar 14 08:39:41 2014
@@ -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;
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-blob/src/main/java/org/apache/jackrabbit/oak/spi/blob/osgi/FileBlobStoreService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/oak/trunk/oak-commons/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-commons/pom.xml?rev=1577447&r1=1577446&r2=1577447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-commons/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-commons/pom.xml Fri Mar 14 08:39:41 2014
@@ -79,11 +79,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>

Modified: jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PropertiesUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PropertiesUtil.java?rev=1577447&r1=1577446&r2=1577447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PropertiesUtil.java (original)
+++ jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PropertiesUtil.java Fri Mar 14 08:39:41 2014
@@ -28,9 +28,12 @@ import java.util.List;
 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 @@ public class PropertiesUtil {
     }
 
     /**
-     * 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 @@ public class PropertiesUtil {
      *                 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 @@ public class PropertiesUtil {
                     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 @@ public class PropertiesUtil {
     }
 
     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 @@ public class PropertiesUtil {
                 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()

Modified: jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/PropertiesUtilTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/PropertiesUtilTest.java?rev=1577447&r1=1577446&r2=1577447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/PropertiesUtilTest.java (original)
+++ jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/PropertiesUtilTest.java Fri Mar 14 08:39:41 2014
@@ -127,7 +127,7 @@ public class PropertiesUtilTest {
 
     @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 @@ public class PropertiesUtilTest {
 
     @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();

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/AbstractDataStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/AbstractDataStoreService.java?rev=1577447&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/AbstractDataStoreService.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/AbstractDataStoreService.java Fri Mar 14 08:39:41 2014
@@ -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;
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/AbstractDataStoreService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DbDataStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DbDataStoreService.java?rev=1577447&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DbDataStoreService.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DbDataStoreService.java Fri Mar 14 08:39:41 2014
@@ -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;
+    }
+}
+

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/DbDataStoreService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/FileDataStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/FileDataStoreService.java?rev=1577447&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/FileDataStoreService.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/FileDataStoreService.java Fri Mar 14 08:39:41 2014
@@ -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();
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/FileDataStoreService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/S3DataStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/S3DataStoreService.java?rev=1577447&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/S3DataStoreService.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/S3DataStoreService.java Fri Mar 14 08:39:41 2014
@@ -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");
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/datastore/S3DataStoreService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java?rev=1577447&r1=1577446&r2=1577447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java Fri Mar 14 08:39:41 2014
@@ -20,12 +20,13 @@ package org.apache.jackrabbit.oak.plugin
 
 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.api.jmx
 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 @@ public class DocumentNodeStoreService {
     @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;
+
+        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);
+        }
+    }
+
+    protected void initialize(ComponentContext context, BlobStore blobStore) throws UnknownHostException {
 
-        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);
 
-        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);
+        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)={}",
-                    new Object[] {type, mongoURI.getHosts(), db, cacheSize, offHeapCache});
-            logger.info("Mongo Connection details {}", MongoConnection.toString(mongoURI.getOptions()));
+            log.info("Starting Document{} with host={}, db={}, cache size (MB)={}, Off Heap Cache size (MB)={}",
+                    new Object[]{type, mongoURI.getHosts(), db, cacheSize, offHeapCache});
+            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 @@ public class DocumentNodeStoreService {
 
         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 @@ public class DocumentNodeStoreService {
             observerTracker = new ObserverTracker(mns);
         }
 
-        observerTracker.start(context);
-        reg = context.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);
-        }
-        return blobStore;
+        observerTracker.start(context.getBundleContext());
+        reg = context.getBundleContext().registerService(NodeStore.class.getName(), store, new Properties());
     }
 
-    private Object prop(Map<String, ?> config, String propName) {
-        return prop(config, propName, PREFIX + propName);
+    private Object prop(String propName) {
+        return prop(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 @@ public class DocumentNodeStoreService {
             observerTracker.stop();
         }
 
+        blobStoreTracker.close();
+        blobStoreTracker = null;
+
+        unregisterNodeStore();
+    }
+
+    private void unregisterNodeStore() {
         for (Registration r : registrations) {
             r.unregister();
         }
@@ -267,4 +274,29 @@ public class DocumentNodeStoreService {
 
         //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();
+        }
+    }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/cloud/CloudStoreUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/cloud/CloudStoreUtils.java?rev=1577447&r1=1577446&r2=1577447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/cloud/CloudStoreUtils.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/cloud/CloudStoreUtils.java Fri Mar 14 08:39:41 2014
@@ -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 @@ public class CloudStoreUtils {
      *             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

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/ds/DataStoreUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/ds/DataStoreUtils.java?rev=1577447&r1=1577446&r2=1577447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/ds/DataStoreUtils.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/blob/ds/DataStoreUtils.java Fri Mar 14 08:39:41 2014
@@ -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());
     }
 }

Modified: jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MongoCloudBlobMicroKernelFixture.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MongoCloudBlobMicroKernelFixture.java?rev=1577447&r1=1577446&r2=1577447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MongoCloudBlobMicroKernelFixture.java (original)
+++ jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MongoCloudBlobMicroKernelFixture.java Fri Mar 14 08:39:41 2014
@@ -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 com.mongodb.DB;
+import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 
 /**
  * The Class MongoCloudBlobMicroKernelFixture.
  */
 public class MongoCloudBlobMicroKernelFixture extends BaseMongoMicroKernelFixture {
-
     /** The blob store. */
     private BlobStore blobStore;
 
@@ -43,11 +43,14 @@ public class MongoCloudBlobMicroKernelFi
      */
     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;
         }
     }
 
@@ -75,4 +78,19 @@ public class MongoCloudBlobMicroKernelFi
         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;
+    }
 }

Modified: jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MongoDataStoreBlobMicroKernelFixture.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MongoDataStoreBlobMicroKernelFixture.java?rev=1577447&r1=1577446&r2=1577447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MongoDataStoreBlobMicroKernelFixture.java (original)
+++ jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MongoDataStoreBlobMicroKernelFixture.java Fri Mar 14 08:39:41 2014
@@ -16,18 +16,18 @@
  */
 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 com.mongodb.DB;
+import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 
 /**
  * The Class MongoCloudBlobMicroKernelFixture.
@@ -44,11 +44,9 @@ public class MongoDataStoreBlobMicroKern
      */
     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);
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakFixture.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakFixture.java?rev=1577447&r1=1577446&r2=1577447&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakFixture.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/fixture/OakFixture.java Fri Mar 14 08:39:41 2014
@@ -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,10 +144,15 @@ public abstract class OakFixture {
             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);
                 }
@@ -153,6 +160,21 @@ public abstract class OakFixture {
                 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
             public Oak getOak(int clusterId) throws Exception {
                 MongoConnection mongo = new MongoConnection(host, port, dbName);



Mime
View raw message