camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r570472 - in /activemq/camel/trunk: ./ components/camel-cxf/ components/camel-cxf/src/main/java/org/apache/camel/component/cxf/ components/camel-cxf/src/main/resources/META-INF/services/org/apache/camel/component/ components/camel-cxf/src/t...
Date Tue, 28 Aug 2007 16:21:55 GMT
Author: jstrachan
Date: Tue Aug 28 09:21:52 2007
New Revision: 570472

URL: http://svn.apache.org/viewvc?rev=570472&view=rev
Log:
applied patch for CAMEL-118 with thanks Willem!

Added:
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
  (with props)
Removed:
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfInvokeComponent.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfInvokeConsumer.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfInvokeEndpoint.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfInvokeProducer.java
    activemq/camel/trunk/components/camel-cxf/src/main/resources/META-INF/services/org/apache/camel/component/cxf-invoke
    activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfInvokeTest.java
Modified:
    activemq/camel/trunk/components/camel-cxf/pom.xml
    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/CxfComponent.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConstants.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.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
    activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/HelloServiceImpl.java
    activemq/camel/trunk/pom.xml

Modified: activemq/camel/trunk/components/camel-cxf/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/pom.xml?rev=570472&r1=570471&r2=570472&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/pom.xml (original)
+++ activemq/camel/trunk/components/camel-cxf/pom.xml Tue Aug 28 09:21:52 2007
@@ -40,6 +40,12 @@
     </dependency>
 
     <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+      <type>test-jar</type>
+    </dependency>
+
+    <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging-api</artifactId>
     </dependency>
@@ -57,7 +63,7 @@
     </dependency>
     <dependency>
       <groupId>org.apache.cxf</groupId>
-      <artifactId>cxf-rt-transports-local</artifactId>
+      <artifactId>cxf-rt-transports-http</artifactId>
       <version>${cxf-version}</version>
     </dependency>
     <dependency>

Added: 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=570472&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
(added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
Tue Aug 28 09:21:52 2007
@@ -0,0 +1,75 @@
+/**
+ * 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.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cxf.frontend.MethodDispatcher;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.MessageContentsList;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.invoker.AbstractInvoker;
+import org.apache.cxf.service.invoker.Invoker;
+import org.apache.cxf.service.model.BindingOperationInfo;
+
+public class CamelInvoker implements Invoker  {
+    private CxfConsumer cxfConsumer;
+    public CamelInvoker(CxfConsumer consumer) {
+        cxfConsumer = consumer;
+    }
+
+    public Object invoke(Exchange exchange, Object o) {
+        BindingOperationInfo bop = exchange.get(BindingOperationInfo.class);
+        MethodDispatcher md = (MethodDispatcher) 
+            exchange.get(Service.class).get(MethodDispatcher.class.getName());
+        Method m = md.getMethod(bop);
+        
+        List<Object> params = null;
+        if (o instanceof List) {
+            params = CastUtils.cast((List<?>)o);
+        } else if (o != null) {
+            params = new MessageContentsList(o);
+        }
+        
+        final List<Object> messageBody = new ArrayList<Object>(params.size()+1);
+        messageBody.add(m.getName());
+        for (Object obj: params) {
+            messageBody.add(obj);
+        }  
+        
+        CxfEndpoint endpoint = (CxfEndpoint) cxfConsumer.getEndpoint();
+        CxfExchange cxfExchange = endpoint.createExchange(exchange.getInMessage());
+        cxfExchange.getIn().setBody(messageBody);
+        
+        
+        try {
+            cxfConsumer.getProcessor().process(cxfExchange);
+        } catch (Exception e) {
+            // catch the exception and send back to cxf client
+            e.printStackTrace();
+        }
+        System.out.println(cxfExchange.getOut().getBody());
+        //TODO deal with the paraments that contains holders
+        Object[] result = (Object[])cxfExchange.getOut().getBody();
+        return result;
+        
+    }
+
+}

Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=570472&r1=570471&r2=570472&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
Tue Aug 28 09:21:52 2007
@@ -20,6 +20,7 @@
 import org.apache.cxf.message.MessageImpl;
 
 import java.io.InputStream;
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -35,7 +36,7 @@
 
     protected Object getBody(Message message) {
         Set<Class<?>> contentFormats = message.getContentFormats();
-        for (Class<?> contentFormat : contentFormats) {
+        for (Class<?> contentFormat : contentFormats) {            
             Object answer = message.getContent(contentFormat);
             if (answer != null) {
                 return answer;
@@ -51,21 +52,20 @@
         // the CXF transport is also based on the stream API.
         // And the interceptors are also based on the stream API,
         // so lets use an InputStream to host the CXF on wire message.
+
         CxfMessage in = exchange.getIn();
         Object body = in.getBody(InputStream.class);
         if (body == null) {
             body = in.getBody();
         }
-        answer.setContent(InputStream.class, body);
-
-        // no need to process headers as we reuse the CXF message
-        /*
-        // set the headers
-        Set<Map.Entry<String, Object>> entries = in.getHeaders().entrySet();
-        for (Map.Entry<String, Object> entry : entries) {
-            answer.put(entry.getKey(), entry.getValue());
+        if (body instanceof InputStream) {
+        	answer.setContent(InputStream.class, body);
+        } else if (body instanceof List) {
+        	//just set the operation's parament
+        	answer.setContent(List.class, body);
         }
-        */
+        
+        
         return answer;
     }
 

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java?rev=570472&r1=570471&r2=570472&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
Tue Aug 28 09:21:52 2007
@@ -16,19 +16,13 @@
  */
 package org.apache.camel.component.cxf;
 
-import java.net.URI;
 import java.util.Map;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.DefaultComponent;
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusException;
-import org.apache.cxf.bus.CXFBusFactory;
-import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.transport.DestinationFactoryManager;
-import org.apache.cxf.transport.local.LocalTransportFactory;
-import org.xmlsoap.schemas.wsdl.http.AddressType;
+import org.apache.camel.util.IntrospectionSupport;
+
 
 /**
  * Defines the <a href="http://activemq.apache.org/camel/cxf.html">CXF Component</a>
@@ -36,7 +30,7 @@
  * @version $Revision$
  */
 public class CxfComponent extends DefaultComponent<CxfExchange> {
-    private LocalTransportFactory localTransportFactory;
+	
 
     public CxfComponent() {
     }
@@ -47,34 +41,11 @@
 
     @Override
     protected Endpoint<CxfExchange> createEndpoint(String uri, String remaining, Map
parameters) throws Exception {
-        URI u = new URI(remaining);
-
-        // TODO this is a hack!!!
-        EndpointInfo endpointInfo = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http");
-        AddressType a = new AddressType();
-        a.setLocation(remaining);
-        endpointInfo.addExtensor(a);
-
-        return new CxfEndpoint(uri, this, endpointInfo);
-    }
-
-    public LocalTransportFactory getLocalTransportFactory() throws BusException {
-        if (localTransportFactory == null) {
-            localTransportFactory = findLocalTransportFactory();
-            if (localTransportFactory == null) {
-                localTransportFactory = new LocalTransportFactory();
-            }
-        }
-        return localTransportFactory;
-    }
-
-    public void setLocalTransportFactory(LocalTransportFactory localTransportFactory) {
-        this.localTransportFactory = localTransportFactory;
+        // now we need to add the address, endpoint name, wsdl url or the SEI to build up
a endpoint
+        CxfEndpoint result = new CxfEndpoint(uri, remaining, this);        
+        IntrospectionSupport.setProperties(result, parameters);
+        return result;
     }
 
-    protected LocalTransportFactory findLocalTransportFactory() throws BusException {
-        Bus bus = CXFBusFactory.getDefaultBus();
-        DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
-        return (LocalTransportFactory) dfm.getDestinationFactory(LocalTransportFactory.TRANSPORT_ID);
-    }
+    
 }

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConstants.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConstants.java?rev=570472&r1=570471&r2=570472&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConstants.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConstants.java
Tue Aug 28 09:21:52 2007
@@ -25,5 +25,11 @@
     String METHOD = "method";
     String SEI = "sei";
     String IMPL = "impl";
+    String WSDL_URL = "wsdlURL";
+    String ADDRESS = "address";
+    String SERVICE_NAME = "serviceName";
+    String PORT_NAME = "portName";
+    // service name -- come from the wsdl   
 }
+
 

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java?rev=570472&r1=570471&r2=570472&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
Tue Aug 28 09:21:52 2007
@@ -18,10 +18,12 @@
 
 import org.apache.camel.Processor;
 import org.apache.camel.impl.DefaultConsumer;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.frontend.ServerFactoryBean;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.transport.Destination;
 import org.apache.cxf.transport.MessageObserver;
-import org.apache.cxf.transport.local.LocalTransportFactory;
+
 
 /**
  * A consumer of exchanges for a service in CXF
@@ -29,44 +31,41 @@
  * @version $Revision$
  */
 public class CxfConsumer extends DefaultConsumer<CxfExchange> {
-    private CxfEndpoint endpoint;
-    private final LocalTransportFactory transportFactory;
+    private CxfEndpoint endpoint;    
+    private Server server;
     private Destination destination;
 
-    public CxfConsumer(CxfEndpoint endpoint, Processor processor, LocalTransportFactory transportFactory)
{
+    public CxfConsumer(CxfEndpoint endpoint, Processor processor) throws ClassNotFoundException
{
+       
         super(endpoint, processor);
+        System.out.println(processor.toString());
         this.endpoint = endpoint;
-        this.transportFactory = transportFactory;
+        //we setup the interceptors by the endpoint configuration
+        //create server here, now we just use the simple front-end        
+        ServerFactoryBean svrBean = new ServerFactoryBean();
+        Class serviceClass = Class.forName(endpoint.getServiceClass());        
+        svrBean.setAddress(endpoint.getAddress());
+        svrBean.setServiceClass(serviceClass);
+        if (endpoint.isInvoker()) {
+            System.out.println("setup the invoker ");
+            svrBean.setInvoker(new CamelInvoker(this));
+        }    
+        svrBean.setStart(false);
+        server = svrBean.create();
     }
 
     @Override
     protected void doStart() throws Exception {
-        super.doStart();
-
-        destination = transportFactory.getDestination(endpoint.getEndpointInfo());
-        destination.setMessageObserver(new MessageObserver() {
-            public void onMessage(Message message) {
-                incomingCxfMessage(message);
-            }
-        });
+        super.doStart();        
+        
+        server.start();
     }
 
     @Override
     protected void doStop() throws Exception {
-        if (destination != null) {
-            destination.shutdown();
-        }
+        server.stop();
         super.doStop();
     }
 
-    protected void incomingCxfMessage(Message message) {
-        try {
-            CxfExchange exchange = endpoint.createExchange(message);
-            getProcessor().process(exchange);
-        } catch (Exception e) {
-            // TODO: what do do if we are getting processing errors from camel?
-            // Shutdown?
-            e.printStackTrace();
-        }
-    }
+    
 }

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=570472&r1=570471&r2=570472&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
Tue Aug 28 09:21:52 2007
@@ -16,38 +16,44 @@
  */
 package org.apache.camel.component.cxf;
 
+import javax.xml.namespace.QName;
+
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.impl.DefaultEndpoint;
-import org.apache.cxf.BusException;
+import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.message.Message;
-import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.transport.local.LocalTransportFactory;
+
 
 /**
  * Defines the <a href="http://activemq.apache.org/camel/cxf.html">CXF Endpoint</a>
  * 
  * @version $Revision$
  */
-public class CxfEndpoint extends DefaultEndpoint<CxfExchange> {
-    private CxfBinding binding;
+public class CxfEndpoint extends DefaultEndpoint<CxfExchange> {    
     private final CxfComponent component;
-    private final EndpointInfo endpointInfo;
+    private final String address;
+    private String wsdlURL;
+    private String serviceClass;
+    private CxfBinding binding;
+    private QName portName;
+    private QName serviceName;
     private boolean inOut = true;
+    private boolean invoker = true;
 
-    public CxfEndpoint(String uri, CxfComponent component, EndpointInfo endpointInfo) {
+    public CxfEndpoint(String uri, String address, CxfComponent component) {
         super(uri, component);
-        this.component = component;
-        this.endpointInfo = endpointInfo;
+        this.component = component;        
+        this.address = address;
     }
-
+        
     public Producer<CxfExchange> createProducer() throws Exception {
-        return new CxfProducer(this, getLocalTransportFactory());
+        return new CxfProducer(this);
     }
 
     public Consumer<CxfExchange> createConsumer(Processor processor) throws Exception
{
-        return new CxfConsumer(this, processor, getLocalTransportFactory());
+        return new CxfConsumer(this, processor);
     }
 
     public CxfExchange createExchange() {
@@ -57,6 +63,50 @@
     public CxfExchange createExchange(Message inMessage) {
         return new CxfExchange(getContext(), getBinding(), inMessage);
     }
+    
+    public boolean isInvoker() {
+        return invoker;
+    }
+    
+    public void setInvoker(boolean invoker) {
+        this.invoker = invoker;
+    }
+    
+    public String getAddress() {
+    	return address;
+    }
+    
+    public String getWsdlURL() {
+    	return wsdlURL;
+    }
+    
+    public void setWsdlURL(String url) {
+        wsdlURL = url;
+    }
+    
+    public String getServiceClass() {
+    	return serviceClass;
+    }
+    
+    public void setServiceClass(String className) {        
+        serviceClass = className;
+    }
+    
+    public void setPortName(QName port) {
+        portName = port;
+    }
+    
+    public void setServiceName(QName service) {
+        serviceName = service;
+    }
+    
+    public QName getPortName(){
+        return portName;
+    }
+    
+    public QName getServiceName() {
+        return serviceName;
+    }
 
     public CxfBinding getBinding() {
         if (binding == null) {
@@ -77,14 +127,7 @@
         this.inOut = inOut;
     }
 
-    public LocalTransportFactory getLocalTransportFactory() throws BusException {
-        return component.getLocalTransportFactory();
-    }
-
-    public EndpointInfo getEndpointInfo() {
-        return endpointInfo;
-    }
-
+   
     public CxfComponent getComponent() {
         return component;
     }
@@ -92,5 +135,7 @@
     public boolean isSingleton() {
         return true;
     }
+    
+    
 
 }

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=570472&r1=570471&r2=570472&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
Tue Aug 28 09:21:52 2007
@@ -16,21 +16,42 @@
  */
 package org.apache.camel.component.cxf;
 
+import com.ibm.wsdl.extensions.soap.SOAPBindingImpl;
+
 import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
 import java.util.concurrent.CountDownLatch;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.impl.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.ClientImpl;
+import org.apache.cxf.frontend.ClientFactoryBean;
+import org.apache.cxf.frontend.ClientProxyFactoryBean;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.transport.Conduit;
 import org.apache.cxf.transport.Destination;
 import org.apache.cxf.transport.MessageObserver;
-import org.apache.cxf.transport.local.LocalConduit;
-import org.apache.cxf.transport.local.LocalTransportFactory;
+import org.apache.cxf.wsdl11.WSDLServiceFactory;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.concurrent.CountDownLatch;
+
+import javax.xml.namespace.QName;
+
 
 /**
  * Sends messages from Camel into the CXF endpoint
@@ -39,17 +60,33 @@
  */
 public class CxfProducer extends DefaultProducer {
     private CxfEndpoint endpoint;
-    private final LocalTransportFactory transportFactory;
-    private Destination destination;
+    private Client client;    
     private Conduit conduit;
-    private ResultFuture future = new ResultFuture();
+    
 
-    public CxfProducer(CxfEndpoint endpoint, LocalTransportFactory transportFactory) {
+    public CxfProducer(CxfEndpoint endpoint) throws MalformedURLException {
         super(endpoint);
         this.endpoint = endpoint;
-        this.transportFactory = transportFactory;
+        client = createClient();
     }
-
+    
+    private Client createClient() throws MalformedURLException {
+        Bus bus = BusFactory.getDefaultBus();
+        // setup the ClientFactoryBean with endpoint
+        ClientFactoryBean cfb = new ClientFactoryBean();
+        cfb.setBus(bus);
+        cfb.setAddress(endpoint.getAddress());
+        if (null != endpoint.getServiceClass()) {            
+            cfb.setServiceClass(ObjectHelper.loadClass(endpoint.getServiceClass()));
+        }
+        if (null != endpoint.getWsdlURL()) {
+            cfb.setWsdlURL(endpoint.getWsdlURL());
+        }       
+        // there may other setting work
+        // create client 
+        return cfb.create();
+    }
+   
     public void process(Exchange exchange) {
         CxfExchange cxfExchange = endpoint.toExchangeType(exchange);
         process(cxfExchange);
@@ -59,70 +96,40 @@
         try {
             CxfBinding binding = endpoint.getBinding();
             MessageImpl m = binding.createCxfMessage(exchange);
-            ExchangeImpl e = new ExchangeImpl();
-            e.setInMessage(m);
-            m.put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
-            m.setDestination(destination);
-            synchronized (conduit) {
-                conduit.prepare(m);
-
-                // now lets wait for the response
-                if (endpoint.isInOut()) {
-                    Message response = future.getResponse();
-
-                    // TODO - why do we need to ignore the returned message and
-                    // get the out message from the exchange!
-                    response = e.getOutMessage();
-                    binding.storeCxfResponse(exchange, response);
-                }
-            }
-        } catch (IOException e) {
+            //InputStream is = m.getContent(InputStream.class);
+            // now we just deal with the POJO invocations 
+            List paraments = m.getContent(List.class);
+            Message response = new MessageImpl();            
+            if (paraments != null) {
+            	String operation = (String)paraments.get(0);
+            	Object[] args = new Object[paraments.size()-1];
+            	for(int i = 0 ; i < paraments.size()-1 ; i++) {            		
+            		args[i] = paraments.get(i+1);
+            	}
+            	// now we just deal with the invoking the paraments
+            	Object[] result = client.invoke(operation, args);                
+            	response.setContent(Object[].class, result);
+                binding.storeCxfResponse(exchange, response);
+            }          	
+            
+        } catch (Exception e) {
             throw new RuntimeCamelException(e);
-        }
+        }   
+                
     }
 
     @Override
     protected void doStart() throws Exception {
         super.doStart();
-        EndpointInfo endpointInfo = endpoint.getEndpointInfo();
-        destination = transportFactory.getDestination(endpointInfo);
-
-        // Set up a listener for the response
-        conduit = transportFactory.getConduit(endpointInfo);
-        conduit.setMessageObserver(future);
+                
+        client = createClient();
+        conduit = client.getConduit();
+        
     }
 
     @Override
     protected void doStop() throws Exception {
-        super.doStop();
-
-        if (conduit != null) {
-            conduit.close();
-        }
+        super.doStop();        
     }
 
-    protected class ResultFuture implements MessageObserver {
-        Message response;
-        CountDownLatch latch = new CountDownLatch(1);
-
-        public Message getResponse() {
-            while (response == null) {
-                try {
-                    latch.await();
-                } catch (InterruptedException e) {
-                    // ignore
-                }
-            }
-            return response;
-        }
-
-        public synchronized void onMessage(Message message) {
-            try {
-                message.remove(LocalConduit.DIRECT_DISPATCH);
-                this.response = message;
-            } finally {
-                latch.countDown();
-            }
-        }
-    }
 }

Modified: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/HelloServiceImpl.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/HelloServiceImpl.java?rev=570472&r1=570471&r2=570472&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/HelloServiceImpl.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/HelloServiceImpl.java
Tue Aug 28 09:21:52 2007
@@ -17,7 +17,7 @@
 package org.apache.camel.component.cxf;
 
 public class HelloServiceImpl implements HelloService {
-    public String echo(String text) {
+    public String echo(String text) {        
         return text;
     }
 
@@ -29,4 +29,5 @@
         return "hello";
     }
 }
+
 

Modified: activemq/camel/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/pom.xml?rev=570472&r1=570471&r2=570472&view=diff
==============================================================================
--- activemq/camel/trunk/pom.xml (original)
+++ activemq/camel/trunk/pom.xml Tue Aug 28 09:21:52 2007
@@ -36,7 +36,7 @@
   <properties>
     <camel-version>1.1-SNAPSHOT</camel-version>
     <compiler.fork>false</compiler.fork>
-    <cxf-version>2.0-incubator</cxf-version>
+    <cxf-version>2.0.1-incubator</cxf-version>
     <jetty-version>6.1.4</jetty-version>
     <m1-repo-url>scpexe://minotaur.apache.org/www/people.apache.org/repo/m1-snapshot-repository</m1-repo-url>
     <openjpa-version>0.9.6-incubating</openjpa-version>



Mime
View raw message