You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2009/01/25 09:00:13 UTC

svn commit: r737487 - in /camel/trunk/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/ main/java/org/apache/camel/component/cxf/converter/ main/java/org/apache/camel/component/cxf/spring/ test/java/org/apache/camel/component/cxf/ tes...

Author: ningjiang
Date: Sun Jan 25 08:00:13 2009
New Revision: 737487

URL: http://svn.apache.org/viewvc?rev=737487&view=rev
Log:
CAMEL-1294 Added the missing unit test and set the beanId for the CxfSpringEndpoint

Added:
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterConverterRouterTest.java   (with props)
    camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterConverterEndpointsRouterContext.xml   (with props)
Modified:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java?rev=737487&r1=737486&r2=737487&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java (original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java Sun Jan 25 08:00:13 2009
@@ -85,7 +85,7 @@
         if (bean.getProperties() != null) {
             Map<String, Object> copy = new HashMap<String, Object>();
             copy.putAll(bean.getProperties());
-
+            
             // pass the copy the method modifies the properties map
             IntrospectionSupport.setProperties(getCamelContext().getTypeConverter(), 
                     this, copy);      
@@ -199,7 +199,10 @@
     
     // Properties
     // -------------------------------------------------------------------------
-
+    public void setBeanId(String id) {        
+        this.beanId = id;
+    }
+    
     public void setServiceNamespace(String serviceNamespace) {
         this.serviceNamespace = serviceNamespace;
     }

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java?rev=737487&r1=737486&r2=737487&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java (original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java Sun Jan 25 08:00:13 2009
@@ -77,8 +77,9 @@
         if (endpointBean == null) {
             throw new IllegalArgumentException("The CxfEndpoint instance is null");
         }
-        //CamelContext 
+        // CamelContext 
         SpringCamelContext context = SpringCamelContext.springCamelContext(endpointBean.getApplicationContext());
+        // The beanId will be set from endpointBean's property        
         Endpoint answer = new CxfSpringEndpoint(context, endpointBean);        
         return answer;
     }

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=737487&r1=737486&r2=737487&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 Sun Jan 25 08:00:13 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.cxf.spring;
 
+import java.util.HashMap;
 import java.util.Map;
 import javax.xml.namespace.QName;
 import org.w3c.dom.Element;
@@ -28,6 +29,7 @@
 import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.parsing.BeanComponentDefinition;
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import org.springframework.beans.factory.xml.ParserContext;
@@ -45,7 +47,8 @@
 
     @Override
     protected void mapAttribute(BeanDefinitionBuilder bean, Element e, String name, String val) {
-        if ("endpointName".equals(name) || "serviceName".equals(name)) {
+                
+        if ("endpointName".equals(name) || "serviceName".equals(name)) {           
             QName q = parseQName(e, val);
             bean.addPropertyValue(name, q);
         } else {
@@ -76,6 +79,14 @@
     protected void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
         super.doParse(element, ctx, bean);
         bean.setLazyInit(false);
+        // put the id into the properies
+        Map map = (Map) bean.getBeanDefinition().getPropertyValues().getPropertyValue("properties");
+        String id = resolveId(element, bean.getBeanDefinition(), ctx);
+        if (map == null) {
+            map = new HashMap();
+            bean.addPropertyValue("properties", map);
+        }
+        map.put("beanId", id);        
     }
 
     @Override
@@ -83,11 +94,11 @@
                                AbstractBeanDefinition definition,
                                ParserContext ctx)
         throws BeanDefinitionStoreException {
-        String id = super.resolveId(elem, definition, ctx);
+        String id = super.resolveId(elem, definition, ctx);        
+        
         if (StringUtils.isEmpty(id)) {
             throw new BeanDefinitionStoreException("The bean id is needed.");
-        }
-
+        }       
         return id;
     }
 
@@ -100,6 +111,7 @@
     // , we implements the ApplicationContextAware here
     public static class CxfSpringEndpointBean extends CxfEndpointBean implements ApplicationContextAware {
         private ApplicationContext applicationContext;
+        private String beanId;
         
         public CxfSpringEndpointBean() {
             super();
@@ -122,6 +134,14 @@
             return applicationContext;
         }
         
+        public void setId(String id) {
+            beanId = id;
+        }
+        
+        public String getId() {
+            return beanId;
+        }
+        
     }
 
 

Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterConverterRouterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterConverterRouterTest.java?rev=737487&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterConverterRouterTest.java (added)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterConverterRouterTest.java Sun Jan 25 08:00:13 2009
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.cxf;
+
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+
+public class CxfGreeterConverterRouterTest extends CXFGreeterRouterTest {
+    
+    protected ClassPathXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/GreeterConverterEndpointsRouterContext.xml");
+    }
+
+}

Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterConverterRouterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterConverterRouterTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterConverterEndpointsRouterContext.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterConverterEndpointsRouterContext.xml?rev=737487&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterConverterEndpointsRouterContext.xml (added)
+++ camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterConverterEndpointsRouterContext.xml Sun Jan 25 08:00:13 2009
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:cxf="http://activemq.apache.org/camel/schema/cxfEndpoint"
+
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://activemq.apache.org/camel/schema/cxfEndpoint http://activemq.apache.org/camel/schema/cxfEndpoint/camel-cxf.xsd
+       http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+    ">
+   <import resource="classpath:META-INF/cxf/cxf.xml"/>
+   <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
+   <import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml" />
+   <!-- Added the import for testing the CAMEL-329 -->
+
+
+   <cxf:cxfEndpoint id="routerEndpoint" address="http://localhost:9003/CamelContext/RouterPort"
+    		serviceClass="org.apache.hello_world_soap_http.Greeter" 
+    		endpointName="s:SoapPort"
+    		serviceName="s:SOAPService"
+    	    xmlns:s="http://apache.org/hello_world_soap_http"/>
+
+   <cxf:cxfEndpoint id="serviceEndpoint" address="http://localhost:9000/SoapContext/SoapPort"
+    		wsdlURL="testutils/hello_world.wsdl"
+    		serviceClass="org.apache.hello_world_soap_http.Greeter"
+    		endpointName="s:SoapPort"
+    		serviceName="s:SOAPService"
+    	xmlns:s="http://apache.org/hello_world_soap_http" />
+
+   <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
+    <route errorHandlerRef="noErrorHandler">
+      <from uri="routerEndpoint" />
+      <to uri="serviceEndpoint" />
+    </route>
+   </camelContext>
+
+   <bean id="noErrorHandler" class="org.apache.camel.builder.NoErrorHandlerBuilder"/>
+
+</beans>
\ No newline at end of file

Propchange: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterConverterEndpointsRouterContext.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterConverterEndpointsRouterContext.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterConverterEndpointsRouterContext.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml