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/20 04:37:32 UTC
svn commit: r735926 - in /camel/branches/camel-1.x/components/camel-cxf/src:
main/java/org/apache/camel/component/cxf/
main/java/org/apache/camel/component/cxf/spring/
main/java/org/apache/camel/component/cxf/transport/
main/java/org/apache/camel/compo...
Author: ningjiang
Date: Mon Jan 19 19:37:31 2009
New Revision: 735926
URL: http://svn.apache.org/viewvc?rev=735926&view=rev
Log:
CAMEL-1275 Get the camelcontext been injected into CamelDestination and CamelConduit
Added:
camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelEndpointSpringConfigureTest.java (with props)
camel/branches/camel-1.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelEndpointSpringConfigure.xml (with props)
Modified:
camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java
camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java
camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java
camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/spring/AbstractCamelContextBeanDefinitionParser.java
Modified: camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java?rev=735926&r1=735925&r2=735926&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java (original)
+++ camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java Mon Jan 19 19:37:31 2009
@@ -28,6 +28,8 @@
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.configuration.spring.ConfigurerImpl;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.frontend.ServerFactoryBean;
@@ -46,7 +48,7 @@
Bus bus = null;
this.endpoint = endpoint;
boolean isWebServiceProvider = false;
- if (endpoint.getApplicationContext() != null) {
+ if (endpoint.getApplicationContext() != null) {
if (endpoint.getCxfEndpointBean() != null) {
bus = endpoint.getCxfEndpointBean().getBus();
} else {
@@ -109,8 +111,7 @@
@Override
protected void doStart() throws Exception {
super.doStart();
-
- server.start();
+ server.start();
}
@Override
@@ -122,5 +123,9 @@
public CxfEndpoint getEndpoint() {
return endpoint;
}
+
+ public Server getServer() {
+ return server;
+ }
}
Modified: camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java?rev=735926&r1=735925&r2=735926&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java (original)
+++ camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java Mon Jan 19 19:37:31 2009
@@ -41,6 +41,8 @@
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.configuration.spring.ConfigurerImpl;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.frontend.ClientProxy;
@@ -95,7 +97,7 @@
Bus bus = null;
if (endpoint.getApplicationContext() != null) {
if (endpoint.getCxfEndpointBean() != null) {
- bus = endpoint.getCxfEndpointBean().getBus();
+ bus = endpoint.getCxfEndpointBean().getBus();
} else {
SpringBusFactory busFactory = new SpringBusFactory(endpoint.getApplicationContext());
bus = busFactory.createBus();
@@ -273,5 +275,9 @@
return result;
}
+
+ public Client getClient() {
+ return client;
+ }
}
Modified: camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java?rev=735926&r1=735925&r2=735926&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java (original)
+++ camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java Mon Jan 19 19:37:31 2009
@@ -109,10 +109,10 @@
public void setApplicationContext(ApplicationContext ctx) throws BeansException {
if (getBus() == null) {
- Bus bus = BusFactory.getThreadDefaultBus();
- BusWiringBeanFactoryPostProcessor.updateBusReferencesInContext(bus, ctx);
+ Bus bus = BusFactory.getThreadDefaultBus();
setBus(bus);
- }
+ }
+ BusWiringBeanFactoryPostProcessor.updateBusReferencesInContext(bus, ctx);
}
}
Modified: camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java?rev=735926&r1=735925&r2=735926&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java (original)
+++ camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java Mon Jan 19 19:37:31 2009
@@ -88,6 +88,7 @@
public CamelContext getCamelContext() {
if (camelContext == null) {
+ getLogger().log(Level.INFO, "No CamelContext injected, create a default one");
camelContext = new DefaultCamelContext();
}
return camelContext;
Modified: camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java?rev=735926&r1=735925&r2=735926&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java (original)
+++ camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java Mon Jan 19 19:37:31 2009
@@ -138,6 +138,7 @@
public CamelContext getCamelContext() {
if (camelContext == null) {
+ getLogger().log(Level.INFO, "No CamelContext injected, create a default one");
camelContext = new DefaultCamelContext();
}
return camelContext;
@@ -160,13 +161,13 @@
public String getBeanName() {
if (endpointInfo == null || endpointInfo.getName() == null) {
return "default" + BASE_BEAN_NAME_SUFFIX;
- }
+ }
return endpointInfo.getName().toString() + BASE_BEAN_NAME_SUFFIX;
}
private void initConfig() {
//we could configure the camel context here
- if (bus != null) {
+ if (bus != null) {
Configurer configurer = bus.getExtension(Configurer.class);
if (null != configurer) {
configurer.configureBean(this);
Modified: camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/spring/AbstractCamelContextBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/spring/AbstractCamelContextBeanDefinitionParser.java?rev=735926&r1=735925&r2=735926&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/spring/AbstractCamelContextBeanDefinitionParser.java (original)
+++ camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/spring/AbstractCamelContextBeanDefinitionParser.java Mon Jan 19 19:37:31 2009
@@ -30,7 +30,7 @@
private static final String DEFAULT_CAMEL_CONTEXT_NAME = "camelContext";
private String getContextId(String contextId) {
- if (ObjectHelper.isNullOrBlank(contextId)) {
+ if (ObjectHelper.isEmpty(contextId)) {
//Set the contextId default value here
return DEFAULT_CAMEL_CONTEXT_NAME;
} else {
Added: camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelEndpointSpringConfigureTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelEndpointSpringConfigureTest.java?rev=735926&view=auto
==============================================================================
--- camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelEndpointSpringConfigureTest.java (added)
+++ camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelEndpointSpringConfigureTest.java Mon Jan 19 19:37:31 2009
@@ -0,0 +1,64 @@
+/**
+ * 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.transport;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.cxf.CxfConsumer;
+import org.apache.camel.component.cxf.CxfEndpoint;
+import org.apache.camel.component.cxf.CxfProducer;
+import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class CamelEndpointSpringConfigureTest extends SpringTestSupport {
+
+ public void testCreateDestinationFromSpring() throws Exception {
+ CxfEndpoint cxfEndpoint = (CxfEndpoint) context.getEndpoint("cxf:bean:serviceEndpoint");
+ CxfProducer producer = (CxfProducer)cxfEndpoint.createProducer();
+ assertNotNull("The producer should not be null", producer);
+ producer.start();
+ CamelConduit conduit = (CamelConduit)producer.getClient().getConduit();
+ assertTrue("we should get SpringCamelContext here", conduit.getCamelContext() instanceof SpringCamelContext);
+ assertEquals("The context id should be camel_conduit", "camel_conduit", conduit.getCamelContext().getName());
+
+ cxfEndpoint = (CxfEndpoint) context.getEndpoint("cxf:bean:routerEndpoint");
+ CxfConsumer consumer = (CxfConsumer)cxfEndpoint.createConsumer(new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ // do nothing here
+ }
+ });
+ assertNotNull("The consumer should not be null", consumer);
+ consumer.start();
+ CamelDestination destination = (CamelDestination)consumer.getServer().getDestination();
+ assertTrue("we should get SpringCamelContext here", destination.getCamelContext() instanceof SpringCamelContext);
+ assertEquals("The context id should be camel_destination", "camel_destination", destination.getCamelContext().getName());
+
+
+ }
+
+ @Override
+ protected AbstractXmlApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("/org/apache/camel/component/cxf/transport/CamelEndpointSpringConfigure.xml");
+ }
+ @Override
+ protected int getExpectedRouteCount() {
+ return 0;
+ }
+
+}
Propchange: camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelEndpointSpringConfigureTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelEndpointSpringConfigureTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/branches/camel-1.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelEndpointSpringConfigure.xml
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelEndpointSpringConfigure.xml?rev=735926&view=auto
==============================================================================
--- camel/branches/camel-1.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelEndpointSpringConfigure.xml (added)
+++ camel/branches/camel-1.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelEndpointSpringConfigure.xml Mon Jan 19 19:37:31 2009
@@ -0,0 +1,53 @@
+<?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"
+ xmlns:camel="http://cxf.apache.org/transports/camel"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://cxf.apache.org/transports/camel http://cxf.apache.org/transports/camel.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
+ ">
+ <camel:destination name="{http://apache.org/hello_world_soap_http}SoapPort.camel-destination">
+ <camelContext id="camel_destination" xmlns="http://activemq.apache.org/camel/schema/spring">
+ </camelContext>
+ </camel:destination>
+
+ <camel:conduit name="{http://apache.org/hello_world_soap_http}SoapPort.camel-conduit">
+ <camelContext id="camel_conduit" xmlns="http://activemq.apache.org/camel/schema/spring">
+ </camelContext>
+ </camel:conduit>
+
+ <cxf:cxfEndpoint id="routerEndpoint" address="camel://direct://Endpoint"
+ serviceClass="org.apache.hello_world_soap_http.Greeter"
+ endpointName="s:SoapPort"
+ serviceName="s:SOAPService"
+ xmlns:s="http://apache.org/hello_world_soap_http"
+ transportId="http://cxf.apache.org/transports/camel">
+ </cxf:cxfEndpoint>
+
+ <cxf:cxfEndpoint id="serviceEndpoint" address="camel://direct://service"
+ 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>
+
+</beans>
\ No newline at end of file
Propchange: camel/branches/camel-1.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelEndpointSpringConfigure.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/branches/camel-1.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelEndpointSpringConfigure.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: camel/branches/camel-1.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelEndpointSpringConfigure.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml