jackrabbit-commits mailing list archives

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

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

Add service properties for the repository service. Assertions in the bundle test case.

Modified:
    jackrabbit/sandbox/osgi/jackrabbit-bundle-it/src/test/java/org/apache/jackrabbit/test/osgi/BundleTest.java
    jackrabbit/sandbox/osgi/jackrabbit-bundle/src/main/java/org/apache/jackrabbit/bundle/Activator.java

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=1044046&r1=1044045&r2=1044046&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:31:29 2010
@@ -18,11 +18,12 @@ package org.apache.jackrabbit.test.osgi;
 
 import javax.jcr.Repository;
 
+import junit.framework.Assert;
+
 import org.apache.jackrabbit.commons.JcrUtils;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.MavenConfiguredJUnit4TestRunner;
-import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 
@@ -31,13 +32,18 @@ public class BundleTest {
 
     @Test
     public void testJackrabbitBundle(BundleContext context) throws Exception {
-        for (Bundle bundle : context.getBundles()) {
-            System.out.println("Bundle: " + bundle.getSymbolicName() + " " + bundle.getState());
-        }
-        for (ServiceReference reference : context.getServiceReferences(Repository.class.getName(),
null)) {
-            System.out.println("Service: " + reference);
-        }
-        System.out.println("Repository: " + JcrUtils.getRepository());
+        ServiceReference reference =
+            context.getServiceReference(Repository.class.getName());
+        Assert.assertNotNull(reference);
+        Assert.assertEquals(
+                "Jackrabbit",
+                reference.getProperty(Repository.REP_NAME_DESC));
+
+        Repository repository = JcrUtils.getRepository();
+        Assert.assertNotNull(repository);
+        Assert.assertEquals(
+                "Jackrabbit",
+                repository.getDescriptor(Repository.REP_NAME_DESC));
     }
 
 }

Modified: 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=1044046&r1=1044045&r2=1044046&view=diff
==============================================================================
--- jackrabbit/sandbox/osgi/jackrabbit-bundle/src/main/java/org/apache/jackrabbit/bundle/Activator.java
(original)
+++ jackrabbit/sandbox/osgi/jackrabbit-bundle/src/main/java/org/apache/jackrabbit/bundle/Activator.java
Thu Dec  9 17:31:29 2010
@@ -35,20 +35,25 @@ public class Activator implements Bundle
     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);
+
+        Hashtable<String, String> properties = new Hashtable<String, String>();
+        for (String key : repository.getDescriptorKeys()) {
+            String descriptor = repository.getDescriptor(key);
+            if (descriptor != null) {
+                properties.put(key, descriptor);
+            }
+        }
         registration = context.registerService(
-                Repository.class.getName(),
-                repository,
-                new Hashtable<String, String>());
+                Repository.class.getName(), repository, properties);
     }
 
     public void stop(BundleContext context) throws Exception {
-        System.out.println("Stopping repository");
-        RepositoryFactoryImpl.setDefaultRepository(null);
         registration.unregister();
+
+        RepositoryFactoryImpl.setDefaultRepository(null);
         repository.shutdown();
     }
 



Mime
View raw message