Author: ningjiang
Date: Sat May 3 20:41:40 2008
New Revision: 653177
URL: http://svn.apache.org/viewvc?rev=653177&view=rev
Log:
CAMEL-487, CAMEL488 Did some improvement on camel-cxf component
Added:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java
(with props)
Modified:
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
Modified:
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java?rev=653177&r1=653176&r2=653177&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
(original)
+++
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
Sat May 3 20:41:40 2008
@@ -165,6 +165,15 @@
}
} else {
result = cxfExchange.getOut().getBody();
+ if (result != null) {
+ if (result instanceof MessageContentsList || result instanceof
List || result.getClass().isArray()) {
+ return result;
+ } else {
+ MessageContentsList resList = new MessageContentsList();
+ resList.add(result);
+ return resList;
+ }
+ }
}
return result;
}
Modified:
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java?rev=653177&r1=653176&r2=653177&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java
(original)
+++
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java
Sat May 3 20:41:40 2008
@@ -83,7 +83,6 @@
CxfMessage out = exchange.getOut();
if (response != null) {
out.setMessage(response);
- out.setBody(response.getContent(InputStream.class));
}
}
Modified:
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java?rev=653177&r1=653176&r2=653177&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
(original)
+++
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
Sat May 3 20:41:40 2008
@@ -42,6 +42,7 @@
private String serviceName;
private String dataFormat;
private String beanId;
+ private boolean isWrapped;
private boolean isSpringContextEndpoint;
private boolean inOut = true;
private ConfigurerImpl configurer;
@@ -143,6 +144,14 @@
this.inOut = inOut;
}
+ public boolean isWrapped() {
+ return isWrapped;
+ }
+
+ public void setWrapped(boolean wrapped) {
+ isWrapped = wrapped;
+ }
+
public CxfComponent getComponent() {
return component;
Modified:
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java?rev=653177&r1=653176&r2=653177&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
(original)
+++
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
Sat May 3 20:41:40 2008
@@ -188,10 +188,18 @@
try {
Object[] result = null;
if (operationNameSpace == null) {
- result = client.invoke(operationName,
parameters.toArray());
+ if (endpoint.isWrapped()) {
+ result = client.invokeWrapped(operationName,
parameters.toArray());
+ }else {
+ result = client.invoke(operationName,
parameters.toArray());
+ }
} else {
QName operation = new QName(operationNameSpace,
operationName);
- result = client.invoke(operation,
parameters.toArray());
+ if (endpoint.isWrapped()) {
+ result = client.invokeWrapped(operation,
parameters.toArray());
+ } else {
+ result = client.invoke(operation,
parameters.toArray());
+ }
}
response.setContent(Object[].class, result);
CxfBinding.storeCxfResponse(exchange, response);
Added:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java?rev=653177&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java
(added)
+++
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java
Sat May 3 20:41:40 2008
@@ -0,0 +1,80 @@
+/**
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.frontend.ClientFactoryBean;
+import org.apache.cxf.frontend.ClientProxyFactoryBean;
+
+
+public class CxfConsumerTest extends ContextTestSupport {
+ private static final transient Log LOG =
LogFactory.getLog(CxfProducerRouterTest.class);
+ private static final String SIMPLE_ENDPOINT_ADDRESS =
"http://localhost:28080/test";
+ private static final String SIMPLE_ENDPOINT_URI = "cxf://" +
SIMPLE_ENDPOINT_ADDRESS
+ +
"?serviceClass=org.apache.camel.component.cxf.HelloService";
+ private static final String ECHO_OPERATION = "echo";
+ private static final String TEST_MESSAGE = "Hello World!";
+
+ // START SNIPPET: example
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from(SIMPLE_ENDPOINT_URI).process(new Processor() {
+ public void process(final Exchange exchange) {
+ Message in = exchange.getIn();
+ // Get the parameter list
+ List parameter = in.getBody(List.class);
+ // Get the operation name
+ String operation =
(String)in.getHeader(CxfConstants.OPERATION_NAME);
+ String result = operation + " " +
(String)parameter.get(0);
+ // Put the result back
+ exchange.getOut().setBody(result);
+ }
+ });
+ }
+ };
+ }
+ // END SNIPPET: example
+
+ public void testInvokingServiceFromCXFClient() throws Exception {
+ ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
+ ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
+ clientBean.setAddress(SIMPLE_ENDPOINT_ADDRESS);
+ clientBean.setServiceClass(HelloService.class);
+ clientBean.setBus(BusFactory.getDefaultBus());
+
+ HelloService client = (HelloService) proxyFactory.create();
+
+ String result = client.echo("hello world");
+ assertEquals("we should get the right answer from router", result,
"echo hello world");
+
+ }
+
+
+
+}
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date