Author: ningjiang
Date: Wed Jul 29 11:56:08 2009
New Revision: 798864
URL: http://svn.apache.org/viewvc?rev=798864&view=rev
Log:
CAMEL-1856 Added ProxyProcessor according to Rong's request
Added:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/ProxyProcessor.java
(with props)
Modified:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelJBIClientProxyTest.java
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelJBIClientProxy.xml
Modified:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelJBIClientProxyTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelJBIClientProxyTest.java?rev=798864&r1=798863&r2=798864&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelJBIClientProxyTest.java
(original)
+++
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelJBIClientProxyTest.java
Wed Jul 29 11:56:08 2009
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.cxf.transport;
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.cxf.HelloService;
import org.junit.After;
import org.junit.Before;
@@ -39,11 +41,20 @@
}
@Test
- public void echoMethodTest() {
+ public void testCallFromProxy() {
String response = proxy.echo("Hello World!");
assertEquals("Get a wrong response ", "echo Hello World!", response);
}
+ @Test
+ public void testCallFromCamel() {
+ // get camel context
+ CamelContext context = (CamelContext)
applicationContext.getBean("conduit_context");
+ ProducerTemplate producer = context.createProducerTemplate();
+ String response = producer.requestBody("direct://jbiStart", "Hello",
String.class);
+ assertEquals("Get a wrong response ", "echo Hello World!", response);
+ }
+
@After
public void tearDown() {
if (applicationContext != null) {
Added:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/ProxyProcessor.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/ProxyProcessor.java?rev=798864&view=auto
==============================================================================
---
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/ProxyProcessor.java
(added)
+++
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/ProxyProcessor.java
Wed Jul 29 11:56:08 2009
@@ -0,0 +1,48 @@
+/**
+ * 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.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.component.cxf.HelloService;
+import org.apache.camel.converter.IOConverter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class ProxyProcessor implements Processor {
+ private static final transient Log LOG =
LogFactory.getLog(ProxyProcessor.class);
+
+ private HelloService proxy;
+
+ public void setHelloService(HelloService service) {
+ proxy = service;
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ Message in = exchange.getIn();
+ String request = in.getBody(String.class);
+ LOG.info("Get the request " + request);
+ // the jbi service processor will ignore the parameter
+ String response = proxy.echo(request);
+ LOG.info("Get the response " + response);
+ exchange.getOut().setBody(response);
+
+ }
+
+}
Propchange:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/ProxyProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/ProxyProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelJBIClientProxy.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelJBIClientProxy.xml?rev=798864&r1=798863&r2=798864&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelJBIClientProxy.xml
(original)
+++
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelJBIClientProxy.xml
Wed Jul 29 11:56:08 2009
@@ -35,8 +35,12 @@
<camelContext id="conduit_context"
xmlns="http://camel.apache.org/schema/spring">
<route>
- <from uri="direct://start" />
- <process ref="myProcessor" />
+ <from uri="direct://jbiStart"/>
+ <process ref="proxyProcessor"/>
+ </route>
+ <route>
+ <from uri="direct://jbiService" />
+ <process ref="serviceProcessor" />
</route>
</camelContext>
@@ -44,11 +48,15 @@
<camel:camelContextRef>conduit_context</camel:camelContextRef>
</camel:conduit>
- <bean id="myProcessor"
class="org.apache.camel.component.cxf.transport.JbiServiceProcessor"/>
+ <bean id="proxyProcessor"
class="org.apache.camel.component.cxf.transport.ProxyProcessor">
+ <property name="helloService" ref="client"/>
+ </bean>
+
+ <bean id="serviceProcessor"
class="org.apache.camel.component.cxf.transport.JbiServiceProcessor"/>
<simple:client id="client"
serviceClass="org.apache.camel.component.cxf.HelloService"
- address="camel://direct://start"
+ address="camel://direct://jbiService"
serviceName="s:service"
xmlns:s="http://cxf.component.camel.apache.org"
endpointName="s:portA"
@@ -56,15 +64,4 @@
transportId="http://cxf.apache.org/transports/camel">
</simple:client>
-
-
- <!-- simple:server id="server"
- serviceClass="org.apache.camel.component.cxf.HelloServiceImpl"
- address="camel://direct://end"
- serviceName="s:service"
- xmlns:s="http://camel.apache.org/camel-test"
- endpointName="s:portA"
- bindingId="http://cxf.apache.org/bindings/jbi"
- transportId="http://cxf.apache.org/transports/camel">
- </simple:server -->
</beans>