jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1044042 - in /jackrabbit/sandbox/osgi: jackrabbit-bundle-it/ jackrabbit-bundle-it/src/test/java/org/apache/jackrabbit/test/osgi/ jackrabbit-bundle/ jackrabbit-bundle/src/main/java/ jackrabbit-bundle/src/main/java/org/ jackrabbit-bundle/src...
Date Thu, 09 Dec 2010 17:16:28 GMT
Author: jukka
Date: Thu Dec  9 17:16:27 2010
New Revision: 1044042

URL: http://svn.apache.org/viewvc?rev=1044042&view=rev
Log:
JCR-2608: Making Jackrabbit content repo usable from OSGi (Equinox)

Add a bundle activator and clean up dependencies. JcrUtils.getRepository() now works.

Added:
    jackrabbit/sandbox/osgi/jackrabbit-bundle/src/main/java/
    jackrabbit/sandbox/osgi/jackrabbit-bundle/src/main/java/org/
    jackrabbit/sandbox/osgi/jackrabbit-bundle/src/main/java/org/apache/
    jackrabbit/sandbox/osgi/jackrabbit-bundle/src/main/java/org/apache/jackrabbit/
    jackrabbit/sandbox/osgi/jackrabbit-bundle/src/main/java/org/apache/jackrabbit/bundle/
    jackrabbit/sandbox/osgi/jackrabbit-bundle/src/main/java/org/apache/jackrabbit/bundle/Activator.java
  (with props)
Modified:
    jackrabbit/sandbox/osgi/jackrabbit-bundle-it/pom.xml
    jackrabbit/sandbox/osgi/jackrabbit-bundle-it/src/test/java/org/apache/jackrabbit/test/osgi/BundleTest.java
    jackrabbit/sandbox/osgi/jackrabbit-bundle/pom.xml

Modified: jackrabbit/sandbox/osgi/jackrabbit-bundle-it/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/osgi/jackrabbit-bundle-it/pom.xml?rev=1044042&r1=1044041&r2=1044042&view=diff
==============================================================================
--- jackrabbit/sandbox/osgi/jackrabbit-bundle-it/pom.xml (original)
+++ jackrabbit/sandbox/osgi/jackrabbit-bundle-it/pom.xml Thu Dec  9 17:16:27 2010
@@ -45,12 +45,6 @@
     </dependency>
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
-      <artifactId>jackrabbit-jcr-commons</artifactId>
-      <version>2.3-SNAPSHOT</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-bundle</artifactId>
       <version>2.3-SNAPSHOT</version>
       <scope>provided</scope>
@@ -82,6 +76,12 @@
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-jcr-commons</artifactId>
+      <version>2.3-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>4.4</version>

Modified: jackrabbit/sandbox/osgi/jackrabbit-bundle-it/src/test/java/org/apache/jackrabbit/test/osgi/BundleTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/osgi/jackrabbit-bundle-it/src/test/java/org/apache/jackrabbit/test/osgi/BundleTest.java?rev=1044042&r1=1044041&r2=1044042&view=diff
==============================================================================
--- jackrabbit/sandbox/osgi/jackrabbit-bundle-it/src/test/java/org/apache/jackrabbit/test/osgi/BundleTest.java
(original)
+++ jackrabbit/sandbox/osgi/jackrabbit-bundle-it/src/test/java/org/apache/jackrabbit/test/osgi/BundleTest.java
Thu Dec  9 17:16:27 2010
@@ -16,9 +16,7 @@
  */
 package org.apache.jackrabbit.test.osgi;
 
-import java.util.Arrays;
-
-import javax.jcr.RepositoryFactory;
+import javax.jcr.Repository;
 
 import org.apache.jackrabbit.commons.JcrUtils;
 import org.junit.Test;
@@ -36,7 +34,7 @@ public class BundleTest {
         for (Bundle bundle : context.getBundles()) {
             System.out.println("Bundle: " + bundle.getSymbolicName() + " " + bundle.getState());
         }
-        for (ServiceReference reference : context.getServiceReferences(RepositoryFactory.class.getName(),
null)) {
+        for (ServiceReference reference : context.getServiceReferences(Repository.class.getName(),
null)) {
             System.out.println("Service: " + reference);
         }
         System.out.println("Repository: " + JcrUtils.getRepository());

Modified: jackrabbit/sandbox/osgi/jackrabbit-bundle/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/osgi/jackrabbit-bundle/pom.xml?rev=1044042&r1=1044041&r2=1044042&view=diff
==============================================================================
--- jackrabbit/sandbox/osgi/jackrabbit-bundle/pom.xml (original)
+++ jackrabbit/sandbox/osgi/jackrabbit-bundle/pom.xml Thu Dec  9 17:16:27 2010
@@ -42,15 +42,23 @@
         <extensions>true</extensions>
         <configuration>
           <instructions>
-            <Embed-Dependency>*</Embed-Dependency>
+            <Embed-Dependency>*;groupId=!org.osgi|javax.jcr</Embed-Dependency>
             <Embed-Transitive>true</Embed-Transitive>
-            <Service-Component>
-              OSGI-INF/jackrabbit-repository-factory.xml
-            </Service-Component>
+            <Export-Package>
+              org.apache.jackrabbit.api.*;version=${project.version},
+              org.apache.jackrabbit.commons.*;version=${project.version},
+              org.apache.jackrabbit.util.*;version=${project.version},
+              org.apache.jackrabbit.value.*;version=${project.version}
+            </Export-Package>
             <Import-Package>
               *,
               <!-- Optional dependencies from jackrabbit-core -->
               org.apache.jackrabbit.test;resolution:=optional,
+              org.apache.pdfbox;resolution:=optional,
+              org.apache.pdfbox.cos;resolution:=optional,
+              org.apache.pdfbox.pdmodel;resolution:=optional,
+              org.apache.pdfbox.pdmodel.encryption;resolution:=optional,
+              org.apache.pdfbox.util;resolution:=optional,
               <!-- Optional dependencies from jackrabbit-webdav -->
               javax.servlet;resolution:=optional,
               javax.servlet.http;resolution:=optional,
@@ -62,6 +70,9 @@
               org.apache.xalan.templates;resolution:=optional,
               org.apache.derby.impl.drda;resolution:=optional
             </Import-Package>
+            <Bundle-Activator>
+              org.apache.jackrabbit.bundle.Activator
+            </Bundle-Activator>
           </instructions>
         </configuration>
       </plugin>
@@ -70,6 +81,24 @@
 
   <dependencies>
     <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <version>4.0.0</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.compendium</artifactId>
+      <version>4.0.0</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>javax.jcr</groupId>
+      <artifactId>jcr</artifactId>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-core</artifactId>
       <version>2.3-SNAPSHOT</version>
@@ -84,6 +113,10 @@
           <artifactId>tika-parsers</artifactId>
         </exclusion>
         <exclusion>
+          <groupId>edu.ucar</groupId>
+          <artifactId>netcdf</artifactId>
+        </exclusion>
+        <exclusion>
           <groupId>org.slf4j</groupId>
           <artifactId>slf4j-api</artifactId>
         </exclusion>

Added: jackrabbit/sandbox/osgi/jackrabbit-bundle/src/main/java/org/apache/jackrabbit/bundle/Activator.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/osgi/jackrabbit-bundle/src/main/java/org/apache/jackrabbit/bundle/Activator.java?rev=1044042&view=auto
==============================================================================
--- jackrabbit/sandbox/osgi/jackrabbit-bundle/src/main/java/org/apache/jackrabbit/bundle/Activator.java
(added)
+++ jackrabbit/sandbox/osgi/jackrabbit-bundle/src/main/java/org/apache/jackrabbit/bundle/Activator.java
Thu Dec  9 17:16:27 2010
@@ -0,0 +1,55 @@
+/*
+ * 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.bundle;
+
+import java.io.File;
+import java.util.Hashtable;
+
+import javax.jcr.Repository;
+
+import org.apache.jackrabbit.core.RepositoryFactoryImpl;
+import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.config.RepositoryConfig;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class Activator implements BundleActivator {
+
+    private volatile RepositoryImpl repository;
+
+    private volatile ServiceRegistration registration;
+
+    public void start(BundleContext context) throws Exception {
+        System.out.println("Starting repository");
+        repository = RepositoryImpl.create(
+                RepositoryConfig.install(new File("jackrabbit")));
+        RepositoryFactoryImpl.setDefaultRepository(repository);
+        registration = context.registerService(
+                Repository.class.getName(),
+                repository,
+                new Hashtable<String, String>());
+    }
+
+    public void stop(BundleContext context) throws Exception {
+        System.out.println("Stopping repository");
+        RepositoryFactoryImpl.setDefaultRepository(null);
+        registration.unregister();
+        repository.shutdown();
+    }
+
+}

Propchange: jackrabbit/sandbox/osgi/jackrabbit-bundle/src/main/java/org/apache/jackrabbit/bundle/Activator.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message