jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1330292 - in /jackrabbit/oak/trunk: oak-core/ oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/ oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/ oak-jcr/ oak-jcr/src/main...
Date Wed, 25 Apr 2012 13:45:02 GMT
Author: jukka
Date: Wed Apr 25 13:45:01 2012
New Revision: 1330292

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

Add basic OSGi services for mk, core and jcr. WIP...

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/Activator.java
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/osgi/
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/osgi/Activator.java
Modified:
    jackrabbit/oak/trunk/oak-core/pom.xml
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentRepository.java
    jackrabbit/oak/trunk/oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OSGiIT.java
    jackrabbit/oak/trunk/oak-jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/GlobalContext.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/OakRepositoryFactory.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
    jackrabbit/oak/trunk/oak-mk/pom.xml
    jackrabbit/oak/trunk/oak-parent/pom.xml
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RepositoryServlet.java

Modified: jackrabbit/oak/trunk/oak-core/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/pom.xml?rev=1330292&r1=1330291&r2=1330292&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-core/pom.xml Wed Apr 25 13:45:01 2012
@@ -45,6 +45,9 @@
               org.apache.jackrabbit.oak.namepath,
               org.apache.jackrabbit.oak.plugins.name
             </Export-Package>
+            <Bundle-Activator>
+              org.apache.jackrabbit.oak.osgi.Activator
+            </Bundle-Activator>
           </instructions>
         </configuration>
       </plugin>
@@ -52,6 +55,19 @@
   </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>biz.aQute</groupId>
       <artifactId>bndlib</artifactId>

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentRepository.java?rev=1330292&r1=1330291&r2=1330292&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentRepository.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/KernelContentRepository.java
Wed Apr 25 13:45:01 2012
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.oak.core;
 
 import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
@@ -50,6 +51,14 @@ public class KernelContentRepository imp
     private final QueryEngine queryEngine;
     private final KernelNodeStore nodeStore;
 
+    /**
+     * Utility constructor that creates a new in-memory repository for use
+     * mostly in test cases.
+     */
+    public KernelContentRepository() {
+        this(new MicroKernelImpl());
+    }
+
     public KernelContentRepository(MicroKernel mk) {
         microKernel = mk;
         valueFactory = new CoreValueFactoryImpl(microKernel);

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java?rev=1330292&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
Wed Apr 25 13:45:01 2012
@@ -0,0 +1,86 @@
+/*
+ * 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.osgi;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.oak.api.ContentRepository;
+import org.apache.jackrabbit.oak.core.KernelContentRepository;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+public class Activator implements BundleActivator, ServiceTrackerCustomizer {
+
+    private BundleContext context;
+
+    private ServiceTracker tracker;
+
+    private final Map<ServiceReference, ServiceRegistration> services =
+            new HashMap<ServiceReference, ServiceRegistration>();
+
+    //-----------------------------------------------------< BundleActivator >--
+
+    @Override
+    public void start(BundleContext bundleContext) throws Exception {
+        context = bundleContext;
+        tracker = new ServiceTracker(
+                context, MicroKernel.class.getName(), this);
+        tracker.open();
+    }
+
+    @Override
+    public void stop(BundleContext bundleContext) throws Exception {
+        tracker.open();
+    }
+
+    //--------------------------------------------< ServiceTrackerCustomizer >--
+
+    @Override
+    public Object addingService(ServiceReference reference) {
+        Object service = context.getService(reference);
+        if (service instanceof MicroKernel) {
+            MicroKernel kernel = (MicroKernel) service;
+            services.put(reference, context.registerService(
+                    ContentRepository.class.getName(),
+                    new KernelContentRepository(kernel),
+                    new Properties()));
+            return service;
+        } else {
+            context.ungetService(reference);
+            return null;
+        }
+    }
+
+    @Override
+    public void modifiedService(ServiceReference reference, Object service) {
+    }
+
+    @Override
+    public void removedService(ServiceReference reference, Object service) {
+        ServiceRegistration registration = services.get(reference);
+        registration.unregister();
+        context.ungetService(reference);
+    }
+
+}

Modified: jackrabbit/oak/trunk/oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OSGiIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OSGiIT.java?rev=1330292&r1=1330291&r2=1330292&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OSGiIT.java
(original)
+++ jackrabbit/oak/trunk/oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OSGiIT.java
Wed Apr 25 13:45:01 2012
@@ -23,6 +23,10 @@ import java.io.File;
 import java.io.IOException;
 import java.net.URISyntaxException;
 
+import javax.jcr.Repository;
+
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.CoreOptions;
@@ -30,8 +34,10 @@ import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.Configuration;
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
 
 @RunWith(JUnit4TestRunner.class)
+@SuppressWarnings({ "rawtypes", "unchecked" })
 public class OSGiIT {
 
     private final File TARGET = new File("target");
@@ -53,14 +59,45 @@ public class OSGiIT {
  
     @Test
     public void testMicroKernel(BundleContext bc) throws Exception {
+        ServiceReference reference =
+                bc.getServiceReference(MicroKernel.class.getName());
+
+        Object service = bc.getService(reference);
+        assert service instanceof MicroKernel;
+
+        MicroKernel kernel = (MicroKernel) service;
+        System.out.println(kernel);
+        System.out.println(kernel.getHeadRevision());
+
+        bc.ungetService(reference);
     }
 
     @Test
-    public void testOakRepository(BundleContext bc) throws Exception {
+    public void testContentRepository(BundleContext bc) throws Exception {
+        ServiceReference reference =
+                bc.getServiceReference(ContentRepository.class.getName());
+
+        Object service = bc.getService(reference);
+        assert service instanceof ContentRepository;
+
+        ContentRepository repository = (ContentRepository) service;
+        System.out.println(repository);
+
+        bc.ungetService(reference);
     }
 
     @Test
-    public void testJcrRepository(BundleContext bc) throws Exception {
+    public void testRepository(BundleContext bc) throws Exception {
+        ServiceReference reference =
+                bc.getServiceReference(Repository.class.getName());
+
+        Object service = bc.getService(reference);
+        assert service instanceof ContentRepository;
+
+        Repository repository = (Repository) service;
+        System.out.println(repository);
+
+        bc.ungetService(reference);
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1330292&r1=1330291&r2=1330292&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Wed Apr 25 13:45:01 2012
@@ -41,6 +41,9 @@
             <Export-Package>
               !
             </Export-Package>
+            <Bundle-Activator>
+              org.apache.jackrabbit.oak.jcr.osgi.Activator
+            </Bundle-Activator>
           </instructions>
         </configuration>
       </plugin>
@@ -48,6 +51,20 @@
   </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>javax.jcr</groupId>
       <artifactId>jcr</artifactId>

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/GlobalContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/GlobalContext.java?rev=1330292&r1=1330291&r2=1330292&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/GlobalContext.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/GlobalContext.java
Wed Apr 25 13:45:01 2012
@@ -19,16 +19,15 @@
 
 package org.apache.jackrabbit.oak.jcr;
 
-import org.apache.jackrabbit.mk.api.MicroKernel;
-import org.apache.jackrabbit.oak.api.ContentRepository;
-import org.apache.jackrabbit.oak.core.KernelContentRepository;
-import org.apache.jackrabbit.oak.jcr.util.Unchecked;
+import static java.text.MessageFormat.format;
 
-import javax.jcr.Repository;
 import java.util.HashMap;
 import java.util.Map;
 
-import static java.text.MessageFormat.format;
+import javax.jcr.Repository;
+
+import org.apache.jackrabbit.oak.api.ContentRepository;
+import org.apache.jackrabbit.oak.jcr.util.Unchecked;
 
 /**
  * Poor man's dependency injection
@@ -41,9 +40,10 @@ public class GlobalContext {
 
     private final Map<Class<?>, Object> instances = new HashMap<Class<?>,
Object>();
 
-    public GlobalContext(MicroKernel mk) {
-        put(ContentRepository.class, new KernelContentRepository(mk));
-        put(Repository.class, new RepositoryImpl(this));
+    public GlobalContext(
+            Repository repository, ContentRepository contentRepository) {
+        put(Repository.class, repository);
+        put(ContentRepository.class, contentRepository);
     }
 
     public <T> T getInstance(Class<T> forClass) {

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/OakRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/OakRepositoryFactory.java?rev=1330292&r1=1330291&r2=1330292&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/OakRepositoryFactory.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/OakRepositoryFactory.java
Wed Apr 25 13:45:01 2012
@@ -20,8 +20,6 @@ import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.RepositoryFactory;
 
-import org.apache.jackrabbit.mk.core.MicroKernelImpl;
-
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Map;
@@ -52,8 +50,7 @@ public class OakRepositoryFactory implem
             URI uri, Map<String, String> parameters)
             throws RepositoryException {
         // TODO correctly interpret uri
-        GlobalContext context = new GlobalContext(new MicroKernelImpl());
-        return context.getInstance(Repository.class);
+        return new RepositoryImpl();
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java?rev=1330292&r1=1330291&r2=1330292&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
Wed Apr 25 13:45:01 2012
@@ -17,9 +17,9 @@
 package org.apache.jackrabbit.oak.jcr;
 
 import org.apache.jackrabbit.commons.SimpleValueFactory;
-import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.ContentRepository;
+import org.apache.jackrabbit.oak.core.KernelContentRepository;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -43,8 +43,8 @@ public class RepositoryImpl implements R
     private final GlobalContext context;
     private final Descriptors descriptors = new Descriptors(new SimpleValueFactory());
 
-    public RepositoryImpl(GlobalContext context) {
-        this.context = context;
+    public RepositoryImpl(ContentRepository repository) {
+        this.context = new GlobalContext(this, repository);
     }
 
     /**
@@ -52,7 +52,7 @@ public class RepositoryImpl implements R
      * mostly in test cases.
      */
     public RepositoryImpl() throws RepositoryException {
-        this(new GlobalContext(new MicroKernelImpl()));
+        this(new KernelContentRepository());
     }
 
     //---------------------------------------------------------< Repository >---
@@ -119,7 +119,6 @@ public class RepositoryImpl implements R
     @Override
     public Session login(Credentials credentials, String workspaceName) throws RepositoryException
{
         // TODO: needs complete refactoring
-
         ContentRepository contentRepository = context.getInstance(ContentRepository.class);
         try {
             ContentSession contentSession = contentRepository.login(credentials, workspaceName);

Added: 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=1330292&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/Activator.java
(added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/Activator.java
Wed Apr 25 13:45:01 2012
@@ -0,0 +1,87 @@
+/*
+ * 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.jcr.osgi;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.jcr.Repository;
+
+import org.apache.jackrabbit.oak.api.ContentRepository;
+import org.apache.jackrabbit.oak.jcr.RepositoryImpl;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+public class Activator implements BundleActivator, ServiceTrackerCustomizer {
+
+    private BundleContext context;
+
+    private ServiceTracker tracker;
+
+    private final Map<ServiceReference, ServiceRegistration> services =
+            new HashMap<ServiceReference, ServiceRegistration>();
+
+    //-----------------------------------------------------< BundleActivator >--
+
+    @Override
+    public void start(BundleContext bundleContext) throws Exception {
+        context = bundleContext;
+        tracker = new ServiceTracker(
+                context, ContentRepository.class.getName(), this);
+        tracker.open();
+    }
+
+    @Override
+    public void stop(BundleContext bundleContext) throws Exception {
+        tracker.open();
+    }
+
+    //--------------------------------------------< ServiceTrackerCustomizer >--
+
+    @Override
+    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()));
+            return service;
+        } else {
+            context.ungetService(reference);
+            return null;
+        }
+    }
+
+    @Override
+    public void modifiedService(ServiceReference reference, Object service) {
+    }
+
+    @Override
+    public void removedService(ServiceReference reference, Object service) {
+        ServiceRegistration registration = services.get(reference);
+        registration.unregister();
+        context.ungetService(reference);
+    }
+
+}

Modified: jackrabbit/oak/trunk/oak-mk/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/pom.xml?rev=1330292&r1=1330291&r2=1330292&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-mk/pom.xml Wed Apr 25 13:45:01 2012
@@ -45,6 +45,9 @@
               org.apache.jackrabbit.mk.core,
               org.apache.jackrabbit.mk.blobs
             </Export-Package>
+            <Bundle-Activator>
+              org.apache.jackrabbit.mk.osgi.Activator
+            </Bundle-Activator>
           </instructions>
         </configuration>
       </plugin>
@@ -52,6 +55,13 @@
   </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>biz.aQute</groupId>
       <artifactId>bndlib</artifactId>

Added: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/osgi/Activator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/osgi/Activator.java?rev=1330292&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/osgi/Activator.java
(added)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/osgi/Activator.java
Wed Apr 25 13:45:01 2012
@@ -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.mk.osgi;
+
+import java.util.Properties;
+
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.mk.core.MicroKernelImpl;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class Activator implements BundleActivator {
+
+    private ServiceRegistration registration;
+
+    //-----------------------------------------------------< BundleActivator >--
+
+    @Override
+    public void start(BundleContext context) throws Exception {
+        registration = context.registerService(
+                MicroKernel.class.getName(),
+                new MicroKernelImpl(),
+                new Properties());
+    }
+
+    @Override
+    public void stop(BundleContext context) throws Exception {
+        registration.unregister();
+    }
+
+}

Modified: jackrabbit/oak/trunk/oak-parent/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-parent/pom.xml?rev=1330292&r1=1330291&r2=1330292&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-parent/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-parent/pom.xml Wed Apr 25 13:45:01 2012
@@ -90,6 +90,16 @@
   <dependencyManagement>
     <dependencies>
       <dependency>
+        <groupId>org.osgi</groupId>
+        <artifactId>org.osgi.core</artifactId>
+        <version>4.0.0</version>
+      </dependency>
+      <dependency>
+        <groupId>org.osgi</groupId>
+        <artifactId>org.osgi.compendium</artifactId>
+        <version>4.0.0</version>
+      </dependency>
+      <dependency>
         <groupId>biz.aQute</groupId>
         <artifactId>bndlib</artifactId>
         <version>1.50.0</version>

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RepositoryServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RepositoryServlet.java?rev=1330292&r1=1330291&r2=1330292&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RepositoryServlet.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/RepositoryServlet.java
Wed Apr 25 13:45:01 2012
@@ -18,11 +18,11 @@ package org.apache.jackrabbit.oak.run;
 
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
-import org.apache.jackrabbit.oak.jcr.GlobalContext;
 import org.apache.jackrabbit.oak.jcr.RepositoryImpl;
 import org.apache.jackrabbit.webdav.jcr.JCRWebdavServerServlet;
 
 import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
 import javax.servlet.ServletException;
 
 class RepositoryServlet extends JCRWebdavServerServlet {
@@ -45,7 +45,11 @@ class RepositoryServlet extends JCRWebda
             kernel = new MicroKernelImpl();
         }
 
-        repository = new RepositoryImpl(new GlobalContext(kernel));
+        try {
+            repository = new RepositoryImpl();
+        } catch (RepositoryException e) {
+            throw new ServletException("Could not start a repository", e);
+        }
         super.init();
     }
 



Mime
View raw message