incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1514720 - in /sling/whiteboard/bdelacretaz: bdelacretaz-oak-server/ bdelacretaz-oak-server/src/main/java/org/apache/sling/oak/server/ it-repository/ oak-launchpad/
Date Fri, 16 Aug 2013 14:13:28 GMT
Author: bdelacretaz
Date: Fri Aug 16 14:13:27 2013
New Revision: 1514720

URL: http://svn.apache.org/r1514720
Log:
SLING-2788 use NodeStore for persistence

Added:
    sling/whiteboard/bdelacretaz/bdelacretaz-oak-server/src/main/java/org/apache/sling/oak/server/Activator.java
  (with props)
Modified:
    sling/whiteboard/bdelacretaz/bdelacretaz-oak-server/pom.xml
    sling/whiteboard/bdelacretaz/bdelacretaz-oak-server/src/main/java/org/apache/sling/oak/server/SlingRepositoryImpl.java
    sling/whiteboard/bdelacretaz/it-repository/   (props changed)
    sling/whiteboard/bdelacretaz/oak-launchpad/   (props changed)

Modified: sling/whiteboard/bdelacretaz/bdelacretaz-oak-server/pom.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/bdelacretaz-oak-server/pom.xml?rev=1514720&r1=1514719&r2=1514720&view=diff
==============================================================================
--- sling/whiteboard/bdelacretaz/bdelacretaz-oak-server/pom.xml (original)
+++ sling/whiteboard/bdelacretaz/bdelacretaz-oak-server/pom.xml Fri Aug 16 14:13:27 2013
@@ -59,6 +59,9 @@
                           org.apache.jackrabbit.oak.security.user;resolution:=optional,
                           *
                         </Import-Package>
+                        <Bundle-Activator>
+                            org.apache.sling.oak.server.Activator
+                        </Bundle-Activator>
                         <Private-Package>
                             org.apache.sling.oak.server.*
                         </Private-Package>

Added: sling/whiteboard/bdelacretaz/bdelacretaz-oak-server/src/main/java/org/apache/sling/oak/server/Activator.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/bdelacretaz-oak-server/src/main/java/org/apache/sling/oak/server/Activator.java?rev=1514720&view=auto
==============================================================================
--- sling/whiteboard/bdelacretaz/bdelacretaz-oak-server/src/main/java/org/apache/sling/oak/server/Activator.java
(added)
+++ sling/whiteboard/bdelacretaz/bdelacretaz-oak-server/src/main/java/org/apache/sling/oak/server/Activator.java
Fri Aug 16 14:13:27 2013
@@ -0,0 +1,77 @@
+/*
+ * 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 SF 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.sling.oak.server;
+
+import java.util.Hashtable;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Activator implements BundleActivator {
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+    
+    @Override
+    public void start(BundleContext context) throws Exception {
+        ensureNodeStoreConfig(context);
+    }
+
+    @Override
+    public void stop(BundleContext context) throws Exception {
+    }
+    
+    /** Create a config for the Oak SegmentNodeStore unless we already have one */
+    private void ensureNodeStoreConfig(BundleContext context) throws Exception {
+        final ServiceReference ref = context.getServiceReference(ConfigurationAdmin.class.getName());
+        if(ref == null) {
+            log.error("verifyConfiguration: Failed to get ConfigurationAdmin ServiceReference");
+        }
+        final ConfigurationAdmin ca = (ConfigurationAdmin)context.getService(ref);
+        if (ca == null) {
+            log.error("verifyConfiguration: Failed to get ConfigurationAdmin");
+            return;
+        }
+
+        final String nodeStoreServicePid = "org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStoreService";
+        
+        // Nothing to do if we already have a config 
+        final Configuration[] cfgs = ca.listConfigurations("("
+                + ConfigurationAdmin.SERVICE_FACTORYPID + "="
+                + nodeStoreServicePid+ ")");
+        if (cfgs != null && cfgs.length > 0) {
+            log.info("verifyConfiguration: {} Configurations available for {}, nothing to
do",
+                    cfgs.length, nodeStoreServicePid);
+            return;
+        }
+        
+        // Else create a default NodeStore config
+        final Hashtable<String, String> props = new Hashtable<String, String>();
+        props.put("name", "Default NodeStore config from the oak-server bundle");
+        props.put("directory", "oak-server-default-NodeStore");
+        Configuration config = ca.getConfiguration(nodeStoreServicePid);
+        config.setBundleLocation(null);
+        config.update(props);
+        log.info("Created default NodeStore config {}, properties={}", config.getPid(), props);
+    }
+    
+}
\ No newline at end of file

Propchange: sling/whiteboard/bdelacretaz/bdelacretaz-oak-server/src/main/java/org/apache/sling/oak/server/Activator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/bdelacretaz/bdelacretaz-oak-server/src/main/java/org/apache/sling/oak/server/Activator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: sling/whiteboard/bdelacretaz/bdelacretaz-oak-server/src/main/java/org/apache/sling/oak/server/SlingRepositoryImpl.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/bdelacretaz-oak-server/src/main/java/org/apache/sling/oak/server/SlingRepositoryImpl.java?rev=1514720&r1=1514719&r2=1514720&view=diff
==============================================================================
--- sling/whiteboard/bdelacretaz/bdelacretaz-oak-server/src/main/java/org/apache/sling/oak/server/SlingRepositoryImpl.java
(original)
+++ sling/whiteboard/bdelacretaz/bdelacretaz-oak-server/src/main/java/org/apache/sling/oak/server/SlingRepositoryImpl.java
Fri Aug 16 14:13:27 2013
@@ -27,10 +27,13 @@ import javax.jcr.SimpleCredentials;
 
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.Service;
+import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.jcr.Jcr;
 import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
 import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.jcr.base.AbstractNamespaceMappingRepository;
 import org.osgi.service.component.ComponentContext;
@@ -46,12 +49,15 @@ public class SlingRepositoryImpl extends
 
     private Repository oakRepository;
     
+    @Reference
+    private NodeStore nodeStore;
+    
     @Activate
     protected void activate(ComponentContext ctx) {
         final SecurityProvider sp = new OpenSecurityProvider();
         // TODO barebones setup for now...might not provide much functionality.
         // TODO for a simple config (tar persistence) we could use the SegmentNodeStoreService
-        oakRepository = new Jcr().with(sp).createRepository();
+        oakRepository = new Jcr(new Oak(nodeStore)).with(sp).createRepository();
     }
     
     @Override

Propchange: sling/whiteboard/bdelacretaz/it-repository/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Aug 16 14:13:27 2013
@@ -12,4 +12,4 @@ derby.log
 .classpath
 .externalToolBuilders
 maven-eclipse.xml
-
+oak-server-default-NodeStore

Propchange: sling/whiteboard/bdelacretaz/oak-launchpad/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Aug 16 14:13:27 2013
@@ -12,5 +12,4 @@ derby.log
 .classpath
 .externalToolBuilders
 maven-eclipse.xml
-
-
+oak-server-default-NodeStore



Mime
View raw message