cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject cxf git commit: Fix problems with using <cxf:bus> with blueprint-no-osgi
Date Fri, 15 May 2015 14:50:21 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 307b3ed0a -> 49b2be36f


Fix problems with using <cxf:bus> with blueprint-no-osgi


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/49b2be36
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/49b2be36
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/49b2be36

Branch: refs/heads/master
Commit: 49b2be36f5181ec4172f50ea8d31c8c94d4beef1
Parents: 307b3ed
Author: Daniel Kulp <dkulp@apache.org>
Authored: Fri May 15 10:49:55 2015 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri May 15 10:49:55 2015 -0400

----------------------------------------------------------------------
 .../cxf/bus/blueprint/BlueprintBeanLocator.java | 22 +++++++++++---------
 .../apache/cxf/bus/blueprint/BlueprintBus.java  |  9 ++++++--
 .../AbstractBPBeanDefinitionParser.java         | 14 ++++++-------
 .../jaxrs_uriinfo_blueprint/WEB-INF/beans.xml   |  2 +-
 4 files changed, 26 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/49b2be36/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java b/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
index 70b547e..4db349d 100644
--- a/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
+++ b/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
@@ -123,7 +123,7 @@ public class BlueprintBeanLocator implements ConfiguredBeanLocator {
                 list.add(type.cast(container.getComponentInstance(s)));
             }
         }
-        if (list.isEmpty()) {
+        if (list.isEmpty() && context != null) {
             try {
                 ServiceReference refs[] = context.getServiceReferences(type.getName(), null);
                 if (refs != null) {
@@ -168,16 +168,18 @@ public class BlueprintBeanLocator implements ConfiguredBeanLocator {
         }
         
         try {
-            ServiceReference refs[] = context.getServiceReferences(type.getName(), null);
-            if (refs != null) {
-                for (ServiceReference r : refs) {
-                    Object o2 = context.getService(r);
-                    Class<? extends T> t = o2.getClass().asSubclass(type);
-                    if (listener.loadBean(t.getName(), t)) {
-                        if (listener.beanLoaded(t.getName(), type.cast(o2))) {
-                            return true;
+            if (context != null) {
+                ServiceReference refs[] = context.getServiceReferences(type.getName(), null);
+                if (refs != null) {
+                    for (ServiceReference r : refs) {
+                        Object o2 = context.getService(r);
+                        Class<? extends T> t = o2.getClass().asSubclass(type);
+                        if (listener.loadBean(t.getName(), t)) {
+                            if (listener.beanLoaded(t.getName(), type.cast(o2))) {
+                                return true;
+                            }
+                            loaded = true;
                         }
-                        loaded = true;
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/cxf/blob/49b2be36/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java b/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
index 9842ad3..b6b68dc 100644
--- a/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
+++ b/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
@@ -67,10 +67,15 @@ public class BlueprintBus extends ExtensionManagerBus {
         setExtension(new BlueprintBeanLocator(getExtension(ConfiguredBeanLocator.class),
container, context),
                            ConfiguredBeanLocator.class);
     }
+    @Override
     public String getId() {
         if (id == null) {
-            id = context.getBundle().getSymbolicName() + "-" 
-                + DEFAULT_BUS_ID + Integer.toString(this.hashCode());
+            if (context == null) {
+                id = super.getId();
+            } else {
+                id = context.getBundle().getSymbolicName() + "-" 
+                    + DEFAULT_BUS_ID + Integer.toString(this.hashCode());
+            }
         }
         return id;
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/49b2be36/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
b/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
index 6be1e3c..c71601c 100644
--- a/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
+++ b/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
@@ -52,7 +52,6 @@ import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.staxutils.StaxUtils;
-import org.osgi.framework.Bundle;
 import org.osgi.service.blueprint.reflect.BeanMetadata;
 import org.osgi.service.blueprint.reflect.CollectionMetadata;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
@@ -266,11 +265,7 @@ public abstract class AbstractBPBeanDefinitionParser {
     protected MutableBeanMetadata getBus(ParserContext context, String name) {
         ComponentDefinitionRegistry cdr = context.getComponentDefinitionRegistry();
         ComponentMetadata meta = cdr.getComponentDefinition("blueprintBundle");
-
-        Bundle blueprintBundle = null;
-        if (meta instanceof PassThroughMetadata) {
-            blueprintBundle = (Bundle) ((PassThroughMetadata) meta).getObject();
-        }
+        
         if (!cdr.containsComponentDefinition(InterceptorTypeConverter.class.getName())) {
             MutablePassThroughMetadata md = context.createMetadata(MutablePassThroughMetadata.class);
             md.setObject(new InterceptorTypeConverter());
@@ -278,13 +273,16 @@ public abstract class AbstractBPBeanDefinitionParser {
             md.setId(InterceptorTypeConverter.class.getName());
             context.getComponentDefinitionRegistry().registerTypeConverter(md);
         }
-        if (blueprintBundle != null && !cdr.containsComponentDefinition(name)) {
+        if (!cdr.containsComponentDefinition(name)) {
             //Create a bus
 
             MutableBeanMetadata bus = context.createMetadata(MutableBeanMetadata.class);
             bus.setId(name);
             bus.setRuntimeClass(BlueprintBus.class);
-            bus.addProperty("bundleContext", createRef(context, "blueprintBundleContext"));
+            if (meta != null) {
+                //blueprint-no-osgi does not provide a bundleContext
+                bus.addProperty("bundleContext", createRef(context, "blueprintBundleContext"));
+            }
             bus.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
             bus.setDestroyMethod("shutdown");
             bus.setInitMethod("initialize");

http://git-wip-us.apache.org/repos/asf/cxf/blob/49b2be36/systests/jaxrs/src/test/resources/jaxrs_uriinfo_blueprint/WEB-INF/beans.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/resources/jaxrs_uriinfo_blueprint/WEB-INF/beans.xml b/systests/jaxrs/src/test/resources/jaxrs_uriinfo_blueprint/WEB-INF/beans.xml
index dd056e2..9cc8d1d 100644
--- a/systests/jaxrs/src/test/resources/jaxrs_uriinfo_blueprint/WEB-INF/beans.xml
+++ b/systests/jaxrs/src/test/resources/jaxrs_uriinfo_blueprint/WEB-INF/beans.xml
@@ -29,7 +29,7 @@
         Having cxf:bus has no effect: <cxf:bus/>
         Having cxf:bus with id causes NPE in BusDefinitionParser: <cxf:bus id="cxf"/>
  
      -->        
-     <bean id="cxf" class="org.apache.cxf.bus.extension.ExtensionManagerBus"/>
+     <cxf:bus/>
      
      <jaxrs:server id="resourceServer" address="/">
         <jaxrs:serviceBeans>


Mime
View raw message