Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CAMEL-5967 supported to specify the camelContextId through the attrib…

…ute of destination or conduite

git-svn-id: https://svn.apache.org/repos/asf/camel/trunk@1432828 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit c708cdda14244af154558c8395f4bcec599c71a8 1 parent 9421dbc
@WillemJiang WillemJiang authored
View
8 .../main/java/org/apache/camel/component/cxf/transport/spring/AbstractCamelContextBeanDefinitionParser.java
@@ -19,6 +19,7 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.apache.camel.util.ObjectHelper;
+import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
@@ -44,6 +45,13 @@ protected void wireCamelContext(BeanDefinitionBuilder bean, String camelContextI
protected void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
// Parser the id attribute
bean.setAbstract(true);
+ // Parser the camelContextId attribute
+ final String camelContextId = element.getAttribute("camelContextId");
+ if (!StringUtils.isEmpty(camelContextId)) {
+ wireCamelContext(bean, getContextId(camelContextId));
+ // Don't need to do further parsing here
+ return;
+ }
NodeList children = element.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node n = children.item(i);
View
4 components/camel-cxf-transport/src/main/resources/schema/configuration/camel.xsd
@@ -41,6 +41,8 @@
<xs:element name="camelContextRef" type="xs:string" minOccurs="0"/>
</xs:sequence>
<xs:attributeGroup ref="cxf-beans:beanAttributes"/>
+ <!-- here we need to specify the CamelContext reference -->
+ <xs:attribute name="camelContextId" type="xs:string" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
@@ -55,6 +57,8 @@
<xs:element name="camelContextRef" type="xs:string" minOccurs="0"/>
</xs:sequence>
<xs:attributeGroup ref="cxf-beans:beanAttributes"/>
+ <!-- here we need to specify the CamelContext reference -->
+ <xs:attribute name="camelContextId" type="xs:string" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
View
13 components/camel-cxf-transport/src/test/java/org/apache/camel/component/cxf/transport/CamelConduitTest.java
@@ -62,6 +62,8 @@ protected CamelContext createCamelContext() throws Exception {
public void testCamelConduitConfiguration() throws Exception {
QName testEndpointQNameA = new QName("http://camel.apache.org/camel-test", "portA");
QName testEndpointQNameB = new QName("http://camel.apache.org/camel-test", "portB");
+ QName testEndpointQNameC = new QName("http://camel.apache.org/camel-test", "portC");
+
// set up the bus with configure file
SpringBusFactory bf = new SpringBusFactory();
BusFactory.setDefaultBus(null);
@@ -77,6 +79,17 @@ public void testCamelConduitConfiguration() throws Exception {
assertNotNull("the camel context which get from camel conduit is not null", context);
assertEquals("get the wrong camel context", context.getName(), "conduit_context");
assertEquals("direct://EndpointA", context.getRoutes().get(0).getEndpoint().getEndpointUri());
+
+ // test the configuration of camelContextId attribute
+ endpointInfo.setAddress("camel://direct:EndpointA");
+ endpointInfo.setName(testEndpointQNameC);
+ conduit = new CamelConduit(null, bus, endpointInfo);
+ context = conduit.getCamelContext();
+
+ assertNotNull("the camel context which get from camel conduit is not null", context);
+ assertEquals("get the wrong camel context", context.getName(), "conduit_context");
+ assertEquals("direct://EndpointA", context.getRoutes().get(0).getEndpoint().getEndpointUri());
+
endpointInfo.setAddress("camel://direct:EndpointC");
endpointInfo.setName(testEndpointQNameB);
View
4 components/camel-cxf-transport/src/test/resources/org/apache/camel/component/cxf/transport/CamelConduit.xml
@@ -36,6 +36,10 @@
<camel:conduit name="{http://camel.apache.org/camel-test}portA.camel-conduit">
<camel:camelContextRef>conduit_context</camel:camelContextRef>
</camel:conduit>
+
+ <camel:conduit name="{http://camel.apache.org/camel-test}portC.camel-conduit" camelContextId="conduit_context"/>
+
+
<!-- START SNIPPET: example -->
<camel:conduit name="{http://camel.apache.org/camel-test}portB.camel-conduit">
<camelContext id="context" xmlns="http://camel.apache.org/schema/spring">
Please sign in to comment.
Something went wrong with that request. Please try again.