geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r774259 - /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
Date Wed, 13 May 2009 08:55:07 GMT
Author: gnodet
Date: Wed May 13 08:55:07 2009
New Revision: 774259

URL: http://svn.apache.org/viewvc?rev=774259&view=rev
Log:
Avoid possible NPE

Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java?rev=774259&r1=774258&r2=774259&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
Wed May 13 08:55:07 2009
@@ -48,6 +48,7 @@
 import org.apache.xbean.recipe.Recipe;
 import org.apache.xbean.recipe.ExecutionContext;
 import org.apache.xbean.recipe.DefaultExecutionContext;
+import org.apache.xbean.recipe.ConstructionException;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
@@ -55,6 +56,7 @@
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.blueprint.context.BlueprintContext;
 import org.osgi.service.blueprint.context.NoSuchComponentException;
+import org.osgi.service.blueprint.context.ComponentDefinitionException;
 import org.osgi.service.blueprint.convert.ConversionService;
 import org.osgi.service.blueprint.convert.Converter;
 import org.osgi.service.blueprint.namespace.NamespaceHandler;
@@ -309,7 +311,7 @@
     }
 
     private Map<String, List<SatisfiableRecipe>> getSatisfiableDependenciesMap()
{
-        if (satisfiables == null) {
+        if (satisfiables == null && instantiator != null) {
             boolean createNewContext = !ExecutionContext.isContextSet();
             if (createNewContext) {
                 ExecutionContext.setContext(new DefaultExecutionContext(instantiator.getRepository()));
@@ -367,10 +369,12 @@
     
     private void untrackServiceReferences() {
         Map<String, List<SatisfiableRecipe>> dependencies = getSatisfiableDependenciesMap();
-        for (String name : dependencies.keySet()) {
-            for (SatisfiableRecipe satisfiable : dependencies.get(name)) {
-                satisfiable.unregisterListener(this);
-                satisfiable.stop();
+        if (dependencies != null) {
+            for (String name : dependencies.keySet()) {
+                for (SatisfiableRecipe satisfiable : dependencies.get(name)) {
+                    satisfiable.unregisterListener(this);
+                    satisfiable.stop();
+                }
             }
         }
     }
@@ -432,7 +436,11 @@
             }
         }
         LOGGER.debug("Instantiating components: {}", components);
-        instantiator.createAll(components);
+        try {
+            instantiator.createAll(components);
+        } catch (ConstructionException e) {
+            throw (ComponentDefinitionException) new ComponentDefinitionException("Unable
to instantiate components").initCause(e);
+        }
     }
 
     private void destroyComponents() {
@@ -516,6 +524,8 @@
             return instantiator.create(name);
         } catch (org.apache.xbean.recipe.NoSuchObjectException e) {
             throw new NoSuchComponentException(name);
+        } catch (ConstructionException e) {
+            throw (ComponentDefinitionException) new ComponentDefinitionException("Cound
not create component instance for " + name).initCause(e);
         }
     }
 



Mime
View raw message