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 2008/02/12 14:57:37 UTC
svn commit: r620805 - in /activemq/camel/trunk:
camel-core/src/main/java/org/apache/camel/impl/
components/camel-cxf/src/main/java/org/apache/camel/component/cxf/
components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/
Author: ningjiang
Date: Tue Feb 12 05:57:34 2008
New Revision: 620805
URL: http://svn.apache.org/viewvc?rev=620805&view=rev
Log:
CAMEL-329 Got the cxf bus work in the camel spring context
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponentResolver.java
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointBeans.xml
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponentResolver.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponentResolver.java?rev=620805&r1=620804&r2=620805&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponentResolver.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponentResolver.java Tue Feb 12 05:57:34 2008
@@ -53,9 +53,7 @@
if (bean instanceof Component) {
return (Component) bean;
}
- else {
- throw new IllegalArgumentException("Bean with name: " + name + " in registry is not a Component: " + bean);
- }
+ // we do not throw the exception here and try to auto create a component
}
Class type;
try {
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=620805&r1=620804&r2=620805&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 Tue Feb 12 05:57:34 2008
@@ -56,9 +56,9 @@
* @param inMessage
* @return outMessage
*/
- public Message invoke(Message inMessage) {
+ public Message invoke(Message inMessage) {
Exchange exchange = inMessage.getExchange();
-
+
//Set Request Context into CXF Message
Map<String, Object> ctxContainer = new HashMap<String, Object>();
Map<String, Object> requestCtx = new HashMap<String, Object>();
@@ -68,23 +68,23 @@
CxfExchange cxfExchange = endpoint.createExchange(inMessage);
try {
cxfConsumer.getProcessor().process(cxfExchange);
- } catch (Exception e) {
+ } catch (Exception ex) {
// catch the exception and send back to cxf client
- e.printStackTrace();
+ throw new Fault(ex);
}
-
+
// make sure the client has retrun back the message
Message outMessage = getCxfMessage(cxfExchange, exchange);
-
+
//Set Response Context into CXF Message
/*ctxContainer = (Map<String, Object>)outMessage.getProperty(CxfMessageAdapter.REQ_RESP_CONTEXT);
Map<String, Object> respCtx = (Map<String, Object>)ctxContainer.get(Client.RESPONSE_CONTEXT);
updateContext(respCtx, outMessage);*/
-
+
return outMessage;
}
-
- public Message getCxfMessage(CxfExchange result, Exchange exchange) {
+
+ public Message getCxfMessage(CxfExchange result, Exchange exchange) {
Message outMessage = null;
if (result.isFailed()) {
CxfMessage fault = result.getFault();
@@ -104,15 +104,15 @@
// get the payload message
outMessage = result.getOutMessage();
if (outMessage == null) {
- Endpoint ep = exchange.get(Endpoint.class);
+ Endpoint ep = exchange.get(Endpoint.class);
outMessage = ep.getBinding().createMessage();
exchange.setOutMessage(outMessage);
}
}
-
+
return outMessage;
}
-
+
@SuppressWarnings("unchecked")
public void updateContext(Map<String, Object> from, Map<String, Object> to) {
if (to != null && from != null) {
@@ -139,7 +139,7 @@
*/
public Object invoke(Exchange exchange, Object o) {
BindingOperationInfo bop = exchange.get(BindingOperationInfo.class);
- MethodDispatcher md = (MethodDispatcher)
+ MethodDispatcher md = (MethodDispatcher)
exchange.get(Service.class).get(MethodDispatcher.class.getName());
Method m = md.getMethod(bop);
List<Object> params = new ArrayList<Object>();
@@ -148,9 +148,9 @@
} else if (o != null) {
params = new MessageContentsList(o);
}
-
+
CxfEndpoint endpoint = (CxfEndpoint) cxfConsumer.getEndpoint();
-
+
CxfExchange cxfExchange = endpoint.createExchange(exchange.getInMessage());
if (bop.getOperationInfo().isOneWay()) {
cxfExchange.setPattern(ExchangePattern.InOnly);
@@ -159,16 +159,15 @@
}
cxfExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, m.getName());
cxfExchange.getIn().setBody(params);
-
-
+
+
try {
cxfConsumer.getProcessor().process(cxfExchange);
- } catch (Exception e) {
+ } catch (Exception ex) {
// catch the exception and send back to cxf client
- e.printStackTrace();
+ throw new Fault(ex);
}
-
- //TODO deal with the fault message
+
Object result;
if (cxfExchange.isFailed()) {
Exception ex= (Exception)cxfExchange.getFault().getBody();
@@ -179,9 +178,9 @@
return (Object[])result;
}
}
-
+
return result;
-
+
}
}
Modified: activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointBeans.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointBeans.xml?rev=620805&r1=620804&r2=620805&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointBeans.xml (original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointBeans.xml Tue Feb 12 05:57:34 2008
@@ -18,29 +18,34 @@
<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"
-
+
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/camel/schema/cxfEndpoint http://activemq.apache.org/camel/schema/cxf/cxfEndpoint.xsd
http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
">
+ <import resource="classpath:META-INF/cxf/cxf.xml"/>
+ <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
+ <import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml" />
+ <!-- Added the import for testing the CAMEL-329 -->
+
- <cxf:cxfEndpoint id="routerEndpoint" address="http://localhost:9003/CamelContext/RouterPort"
+ <cxf:cxfEndpoint id="routerEndpoint" address="http://localhost:9003/CamelContext/RouterPort"
serviceClass="org.apache.hello_world_soap_http.GreeterImpl"/>
-
- <cxf:cxfEndpoint id="serviceEndpoint" address="http://localhost:9000/SoapContext/SoapPort"
+
+ <cxf:cxfEndpoint id="serviceEndpoint" address="http://localhost:9000/SoapContext/SoapPort"
wsdlURL="testutils/hello_world.wsdl"
serviceClass="org.apache.hello_world_soap_http.Greeter"
endpointName="s:SoapPort"
serviceName="s:SOAPService"
xmlns:s="http://apache.org/hello_world_soap_http" />
-
+
<camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="cxf:bean:routerEndpoint" />
- <to uri="cxf:bean:serviceEndpoint" />
+ <to uri="cxf:bean:serviceEndpoint" />
</route>
- </camelContext>
-
+ </camelContext>
+
</beans>