Author: ningjiang
Date: Mon Aug 29 10:17:04 2011
New Revision: 1162716
URL: http://svn.apache.org/viewvc?rev=1162716&view=rev
Log:
CAMEL-4351 Fixed the issue of placeholders in endpointName and serviceName
attributes of cxf:cxfEndpoint
Added:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/QNameConverter.java
(with props)
Modified:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java
camel/trunk/components/camel-cxf/src/main/resources/schema/cxfEndpoint.xsd
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/CxfEndpointBeans.xml
Modified:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java?rev=1162716&r1=1162715&r2=1162716&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
(original)
+++
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
Mon Aug 29 10:17:04 2011
@@ -549,6 +549,10 @@ public class CxfEndpoint extends Default
serviceName = service;
}
+ public void setServiceName(String service) {
+ setServiceName(QName.valueOf(service));
+ }
+
public QName getServiceName() {
return serviceName;
}
@@ -560,10 +564,15 @@ public class CxfEndpoint extends Default
public void setPortName(QName port) {
portName = port;
}
+
public void setEndpointName(QName port) {
portName = port;
}
+ public void setEndpointName(String port) {
+ setEndpointName(QName.valueOf(port));
+ }
+
public String getDefaultOperationName() {
return defaultOperationName;
}
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=1162716&r1=1162715&r2=1162716&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
Mon Aug 29 10:17:04 2011
@@ -34,11 +34,22 @@ public class CxfEndpointBeanDefinitionPa
return CxfSpringEndpoint.class;
}
+ private boolean isSpringPlaceHolder(String value) {
+ if (value != null && value.startsWith("${") && value.endsWith("}")) {
+ return true;
+ }
+ return false;
+ }
+
@Override
protected void mapAttribute(BeanDefinitionBuilder bean, Element e, String
name, String val) {
if ("endpointName".equals(name) || "serviceName".equals(name)) {
- QName q = parseQName(e, val);
- bean.addPropertyValue(name, q);
+ if (isSpringPlaceHolder(val)) {
+ mapToProperty(bean, name, val);
+ } else {
+ QName q = parseQName(e, val);
+ bean.addPropertyValue(name, q);
+ }
} else {
mapToProperty(bean, name, val);
}
Added:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/QNameConverter.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/QNameConverter.java?rev=1162716&view=auto
==============================================================================
---
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/QNameConverter.java
(added)
+++
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/QNameConverter.java
Mon Aug 29 10:17:04 2011
@@ -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.spring;
+
+import org.springframework.core.convert.converter.Converter;
+
+import javax.xml.namespace.QName;
+
+public class QNameConverter implements Converter<String, QName> {
+
+ @Override
+ public QName convert(String source) {
+ return QName.valueOf(source);
+ }
+}
Propchange:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/QNameConverter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/QNameConverter.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
camel/trunk/components/camel-cxf/src/main/resources/schema/cxfEndpoint.xsd
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/resources/schema/cxfEndpoint.xsd?rev=1162716&r1=1162715&r2=1162716&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/resources/schema/cxfEndpoint.xsd
(original)
+++ camel/trunk/components/camel-cxf/src/main/resources/schema/cxfEndpoint.xsd
Mon Aug 29 10:17:04 2011
@@ -54,8 +54,8 @@
<xsd:attribute name="serviceClass" type="xsd:string"/>
<xsd:attribute name="transportId" type="xsd:string"/>
<xsd:attribute name="wsdlURL" type="xsd:string" />
- <xsd:attribute name="endpointName" type="xsd:QName" />
- <xsd:attribute name="serviceName" type="xsd:QName" />
+ <xsd:attribute name="endpointName" type="xsd:string" />
+ <xsd:attribute name="serviceName" type="xsd:string" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Modified:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java?rev=1162716&r1=1162715&r2=1162716&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java
(original)
+++
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java
Mon Aug 29 10:17:04 2011
@@ -18,14 +18,23 @@ package org.apache.camel.component.cxf.s
import org.apache.camel.component.cxf.CXFTestSupport;
import org.apache.camel.component.cxf.CxfEndpoint;
-import org.apache.camel.test.AvailablePortFinder;
import org.junit.Test;
+import javax.xml.namespace.QName;
+
public class CxfEndpointBeanTest extends AbstractSpringBeanTestSupport {
static int port1 = CXFTestSupport.getPort1();
- static int port2 = CXFTestSupport.getPort2();
+ static {
+ //set them as system properties so Spring can use the property
placeholder
+ //things to set them into the URL's in the spring contexts
+ System.setProperty("CxfEndpointBeans.serviceName",
"{http://camel.apache.org/wsdl-first}PersonService");
+ System.setProperty("CxfEndpointBeans.endpointName",
"{http://camel.apache.org/wsdl-first}soap");
+ }
+ private QName serviceName =
QName.valueOf("{http://camel.apache.org/wsdl-first}PersonService");
+ private QName endpointName =
QName.valueOf("{http://camel.apache.org/wsdl-first}soap");
+
+
-
protected String[] getApplicationContextFiles() {
return new
String[]{"org/apache/camel/component/cxf/spring/CxfEndpointBeans.xml"};
}
@@ -40,6 +49,12 @@ public class CxfEndpointBeanTest extends
assertEquals("Got the wrong handlers size", 1,
routerEndpoint.getHandlers().size());
assertEquals("Got the wrong schemalocations size", 1,
routerEndpoint.getSchemaLocations().size());
assertEquals("Got the wrong schemalocation",
"classpath:wsdl/Message.xsd", routerEndpoint.getSchemaLocations().get(0));
+
+ CxfEndpoint myEndpoint = (CxfEndpoint)ctx.getBean("myEndpoint");
+ assertEquals("Got the wrong endpointName", endpointName,
myEndpoint.getPortName());
+ assertEquals("Got the wrong serviceName", serviceName,
myEndpoint.getServiceName());
}
+
+
}
Modified:
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/CxfEndpointBeans.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/CxfEndpointBeans.xml?rev=1162716&r1=1162715&r2=1162716&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/CxfEndpointBeans.xml
(original)
+++
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/CxfEndpointBeans.xml
Mon Aug 29 10:17:04 2011
@@ -28,6 +28,15 @@
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+ <bean id="conversionService"
+ class="org.springframework.context.support.ConversionServiceFactoryBean">
+ <property name="converters">
+ <list>
+ <bean
class="org.apache.camel.component.cxf.spring.QNameConverter"/>
+ </list>
+ </property>
+ </bean>
+
<cxf:cxfEndpoint id="routerEndpoint"
address="http://localhost:${CXFTestSupport.port1}/CxfEndpointBeanTest/router"
serviceClass="org.apache.camel.component.cxf.HelloService">
<cxf:schemaLocations>
@@ -40,4 +49,8 @@
<cxf:cxfEndpoint id="serviceEndpoint"
address="http://localhost:${CXFTestSupport.port2}/CxfEndpointBeanTest/helloworld"
serviceClass="org.apache.camel.component.cxf.HelloService"/>
+ <cxf:cxfEndpoint id="myEndpoint"
address="http://localhot:${CXFTestSupport.port3}/test"
+ serviceClass="org.apache.camel.wsdl_first.Person"
serviceName="${CxfEndpointBeans.serviceName}"
endpointName="${CxfEndpointBeans.endpointName}"
+ wsdlURL="person.wsdl"/>
+
</beans>