jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1331368 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/ oak-it/osgi/ oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/
Date Fri, 27 Apr 2012 11:50:56 GMT
Author: jukka
Date: Fri Apr 27 11:50:55 2012
New Revision: 1331368

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

Simplified OSGi test with the @Inject annotation.
Fix initialization order issue with the query index provider.

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
    jackrabbit/oak/trunk/oak-it/osgi/pom.xml
    jackrabbit/oak/trunk/oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OSGiIT.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java?rev=1331368&r1=1331367&r2=1331368&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
Fri Apr 27 11:50:55 2012
@@ -63,9 +63,22 @@ public class ContentRepositoryImpl imple
     }
 
     private ContentRepositoryImpl(MicroKernel mk) {
-        this(mk, new Indexer(mk));
+        this(mk, getDefaultIndexProvider(mk));
     }
 
+    private static QueryIndexProvider getDefaultIndexProvider(MicroKernel mk) {
+        QueryIndexProvider provider = new Indexer(mk);
+        provider.init();
+        return provider;
+    }
+
+    /**
+     * Creates an Oak repository instance based on the given, already
+     * initialized components.
+     *
+     * @param mk underlying kernel instance
+     * @param indexProvider index provider
+     */
     public ContentRepositoryImpl(MicroKernel mk, QueryIndexProvider indexProvider) {
         microKernel = mk;
         valueFactory = new CoreValueFactoryImpl(microKernel);
@@ -73,7 +86,6 @@ public class ContentRepositoryImpl imple
         queryEngine = new QueryEngineImpl(microKernel, valueFactory, indexProvider);
 
         // FIXME: workspace setup must be done elsewhere...
-        indexProvider.init();
         queryEngine.init();
         NodeState root = nodeStore.getRoot();
 

Modified: 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=1331368&r1=1331367&r2=1331368&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
Fri Apr 27 11:50:55 2012
@@ -36,7 +36,7 @@ public class Activator implements Bundle
 
     private ServiceTracker tracker;
 
-    private OsgiIndexProvider indexProvider;
+    private final OsgiIndexProvider indexProvider = new OsgiIndexProvider();
 
     private final Map<ServiceReference, ServiceRegistration> services =
             new HashMap<ServiceReference, ServiceRegistration>();
@@ -46,16 +46,18 @@ public class Activator implements Bundle
     @Override
     public void start(BundleContext bundleContext) throws Exception {
         context = bundleContext;
+
+        indexProvider.start(bundleContext);
+
         tracker = new ServiceTracker(
                 context, MicroKernel.class.getName(), this);
         tracker.open();
-        indexProvider = new OsgiIndexProvider();
-        indexProvider.start(bundleContext);
     }
 
     @Override
     public void stop(BundleContext bundleContext) throws Exception {
         tracker.close();
+
         indexProvider.stop();
     }
 

Modified: jackrabbit/oak/trunk/oak-it/osgi/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/osgi/pom.xml?rev=1331368&r1=1331367&r2=1331368&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/osgi/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-it/osgi/pom.xml Fri Apr 27 11:50:55 2012
@@ -32,7 +32,7 @@
 
   <properties>
     <skip.deployment>true</skip.deployment>
-    <pax.exam.version>2.2.0</pax.exam.version>
+    <pax.exam.version>2.4.0.RC1</pax.exam.version>
   </properties>
 
   <build>
@@ -93,6 +93,12 @@
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-atinject_1.0_spec</artifactId>
+      <version>1.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>org.ops4j.pax.exam</groupId>
       <artifactId>pax-exam-container-native</artifactId>
       <version>${pax.exam.version}</version>

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=1331368&r1=1331367&r2=1331368&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
Fri Apr 27 11:50:55 2012
@@ -23,6 +23,7 @@ import java.io.File;
 import java.io.IOException;
 import java.net.URISyntaxException;
 
+import javax.inject.Inject;
 import javax.jcr.Repository;
 
 import org.apache.jackrabbit.mk.api.MicroKernel;
@@ -33,8 +34,6 @@ import org.ops4j.pax.exam.CoreOptions;
 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" })
@@ -56,48 +55,30 @@ public class OSGiIT {
                 bundle(new File(base, "oak-core.jar").toURI().toURL().toString()),
                 bundle(new File(base, "oak-jcr.jar").toURI().toURL().toString()));
     }
- 
-    @Test
-    public void testMicroKernel(BundleContext bc) throws Exception {
-        ServiceReference reference =
-                bc.getServiceReference(MicroKernel.class.getName());
 
-        Object service = bc.getService(reference);
-        assert service instanceof MicroKernel;
+    @Inject
+    private MicroKernel kernel;
 
-        MicroKernel kernel = (MicroKernel) service;
+    @Test
+    public void testMicroKernel() {
         System.out.println(kernel);
         System.out.println(kernel.getHeadRevision());
-
-        bc.ungetService(reference);
     }
 
-    @Test
-    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);
-    }
+    @Inject
+    private ContentRepository oakRepository;
 
     @Test
-    public void testRepository(BundleContext bc) throws Exception {
-        ServiceReference reference =
-                bc.getServiceReference(Repository.class.getName());
-
-        Object service = bc.getService(reference);
-        assert service instanceof ContentRepository;
+    public void testOakRepository() {
+        System.out.println(oakRepository);
+    }
 
-        Repository repository = (Repository) service;
-        System.out.println(repository);
+    @Inject
+    private Repository jcrRepository;
 
-        bc.ungetService(reference);
+    @Test
+    public void testJcrRepository() {
+        System.out.println(jcrRepository);
     }
 
 }



Mime
View raw message