cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1209212 - in /cxf/trunk: common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
Date Thu, 01 Dec 2011 19:48:12 GMT
Author: dkulp
Date: Thu Dec  1 19:48:09 2011
New Revision: 1209212

URL: http://svn.apache.org/viewvc?rev=1209212&view=rev
Log:
[CXF-3947] Make sure the bus names aren't lost when parsing beans with
bus properties

Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java?rev=1209212&r1=1209211&r2=1209212&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
Thu Dec  1 19:48:09 2011
@@ -40,6 +40,7 @@ import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.jaxb.JAXBContextCache;
 import org.apache.cxf.jaxb.JAXBContextCache.CachedContextAndSchemas;
@@ -51,12 +52,13 @@ import org.springframework.beans.factory
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
 import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.StringUtils;
 
 public abstract class AbstractBeanDefinitionParser 
     extends org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser {
     public static final String WIRE_BUS_ATTRIBUTE = AbstractBeanDefinitionParser.class.getName()
+ ".wireBus";
     public static final String WIRE_BUS_NAME = AbstractBeanDefinitionParser.class.getName()
+ ".wireBusName";
+    public static final String WIRE_BUS_HANDLER 
+        = "org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor";
     private static final Logger LOG = LogUtils.getL7dLogger(AbstractBeanDefinitionParser.class);
     
     private Class beanClass;
@@ -100,9 +102,13 @@ public abstract class AbstractBeanDefini
                 processNameAttribute(element, ctx, bean, val);
             } else if (!"id".equals(name) && isAttribute(pre, name)) {
                 if ("bus".equals(name)) {                                     
-                    if (val != null && val.trim().length() > 0 
-                        && ctx.getRegistry().containsBeanDefinition(val)) {
-                        bean.addPropertyReference(name, val);
+                    if (val != null && val.trim().length() > 0) {
+                        if (ctx.getRegistry().containsBeanDefinition(val)) {
+                            bean.addPropertyReference(name, val);
+                        } else {
+                            addBusWiringAttribute(bean, BusWiringType.PROPERTY,
+                                                  val, ctx);
+                        }
                         setBus = true;                         
                     }
                 } else {
@@ -226,17 +232,28 @@ public abstract class AbstractBeanDefini
 
     protected void addBusWiringAttribute(BeanDefinitionBuilder bean, 
                                          BusWiringType type) {
-        addBusWiringAttribute(bean, type, null);
+        addBusWiringAttribute(bean, type, null, null);
     }
                                          
     protected void addBusWiringAttribute(BeanDefinitionBuilder bean, 
                                          BusWiringType type,
-                                         String busName) {
+                                         String busName,
+                                         ParserContext ctx) {
         LOG.fine("Adding " + WIRE_BUS_ATTRIBUTE + " attribute " + type + " to bean " + bean);
         bean.getRawBeanDefinition().setAttribute(WIRE_BUS_ATTRIBUTE, type);
-        if (busName != null) {
+        if (!StringUtils.isEmpty(busName)) {
+            if (busName.charAt(0) == '#') {
+                busName = busName.substring(1);
+            }
             bean.getRawBeanDefinition().setAttribute(WIRE_BUS_NAME, busName); 
         }
+        
+        if (ctx != null 
+            && !ctx.getRegistry().containsBeanDefinition(WIRE_BUS_HANDLER)) {
+            BeanDefinitionBuilder b 
+                = BeanDefinitionBuilder.rootBeanDefinition(WIRE_BUS_HANDLER);
+            ctx.getRegistry().registerBeanDefinition(WIRE_BUS_HANDLER, b.getBeanDefinition());
+        }
     }
     
     protected void mapElementToJaxbProperty(Element parent, 
@@ -418,7 +435,7 @@ public abstract class AbstractBeanDefini
             return;
         }
         
-        if (StringUtils.hasText(val)) {
+        if (!StringUtils.isEmpty(val)) {
             if (val.startsWith("#")) {
                 bean.addPropertyReference(propertyName, val.substring(1));
             } else {

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java?rev=1209212&r1=1209211&r2=1209212&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java Thu
Dec  1 19:48:09 2011
@@ -60,9 +60,9 @@ public class BusDefinitionParser extends
         }
         element.removeAttribute("name");
         if (StringUtils.isEmpty(bus)) {
-            addBusWiringAttribute(bean, BusWiringType.PROPERTY);
+            addBusWiringAttribute(bean, BusWiringType.PROPERTY, null, ctx);
         } else {
-            addBusWiringAttribute(bean, BusWiringType.PROPERTY, bus);
+            addBusWiringAttribute(bean, BusWiringType.PROPERTY, bus, ctx);
         }
         String id = element.getAttribute("id");
         if (!StringUtils.isEmpty(id)) {



Mime
View raw message