jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1330372 - in /jackrabbit/oak/trunk: ./ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/ oak-sling/ oak-sling/src/ oak-sling/src/main/ oak-sling/src/main/java/ oak-sling/src/main/java/org/ oak-sling/src/main/java/org/apache/ oak-sl...
Date Wed, 25 Apr 2012 16:00:27 GMT
Author: jukka
Date: Wed Apr 25 16:00:27 2012
New Revision: 1330372

URL: http://svn.apache.org/viewvc?rev=1330372&view=rev
Log:
OAK-67: Initial OSGi Bundle Setup

Add a version of the oak-jcr bundle that adds support for the SlingRepository interface

Added:
    jackrabbit/oak/trunk/oak-sling/
    jackrabbit/oak/trunk/oak-sling/pom.xml
    jackrabbit/oak/trunk/oak-sling/src/
    jackrabbit/oak/trunk/oak-sling/src/main/
    jackrabbit/oak/trunk/oak-sling/src/main/java/
    jackrabbit/oak/trunk/oak-sling/src/main/java/org/
    jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/
    jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/
    jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/
    jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/
    jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/Activator.java
      - copied, changed from r1330359, jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/Activator.java
    jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/SlingRepositoryImpl.java
Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/Activator.java
    jackrabbit/oak/trunk/pom.xml

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/Activator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/Activator.java?rev=1330372&r1=1330371&r2=1330372&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/Activator.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/Activator.java
Wed Apr 25 16:00:27 2012
@@ -79,8 +79,7 @@ public class Activator implements Bundle
 
     @Override
     public void removedService(ServiceReference reference, Object service) {
-        ServiceRegistration registration = services.get(reference);
-        registration.unregister();
+        services.get(reference).unregister();
         context.ungetService(reference);
     }
 

Added: jackrabbit/oak/trunk/oak-sling/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-sling/pom.xml?rev=1330372&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-sling/pom.xml (added)
+++ jackrabbit/oak/trunk/oak-sling/pom.xml Wed Apr 25 16:00:27 2012
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+   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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd
">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.jackrabbit</groupId>
+    <artifactId>oak-parent</artifactId>
+    <version>0.2-SNAPSHOT</version>
+    <relativePath>../oak-parent/pom.xml</relativePath>
+  </parent>
+
+  <artifactId>oak-sling</artifactId>
+  <name>Oak support for Apache Sling</name>
+  <packaging>bundle</packaging>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <configuration>
+          <instructions>
+            <Export-Package>
+              !
+            </Export-Package>
+            <Embed-Dependency>
+              oak-jcr
+            </Embed-Dependency>
+            <Bundle-Activator>
+              org.apache.jackrabbit.oak.sling.Activator
+            </Bundle-Activator>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <!-- Optional OSGi dependencies, used only when running within OSGi -->
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.compendium</artifactId>
+      <scope>provided</scope>
+      <optional>true</optional>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>oak-jcr</artifactId>
+      <version>0.2-SNAPSHOT</version>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.sling</groupId>
+      <artifactId>org.apache.sling.jcr.api</artifactId>
+      <version>2.1.0</version>
+    </dependency>
+  </dependencies>
+
+</project>

Copied: jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/Activator.java
(from r1330359, jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/Activator.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/Activator.java?p2=jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/Activator.java&p1=jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/Activator.java&r1=1330359&r2=1330372&rev=1330372&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/Activator.java
(original)
+++ jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/Activator.java
Wed Apr 25 16:00:27 2012
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.oak.jcr.osgi;
+package org.apache.jackrabbit.oak.sling;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -23,7 +23,7 @@ import java.util.Properties;
 import javax.jcr.Repository;
 
 import org.apache.jackrabbit.oak.api.ContentRepository;
-import org.apache.jackrabbit.oak.jcr.RepositoryImpl;
+import org.apache.sling.jcr.api.SlingRepository;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -37,7 +37,10 @@ public class Activator implements Bundle
 
     private ServiceTracker tracker;
 
-    private final Map<ServiceReference, ServiceRegistration> services =
+    private final Map<ServiceReference, ServiceRegistration> jcrRepositories =
+            new HashMap<ServiceReference, ServiceRegistration>();
+
+    private final Map<ServiceReference, ServiceRegistration> slingRepositories =
             new HashMap<ServiceReference, ServiceRegistration>();
 
     //-----------------------------------------------------< BundleActivator >--
@@ -61,11 +64,12 @@ public class Activator implements Bundle
     public Object addingService(ServiceReference reference) {
         Object service = context.getService(reference);
         if (service instanceof ContentRepository) {
-            ContentRepository repository = (ContentRepository) service;
-            services.put(reference, context.registerService(
-                    Repository.class.getName(),
-                    new RepositoryImpl(repository),
-                    new Properties()));
+            SlingRepository repository =
+                    new SlingRepositoryImpl((ContentRepository) service);
+            jcrRepositories.put(reference, context.registerService(
+                    Repository.class.getName(), repository, new Properties()));
+            slingRepositories.put(reference, context.registerService(
+                    Repository.class.getName(), repository, new Properties()));
             return service;
         } else {
             context.ungetService(reference);
@@ -79,8 +83,8 @@ public class Activator implements Bundle
 
     @Override
     public void removedService(ServiceReference reference, Object service) {
-        ServiceRegistration registration = services.get(reference);
-        registration.unregister();
+        slingRepositories.get(reference).unregister();
+        jcrRepositories.get(reference).unregister();
         context.ungetService(reference);
     }
 

Added: jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/SlingRepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/SlingRepositoryImpl.java?rev=1330372&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/SlingRepositoryImpl.java
(added)
+++ jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/SlingRepositoryImpl.java
Wed Apr 25 16:00:27 2012
@@ -0,0 +1,44 @@
+/*
+ * 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.sling;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.oak.api.ContentRepository;
+import org.apache.jackrabbit.oak.jcr.RepositoryImpl;
+import org.apache.sling.jcr.api.SlingRepository;
+
+public class SlingRepositoryImpl
+        extends RepositoryImpl implements SlingRepository {
+
+    public SlingRepositoryImpl(ContentRepository repository) {
+        super(repository);
+    }
+
+    @Override
+    public String getDefaultWorkspace() {
+        return "default";
+    }
+
+    @Override
+    public Session loginAdministrative(String workspace)
+            throws RepositoryException {
+        return login(workspace);
+    }
+
+}

Modified: jackrabbit/oak/trunk/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/pom.xml?rev=1330372&r1=1330371&r2=1330372&view=diff
==============================================================================
--- jackrabbit/oak/trunk/pom.xml (original)
+++ jackrabbit/oak/trunk/pom.xml Wed Apr 25 16:00:27 2012
@@ -40,6 +40,7 @@
     <module>oak-mk</module>
     <module>oak-core</module>
     <module>oak-jcr</module>
+    <module>oak-sling</module>
     <module>oak-run</module>
     <module>oak-it</module>
     <module>oak-bench</module>



Mime
View raw message