camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r772537 - in /camel/trunk/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/ main/java/org/apache/camel/component/cxf/transport/ main/java/org/apache/camel/component/cxf/util/ test/java/org/apache/camel/component/cxf/
Date Thu, 07 May 2009 08:00:22 GMT
Author: ningjiang
Date: Thu May  7 08:00:14 2009
New Revision: 772537

URL: http://svn.apache.org/viewvc?rev=772537&view=rev
Log:
CAMEL-1589 clean up the CamelTransportConstants.CONTENT_TYPE

Modified:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfHeaderFilterStrategy.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelTransportConstants.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfHeaderHelper.java
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfHeaderFilterStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfHeaderFilterStrategy.java?rev=772537&r1=772536&r2=772537&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfHeaderFilterStrategy.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfHeaderFilterStrategy.java
Thu May  7 08:00:14 2009
@@ -63,11 +63,10 @@
         getOutFilter().add(Message.PROTOCOL_HEADERS);
         getInFilter().add(Message.PROTOCOL_HEADERS);
         
-        // Since the DefaultCxfBinding deal with the content-type separately.
-        // We need to filter this header
+        // Since CXF can take the content-type from the protocol header
+        // we need to filter this header of this name.
         getOutFilter().add("content-type");
-        getInFilter().add("content-type");
-        
+                        
         // initialize message header filter map with default SOAP filter
         messageHeaderFiltersMap = new HashMap<String, MessageHeaderFilter>();
         addToMessageHeaderFilterMap(new SoapMessageHeaderFilter());

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java?rev=772537&r1=772536&r2=772537&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
Thu May  7 08:00:14 2009
@@ -214,7 +214,7 @@
         Map<String, Object> camelHeaders = camelExchange.getOut().getHeaders();
         extractInvocationContextFromCamel(camelExchange, camelHeaders, 
                 responseContext, Client.RESPONSE_CONTEXT);
-      
+        
         propagateHeadersFromCamelToCxf(camelExchange, camelHeaders, cxfExchange, 
                 responseContext);
         // create out message
@@ -228,7 +228,7 @@
         // propagate contexts
         if (dataFormat != DataFormat.POJO) {
             // copying response context to out message seems to cause problem in POJO mode
-            outMessage.putAll(responseContext);
+            outMessage.putAll(responseContext);            
         }
         outMessage.put(Client.RESPONSE_CONTEXT, responseContext);      
         
@@ -360,19 +360,10 @@
             }
         }
 
-        // propagate content type
-        String key = Message.CONTENT_TYPE;
-        Object value = cxfMessage.get(key);
-        if (value != null && !headerFilterStrategy.applyFilterToExternalHeaders(key,
value, exchange)) {
-            camelHeaders.put(CamelTransportConstants.CONTENT_TYPE, value);
-            if (LOG.isTraceEnabled()) {
-                LOG.trace("Populate header from CXF header=" + key + " value=" + value);
-            }
-        }
         
         // propagate SOAP/protocol header list
-        key = Header.HEADER_LIST;
-        value = cxfMessage.get(key);
+        String key = Header.HEADER_LIST;
+        Object value = cxfMessage.get(key);
         if (value != null) {
             if (!headerFilterStrategy.applyFilterToExternalHeaders(key, value, exchange))
{
                 camelHeaders.put(key, value);
@@ -414,12 +405,6 @@
                 LOG.trace("Propagate to CXF header: " + entry.getKey() + " value: " + entry.getValue());
             }
             
-            // put content type in exchange
-            if (CamelTransportConstants.CONTENT_TYPE.equals(entry.getKey())) {
-                cxfExchange.put(Message.CONTENT_TYPE, entry.getValue());
-                continue;
-            }
-            
             // put response code in request context so it will be copied to CXF message's
property
             if (Message.RESPONSE_CODE.equals(entry.getKey())) {
                 cxfContext.put(entry.getKey(), entry.getValue());

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelTransportConstants.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelTransportConstants.java?rev=772537&r1=772536&r2=772537&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelTransportConstants.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelTransportConstants.java
Thu May  7 08:00:14 2009
@@ -46,8 +46,7 @@
     public static final String CAMEL_SERVER_CONFIG_ID = "camel-server";
     public static final String CAMEL_REBASED_REPLY_TO = "org.apache.cxf.camel.server.replyto";
     public static final String CAMEL_CORRELATION_ID = "org.apache.cxf.camel.correlationId";
-    public static final String CONTENT_TYPE = "content.type";
-
+    
     private CamelTransportConstants() {
         // Utility class
     }

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfHeaderHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfHeaderHelper.java?rev=772537&r1=772536&r2=772537&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfHeaderHelper.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfHeaderHelper.java
Thu May  7 08:00:14 2009
@@ -42,11 +42,11 @@
     }
 
     /**
-     * Progagates Camel headers to CXF message.
+     * Propagates Camel headers to CXF message.
      *
      * @param strategy header filter strategy
      * @param headers Camel header
-     * @param message CXF meassage
+     * @param message CXF message
      * @param exchange provides context for filtering
      */
     public static void propagateCamelToCxf(HeaderFilterStrategy strategy,
@@ -64,9 +64,7 @@
             if (strategy != null
                     && !strategy.applyFilterToCamelHeaders(entry.getKey(), entry.getValue(),
exchange)) {
 
-                if (CamelTransportConstants.CONTENT_TYPE.equals(entry.getKey())) {
-                    message.put(Message.CONTENT_TYPE, entry.getValue());
-                } else if (Client.REQUEST_CONTEXT.equals(entry.getKey())
+                if (Client.REQUEST_CONTEXT.equals(entry.getKey())
                             || Client.RESPONSE_CONTEXT.equals(entry.getKey())
                             || Message.RESPONSE_CODE.equals(entry.getKey())) {
                     message.put(entry.getKey(), entry.getValue());
@@ -97,16 +95,9 @@
             }
         }
 
-        // propagate content type
-        String key = Message.CONTENT_TYPE;
-        Object value = message.get(key);
-        if (value != null && !strategy.applyFilterToExternalHeaders(key, value, exchange))
{
-            headers.put(CamelTransportConstants.CONTENT_TYPE, value);
-        }
-
         // propagate request context
-        key = Client.REQUEST_CONTEXT;
-        value = message.get(key);
+        String key = Client.REQUEST_CONTEXT;
+        Object value = message.get(key);
         if (value != null && !strategy.applyFilterToExternalHeaders(key, value, exchange))
{
             headers.put(key, value);
         }

Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java?rev=772537&r1=772536&r2=772537&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
(original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
Thu May  7 08:00:14 2009
@@ -46,7 +46,7 @@
         Map protocalHeaders = (Map) context.get("org.apache.cxf.message.Message.PROTOCOL_HEADERS");
         assertEquals("Should get the content type", protocalHeaders.get("content-type").toString(),
"[text/xml; charset=utf-8]");
         assertEquals("Should get the response code ", context.get("org.apache.cxf.message.Message.RESPONSE_CODE"),
200);        
-        assertEquals("Should get the content type", result.assertExchangeReceived(0).getIn().getHeaders().get("content.type"),
"text/xml; charset=utf-8");        
+        assertEquals("Should get the content type", result.assertExchangeReceived(0).getIn().getHeaders().get("content-type"),
"text/xml; charset=utf-8");        
     }
     
     public void testTheContentTypeOnTheWire() throws Exception {
@@ -60,9 +60,9 @@
             }
 
         });
-        
-        assertNotNull("We should get the content type here", exchange.getOut().getHeader("Content-Type"));
+        assertNotNull("We should get the Content-Type here", exchange.getOut().getHeader("Content-Type"));
         assertEquals("Get wrong content type", "text/xml; charset=utf-8", exchange.getOut().getHeader("Content-Type"));
+        assertNull("We should not get the content-type here", exchange.getOut().getHeader("content-type"));
       
         String response = exchange.getOut().getBody(String.class);        
         assertNotNull("Response should not be null", response);
         assertTrue("We should get right return result", response.indexOf("echo hello world")
> 0);



Mime
View raw message