cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1149444 - /cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
Date Fri, 22 Jul 2011 03:18:40 GMT
Author: ningjiang
Date: Fri Jul 22 03:18:39 2011
New Revision: 1149444

URL: http://svn.apache.org/viewvc?rev=1149444&view=rev
Log:
CXF-3678 Fixed the NPE error of BlueprintBeanLocator

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java?rev=1149444&r1=1149443&r2=1149444&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
Fri Jul 22 03:18:39 2011
@@ -25,12 +25,14 @@ import java.util.Collections;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.logging.Logger;
 
 import org.apache.aries.blueprint.ExtendedBlueprintContainer;
 import org.apache.aries.blueprint.container.BeanRecipe;
 import org.apache.aries.blueprint.di.ExecutionContext;
 import org.apache.aries.blueprint.di.Recipe;
 import org.apache.cxf.bus.extension.ExtensionManagerImpl;
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.configuration.ConfiguredBeanLocator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -40,6 +42,7 @@ import org.osgi.service.blueprint.contai
  * 
  */
 public class BlueprintBeanLocator implements ConfiguredBeanLocator {
+    private static final Logger LOG = LogUtils.getL7dLogger(BlueprintBeanLocator.class);
     ConfiguredBeanLocator orig;
     ExtendedBlueprintContainer container;
     BundleContext context;
@@ -65,7 +68,7 @@ public class BlueprintBeanLocator implem
         try {
             for (String s : container.getComponentIds()) {
                 Recipe r = container.getRepository().getRecipe(s);
-                if (r instanceof BeanRecipe 
+                if (r instanceof BeanRecipe && ((BeanRecipe)r).getType() != null
                     && type.isAssignableFrom(((BeanRecipe)r).getType())) {
                     names.add(s);
                 }
@@ -86,11 +89,11 @@ public class BlueprintBeanLocator implem
         try {
             for (String s : container.getComponentIds()) {
                 Recipe r = container.getRepository().getRecipe(s);
-                if (r instanceof BeanRecipe 
+                if (r instanceof BeanRecipe && ((BeanRecipe)r).getType() != null
                     && type.isAssignableFrom(((BeanRecipe)r).getType())) {
                     
                     list.add(type.cast(container.getComponentInstance(s)));
-                }
+                } 
             }
         } finally {
             ExecutionContext.Holder.setContext(origContext);
@@ -106,6 +109,8 @@ public class BlueprintBeanLocator implem
                 }
             } catch (Exception ex) {
                 //ignore, just don't support the OSGi services
+                LOG.info("Try to find the Bean with type:" + type 
+                    + " from OSGi services and get error: " + ex);  
             }
         }
         
@@ -121,7 +126,7 @@ public class BlueprintBeanLocator implem
         try {
             for (String s : container.getComponentIds()) {
                 Recipe r = container.getRepository().getRecipe(s);
-                if (r instanceof BeanRecipe 
+                if (r instanceof BeanRecipe && ((BeanRecipe)r).getType() != null
                     && type.isAssignableFrom(((BeanRecipe)r).getType())) {
                     names.add(s);
                 }



Mime
View raw message