camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r950506 - in /camel/trunk/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/ test/java/org/apache/camel/component/cxf/
Date Wed, 02 Jun 2010 11:44:27 GMT
Author: ningjiang
Date: Wed Jun  2 11:44:27 2010
New Revision: 950506

URL: http://svn.apache.org/viewvc?rev=950506&view=rev
Log:
CAMEL-2780 add operationName and operationNamespace options into CxfEndpoint

Added:
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerOperationTest.java
  (with props)
Modified:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConstants.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConstants.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConstants.java?rev=950506&r1=950505&r2=950506&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConstants.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConstants.java
Wed Jun  2 11:44:27 2010
@@ -37,7 +37,7 @@ public interface CxfConstants {
     String PORT_NAMESPACE = "endpointNamespace";
     String PROTOCOL_NAME_RES = "res";
     String OPERATION_NAME = "operationName";
-    String OPERATION_NAMESPACE = "operationNameSpace";
+    String OPERATION_NAMESPACE = "operationNamespace";
     String SPRING_CONTEXT_ENDPOINT = "bean:";
     String CAMEL_TRANSPORT_PREFIX = "camel:";
     String CXF_EXCHANGE = "org.apache.cxf.message.exchange";

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java?rev=950506&r1=950505&r2=950506&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
Wed Jun  2 11:44:27 2010
@@ -80,6 +80,8 @@ public class CxfEndpoint extends Default
     private String serviceClass;
     private String portName;
     private String serviceName;
+    private String operationName;
+    private String operationNamespace;
     private DataFormat dataFormat = DataFormat.POJO;
     private boolean isWrapped;
     private boolean inOut = true;
@@ -412,6 +414,22 @@ public class CxfEndpoint extends Default
     public void setPortName(String port) {
         portName = port;
     }
+    
+    public String getOperationName() {
+        return operationName;
+    }
+    
+    public void setOperationName(String name) {
+        operationName = name;
+    }
+    
+    public String getOperationNamespace() {
+        return operationNamespace;
+    }
+    
+    public void setOperationNamespace(String namespace) {
+        operationNamespace = namespace;
+    }
 
     public boolean isInOut() {
         return inOut;

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java?rev=950506&r1=950505&r2=950506&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
Wed Jun  2 11:44:27 2010
@@ -259,10 +259,12 @@ public class CxfProducer extends Default
      * {@link BindingOperationInfo}.
      */
     private BindingOperationInfo getBindingOperationInfo(Exchange ex) {
-
+        CxfEndpoint endpoint = (CxfEndpoint)this.getEndpoint();
         BindingOperationInfo answer = null;
         String lp = ex.getIn().getHeader(CxfConstants.OPERATION_NAME, String.class);
-        
+        if (lp == null) {
+            lp = endpoint.getOperationName();
+        }
         if (lp == null) {
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Try to find a default operation.  You should set '" 
@@ -279,11 +281,14 @@ public class CxfProducer extends Default
         } else {
             String ns = ex.getIn().getHeader(CxfConstants.OPERATION_NAMESPACE, String.class);
             if (ns == null) {
+                ns = endpoint.getOperationNamespace();
+            }
+            if (ns == null) {
                 ns = client.getEndpoint().getService().getName().getNamespaceURI();
                 if (LOG.isTraceEnabled()) {
                     LOG.trace("Operation namespace not in header.  Set it to: " + ns);
                 }
-            }
+            }            
 
             QName qname = new QName(ns, lp);
 

Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerOperationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerOperationTest.java?rev=950506&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerOperationTest.java
(added)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerOperationTest.java
Wed Jun  2 11:44:27 2010
@@ -0,0 +1,89 @@
+/**
+ * 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 java.util.Map;
+import javax.xml.ws.Endpoint;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.cxf.bus.CXFBusFactory;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.hello_world_soap_http.GreeterImpl;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @version $Revision$
+ */
+public class CxfProducerOperationTest extends CxfProducerTest {
+    private static final String NAMESPACE = "http://apache.org/hello_world_soap_http";
+   
+    protected String getSimpleEndpointUri() {
+        return "cxf://" + SIMPLE_SERVER_ADDRESS
+            + "?serviceClass=org.apache.camel.component.cxf.HelloService" 
+            + "&" + CxfConstants.OPERATION_NAME + "=" + ECHO_OPERATION;
+    }
+
+    protected String getJaxwsEndpointUri() {
+        return "cxf://" + JAXWS_SERVER_ADDRESS
+            + "?serviceClass=org.apache.hello_world_soap_http.Greeter"
+            + "&" + CxfConstants.OPERATION_NAME + "=" + GREET_ME_OPERATION
+            + "&" + CxfConstants.OPERATION_NAMESPACE + "=" + NAMESPACE;
+    }
+
+    protected Exchange sendSimpleMessage() {
+        return sendSimpleMessage(getSimpleEndpointUri());
+    }
+
+    private Exchange sendSimpleMessage(String endpointUri) {
+        Exchange exchange = template.send(endpointUri, new Processor() {
+            public void process(final Exchange exchange) {
+                final List<String> params = new ArrayList<String>();
+                params.add(TEST_MESSAGE);
+                exchange.getIn().setBody(params);
+                exchange.getIn().setHeader(Exchange.FILE_NAME, "testFile");
+            }
+        });
+        return exchange;
+
+    }
+    protected Exchange sendJaxWsMessage() {
+        Exchange exchange = template.send(getJaxwsEndpointUri(), new Processor() {
+            public void process(final Exchange exchange) {
+                final List<String> params = new ArrayList<String>();
+                params.add(TEST_MESSAGE);
+                exchange.getIn().setBody(params);
+                exchange.getIn().setHeader(Exchange.FILE_NAME, "testFile");
+            }
+        });
+        return exchange;
+    }
+}

Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerOperationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerOperationTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message