You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by gn...@apache.org on 2009/04/18 10:44:46 UTC

svn commit: r766268 - in /geronimo/sandbox/blueprint: itests/src/test/java/org/apache/felix/blueprint/itests/Test.java org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/ModuleContextImpl.java

Author: gnodet
Date: Sat Apr 18 08:44:46 2009
New Revision: 766268

URL: http://svn.apache.org/viewvc?rev=766268&view=rev
Log:
Register the ModuleContext in the OSGi registry and make the integration tests test the sample bundle

Modified:
    geronimo/sandbox/blueprint/itests/src/test/java/org/apache/felix/blueprint/itests/Test.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/ModuleContextImpl.java

Modified: geronimo/sandbox/blueprint/itests/src/test/java/org/apache/felix/blueprint/itests/Test.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/itests/src/test/java/org/apache/felix/blueprint/itests/Test.java?rev=766268&r1=766267&r2=766268&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/itests/src/test/java/org/apache/felix/blueprint/itests/Test.java (original)
+++ geronimo/sandbox/blueprint/itests/src/test/java/org/apache/felix/blueprint/itests/Test.java Sat Apr 18 08:44:46 2009
@@ -22,6 +22,7 @@
 
 import org.apache.servicemix.kernel.testing.support.AbstractIntegrationTest;
 import org.osgi.framework.Bundle;
+import org.osgi.service.blueprint.context.ModuleContext;
 import org.springframework.core.io.Resource;
 import org.springframework.util.Assert;
 
@@ -32,6 +33,11 @@
         Bundle bundle = installBundle(res);
         assertNotNull(bundle);
         bundle.start();
+
+        ModuleContext moduleContext = getOsgiService(ModuleContext.class, 5000);
+        assertNotNull(moduleContext);
+
+        // TODO: Check that the moduleContext has been correctly instanciated, that it contains the right beans, etc...
     }
 
     /**

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/ModuleContextImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/ModuleContextImpl.java?rev=766268&r1=766267&r2=766268&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/ModuleContextImpl.java (original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/ModuleContextImpl.java Sat Apr 18 08:44:46 2009
@@ -27,6 +27,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.Properties;
 
 import org.apache.felix.blueprint.BlueprintConstants;
 import org.apache.felix.blueprint.HeaderParser;
@@ -40,6 +41,7 @@
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.blueprint.context.ModuleContext;
 import org.osgi.service.blueprint.context.NoSuchComponentException;
 import org.osgi.service.blueprint.convert.ConversionService;
@@ -66,6 +68,7 @@
     private final List<URL> urls;
     private final ComponentDefinitionRegistryImpl componentDefinitionRegistry;
     private final ConversionServiceImpl conversionService;
+    private ServiceRegistration registration;
 
     public ModuleContextImpl(BundleContext bundleContext, ModuleContextEventSender sender, NamespaceHandlerRegistry handlers, List<URL> urls) {
         this.bundleContext = bundleContext;
@@ -107,7 +110,13 @@
             registerTypeConverters(graph);
             
             System.out.println(graph.createAll(new ArrayList<String>(componentDefinitionRegistry.getComponentDefinitionNames())));
-                        
+
+            // Register the ModuleContext in the OSGi registry
+            Properties props = new Properties();
+            props.put("osgi.blueprint.context.symbolicname", bundleContext.getBundle().getSymbolicName());
+            props.put("osgi.blueprint.context.version", bundleContext.getBundle().getHeaders().get(Constants.BUNDLE_VERSION));
+            registration = bundleContext.registerService(ModuleContext.class.getName(), this, props);
+
             sender.sendCreated(this);
         } catch (WaitForDependencyException e) {
             sender.sendWaiting(this, e.getServiceObjectClass(), e.getServiceFilter());
@@ -186,6 +195,9 @@
     }
 
     public void destroy() {
+        if (registration != null) {
+            registration.unregister();
+        }
         sender.sendDestroying(this);
         System.out.println("Module context destroyed: " + this.bundleContext);
         // TODO: destroy all instances