Index: oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/DocumentNodeStoreConfigTest.groovy =================================================================== --- oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/DocumentNodeStoreConfigTest.groovy (revision 1814597) +++ oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/DocumentNodeStoreConfigTest.groovy (working copy) @@ -63,6 +63,7 @@ registry.registerService(DataSource.class.name, ds, ['datasource.name': 'oak'] as Hashtable) //2. Create config for DocumentNodeStore with RDB enabled + createPresetConfiguration() createConfig([ 'org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService': [ documentStoreType: 'RDB' @@ -94,6 +95,7 @@ registry.registerService(DataSource.class.name, ds2, ['datasource.name': 'oak'] as Hashtable) //3. Create config for DocumentNodeStore with RDB enabled + createPresetConfiguration() createConfig([ 'org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService': [ documentStoreType: 'RDB' @@ -119,6 +121,7 @@ ServiceRegistration srds = registry.registerService(DataSource.class.name, ds, ['datasource.name': 'oak'] as Hashtable) //2. Create config for DocumentNodeStore with RDB enabled + createPresetConfiguration() createConfig([ 'org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService': [ documentStoreType: 'RDB' @@ -151,6 +154,7 @@ registry = repositoryFactory.initializeServiceRegistry(config) //1. Create config for DocumentNodeStore with RDB enabled + createPresetConfiguration() createConfig([ 'org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService': [ documentStoreType: 'RDB' @@ -179,6 +183,7 @@ registry.registerService(DataSource.class.name, ds1, ['datasource.name': 'oak'] as Hashtable) //2. Create config for DocumentNodeStore with RDB enabled + createPresetConfiguration() createConfig([ 'org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService': [ documentStoreType : 'RDB', @@ -221,6 +226,7 @@ //2. Create config for DocumentNodeStore with RDB enabled // (supply blobDataSource which should be ignored because customBlob takes precedence) + createPresetConfiguration() createConfig([ 'org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService': [ documentStoreType: 'RDB', @@ -259,6 +265,7 @@ mongoCheck() registry = repositoryFactory.initializeServiceRegistry(config) + createPresetConfiguration() createConfig([ 'org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService': [ mongouri : MongoUtils.URL, @@ -283,6 +290,7 @@ mongoCheck() registry = repositoryFactory.initializeServiceRegistry(config) + createPresetConfiguration() createConfig([ 'org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService': [ mongouri: MongoUtils.URL, @@ -314,6 +322,7 @@ registry.registerService(DataSource.class.name, ds, ['datasource.name': 'oak'] as Hashtable) //2. Create config for DocumentNodeStore with RDB enabled + createPresetConfiguration() createConfig([ 'org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService': [ documentStoreType: 'RDB' @@ -333,6 +342,7 @@ registry.registerService(DataSource.class.name, ds, ['datasource.name': 'oak'] as Hashtable) //2. Create config for DocumentNodeStore with RDB enabled + createPresetConfiguration() createConfig([ 'org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService': [ documentStoreType: 'RDB', @@ -389,6 +399,10 @@ } } + private createPresetConfiguration() { + createConfig(['org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreServicePreset': [:]]) + } + private mongoCheck() { //Somehow in Groovy assumeNotNull cause issue as Groovy probably //does away with null array causing a NPE Index: oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/SecondaryStoreConfigIT.groovy =================================================================== --- oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/SecondaryStoreConfigIT.groovy (revision 1814597) +++ oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/SecondaryStoreConfigIT.groovy (working copy) @@ -42,6 +42,7 @@ MongoUtils.dropDatabase(MongoUtils.DB) config[REPOSITORY_CONFIG_FILE] = createConfigValue("oak-base-config.json") config[REPOSITORY_CONFIG] = [ + 'org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreServicePreset': [:], 'org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService': [ mongouri : MongoUtils.URL, db : MongoUtils.DB Index: oak-store-document/pom.xml =================================================================== --- oak-store-document/pom.xml (revision 1814597) +++ oak-store-document/pom.xml (working copy) @@ -295,6 +295,7 @@ org.apache.sling org.apache.sling.testing.osgi-mock + 2.3.5-SNAPSHOT test Index: oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Configuration.java =================================================================== --- oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Configuration.java (revision 1814597) +++ oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Configuration.java (working copy) @@ -23,6 +23,7 @@ import org.osgi.service.metatype.annotations.ObjectClassDefinition; import org.osgi.service.metatype.annotations.Option; +import static org.apache.jackrabbit.oak.plugins.document.Configuration.PID; import static org.apache.jackrabbit.oak.plugins.document.DocumentMK.Builder.DEFAULT_CACHE_SEGMENT_COUNT; import static org.apache.jackrabbit.oak.plugins.document.DocumentMK.Builder.DEFAULT_CACHE_STACK_MOVE_DISTANCE; import static org.apache.jackrabbit.oak.plugins.document.DocumentMK.Builder.DEFAULT_CHILDREN_CACHE_PERCENTAGE; @@ -31,6 +32,7 @@ import static org.apache.jackrabbit.oak.plugins.document.DocumentMK.Builder.DEFAULT_PREV_DOC_CACHE_PERCENTAGE; @ObjectClassDefinition( + pid = {PID}, name = "Apache Jackrabbit Oak Document NodeStore Service", description = "NodeStore implementation based on Document model. For configuration option refer " + "to http://jackrabbit.apache.org/oak/docs/osgi_config.html#DocumentNodeStore. Note that for system " + @@ -38,6 +40,11 @@ "should be done via file system based config file and this view should ONLY be used to determine which " + "options are supported") @interface Configuration { + + String PID = "org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService"; + + String PRESET_PID = PID + "Preset"; + @AttributeDefinition( name = "Mongo URI", description = "Mongo connection URI used to connect to Mongo. Refer to " + Index: oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java =================================================================== --- oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java (revision 1814597) +++ oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java (working copy) @@ -120,7 +120,6 @@ import org.osgi.service.component.annotations.Reference; import org.osgi.service.component.annotations.ReferenceCardinality; import org.osgi.service.component.annotations.ReferencePolicy; -import org.osgi.service.metatype.annotations.Designate; import org.quartz.CronExpression; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -130,8 +129,7 @@ */ @Component( configurationPolicy = ConfigurationPolicy.REQUIRE, - service = {}) -@Designate(ocd = Configuration.class) + configurationPid = {Configuration.PRESET_PID, Configuration.PID}) public class DocumentNodeStoreService { private static final long MB = 1024 * 1024; Index: oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceTest.java =================================================================== --- oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceTest.java (revision 1814597) +++ oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreServiceTest.java (working copy) @@ -34,6 +34,7 @@ import org.apache.sling.testing.mock.osgi.junit.OsgiContext; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -190,6 +191,42 @@ assertFalse(dns.getNodeCachePredicate().apply("/x")); } + @Ignore + @Test + public void preset() throws Exception { + MockOsgi.setConfigForPid(context.bundleContext(), + Configuration.PRESET_PID, + DocumentNodeStoreService.PROP_SO_KEEP_ALIVE, true); + + Map config = newConfig(repoHome); + MockOsgi.activate(service, context.bundleContext(), config); + + DocumentNodeStore store = context.getService(DocumentNodeStore.class); + MongoDocumentStore mds = getMongoDocumentStore(store); + DB db = MongoDocumentStoreTestHelper.getDB(mds); + assertTrue(db.getMongo().getMongoOptions().isSocketKeepAlive()); + } + + @Ignore + @Test + public void presetOverride() throws Exception { + MockOsgi.setConfigForPid(context.bundleContext(), + Configuration.PRESET_PID, + DocumentNodeStoreService.PROP_SO_KEEP_ALIVE, true); + + MockOsgi.setConfigForPid(context.bundleContext(), + Configuration.PID, + DocumentNodeStoreService.PROP_SO_KEEP_ALIVE, false); + + Map config = newConfig(repoHome); + MockOsgi.activate(service, context.bundleContext(), config); + + DocumentNodeStore store = context.getService(DocumentNodeStore.class); + MongoDocumentStore mds = getMongoDocumentStore(store); + DB db = MongoDocumentStoreTestHelper.getDB(mds); + assertFalse(db.getMongo().getMongoOptions().isSocketKeepAlive()); + } + private static MongoDocumentStore getMongoDocumentStore(DocumentNodeStore s) { try { Field f = s.getClass().getDeclaredField("nonLeaseCheckingStore");