Author: wtam
Date: Wed Mar  4 20:38:44 2009
New Revision: 750147

URL: http://svn.apache.org/viewvc?rev=750147&view=rev
Log:
[CAMEL-1421] Cxf Endpoint String bean properites are not merged

Modified:
    
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/ServiceClassRefTest.java
    
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/ServiceClassRefTest-context.xml

Modified: 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java?rev=750147&r1=750146&r2=750147&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java
 Wed Mar  4 20:38:44 2009
@@ -55,11 +55,17 @@
         }
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     protected void mapElement(ParserContext ctx, BeanDefinitionBuilder bean, 
Element el, String name) {
         if ("properties".equals(name)) {
-            Map<?, ?> map = ctx.getDelegate().parseMapElement(el, 
bean.getBeanDefinition());
+            Map map = ctx.getDelegate().parseMapElement(el, 
bean.getBeanDefinition());
+            Map props = getPropertyMap(bean, false);
+            if (props != null) {
+                map.putAll(props);
+            }
             bean.addPropertyValue("properties", map);
+            
         } else if ("binding".equals(name)) {
             setFirstChildAsProperty(el, ctx, bean, "bindingConfig");
         } else if ("inInterceptors".equals(name) || 
"inFaultInterceptors".equals(name)
@@ -86,7 +92,7 @@
 
         if (org.springframework.util.StringUtils.hasText(val)) {
             if (val.startsWith("#")) {
-                Map<String, Object> map = getPropertyMap(bean);
+                Map<String, Object> map = getPropertyMap(bean, true);
                 map.put(propertyName, val);
             } else {
                 bean.addPropertyValue(propertyName, val);
@@ -101,7 +107,7 @@
         bean.setLazyInit(false);
         
         // put the bean id into the property map
-        Map<String, Object> map = getPropertyMap(bean);
+        Map<String, Object> map = getPropertyMap(bean, true);
         map.put("beanId", resolveId(element, bean.getBeanDefinition(), ctx));  
      
     }
 
@@ -124,14 +130,16 @@
     }
 
     @SuppressWarnings("unchecked")
-    private Map<String, Object> getPropertyMap(BeanDefinitionBuilder bean) {
+    private Map<String, Object> getPropertyMap(BeanDefinitionBuilder bean, 
boolean lazyInstantiation) {
         PropertyValue propertyValue = 
(PropertyValue)bean.getBeanDefinition().getPropertyValues()
             .getPropertyValue("properties");
         
         Map<String, Object> map = null;
         if (propertyValue == null) {
-            map = new HashMap<String, Object>();
-            bean.addPropertyValue("properties", map);
+            if (lazyInstantiation) {
+                map = new HashMap<String, Object>();
+                bean.addPropertyValue("properties", map);
+            }
         } else {
             map = (Map<String, Object>)propertyValue.getValue();
         }

Modified: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/ServiceClassRefTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/ServiceClassRefTest.java?rev=750147&r1=750146&r2=750147&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/ServiceClassRefTest.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/ServiceClassRefTest.java
 Wed Mar  4 20:38:44 2009
@@ -33,8 +33,15 @@
     protected CamelContext context;
     
     public void testServiceClassNameCreatedByRefNotation() throws Exception {
+        // verify the '#' notation works
         CxfEndpoint endpoint = context.getEndpoint("cxf:bean:fromEndpoint", 
CxfEndpoint.class);
         assertEquals("org.apache.camel.component.cxf.HelloServiceImpl", 
endpoint.getServiceClass());
+        assertEquals(DataFormat.POJO, endpoint.getDataFormat());
+        
+        // verify values in bean properties are ok
+        endpoint = context.getEndpoint("cxf:bean:fromEndpointWithProps", 
CxfEndpoint.class);
+        assertEquals(DataFormat.PAYLOAD, endpoint.getDataFormat());
     }
 
+
 }

Modified: 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/ServiceClassRefTest-context.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/ServiceClassRefTest-context.xml?rev=750147&r1=750146&r2=750147&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/ServiceClassRefTest-context.xml
 (original)
+++ 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/ServiceClassRefTest-context.xml
 Wed Mar  4 20:38:44 2009
@@ -14,29 +14,36 @@
                License.
        -->
 <beans xmlns="http://www.springframework.org/schema/beans";
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
-       xmlns:cxf="http://camel.apache.org/schema/cxfEndpoint";
-       
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:cxf="http://camel.apache.org/schema/cxfEndpoint";
        xsi:schemaLocation="
        http://www.springframework.org/schema/beans  
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://camel.apache.org/schema/spring  
http://camel.apache.org/schema/spring/camel-spring.xsd
        http://camel.apache.org/schema/cxfEndpoint 
http://camel.apache.org/schema/cxf/camel-cxf.xsd
     ">
     
-    <bean id="myServiceClass" 
class="org.apache.camel.component.cxf.HelloServiceImpl"/>
-    
-       <cxf:cxfEndpoint id="fromEndpoint" 
address="http://localhost:9000/helloworld";
+       <bean id="myServiceClass" 
class="org.apache.camel.component.cxf.HelloServiceImpl" />
+       
+       <cxf:cxfEndpoint id="fromEndpointWithProps" 
address="http://localhost:9004/helloworld";
+               serviceClass="#myServiceClass">
+               <cxf:properties>
+                       <entry key="dataFormat" value="PAYLOAD" />
+               </cxf:properties>
+       </cxf:cxfEndpoint>
+       
+       <cxf:cxfEndpoint id="fromEndpoint" 
address="http://localhost:9003/helloworld";
                serviceClass="#myServiceClass" />
-               
+
        <cxf:cxfEndpoint id="toEndpoint" 
address="http://localhost:9002/helloworld";
                serviceClass="org.apache.camel.component.cxf.HelloService" />
-
-       <camelContext id="camelContext"
-               xmlns="http://camel.apache.org/schema/spring";>
+               
+       <camelContext id="camelContext" 
xmlns="http://camel.apache.org/schema/spring";>
                <route>
-                       <from uri="cxf:bean:fromEndpoint"/>
-                       <to uri="cxf:bean:toEndpoint"/>
+                       <from uri="cxf:bean:fromEndpoint" />
+                       <to uri="cxf:bean:toEndpoint" />
+               </route>
+               <route>
+                       <from uri="cxf:bean:fromEndpointWithProps" />
+                       <to uri="cxf:bean:toEndpoint?dataFormat=PAYLOAD" />
                </route>
        </camelContext>
-
 </beans>
\ No newline at end of file


Reply via email to