Author: dkulp
Date: Thu May 17 14:46:48 2012
New Revision: 1339622

URL: http://svn.apache.org/viewvc?rev=1339622&view=rev
Log:
[CAMEL-4641] Part 1 - introduce RAW mode and deprecate MESSAGE mode

Modified:
    
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
    
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DataFormat.java
    
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsTest.java
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsWithSpringTest.java

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=1339622&r1=1339621&r2=1339622&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
 Thu May 17 14:46:48 2012
@@ -259,7 +259,7 @@ public class CxfEndpoint extends Default
         if (!CxfEndpointUtils.hasAnnotation(cls, WebServiceProvider.class)) {
             if (getDataFormat() == DataFormat.PAYLOAD) {
                 sfb.getFeatures().add(new 
PayLoadDataFormatFeature(allowStreaming));
-            } else if (getDataFormat() == DataFormat.MESSAGE) {
+            } else if (getDataFormat().dealias() == DataFormat.RAW) {
                 MessageDataFormatFeature feature = new 
MessageDataFormatFeature();
                 feature.addInIntercepters(getInInterceptors());
                 feature.addOutInterceptors(getOutInterceptors());
@@ -418,7 +418,7 @@ public class CxfEndpoint extends Default
         }
 
         // apply feature here
-        if (getDataFormat() == DataFormat.MESSAGE) {
+        if (getDataFormat().dealias() == DataFormat.RAW) {
             MessageDataFormatFeature feature = new MessageDataFormatFeature();
             feature.addInIntercepters(getInInterceptors());
             feature.addOutInterceptors(getOutInterceptors());

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=1339622&r1=1339621&r2=1339622&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
 Thu May 17 14:46:48 2012
@@ -179,7 +179,7 @@ public class CxfProducer extends Default
         requestContext.put(DataFormat.class.getName(), dataFormat);
 
         // don't let CXF ClientImpl close the input stream 
-        if (dataFormat == DataFormat.MESSAGE) {
+        if (dataFormat.dealias() == DataFormat.RAW) {
             cxfExchange.put(Client.KEEP_CONDUIT_ALIVE, true);
             LOG.trace("Set CXF Exchange property: {}={}", 
Client.KEEP_CONDUIT_ALIVE, true);
         }
@@ -303,7 +303,7 @@ public class CxfProducer extends Default
         } else if (endpoint.getDataFormat() == DataFormat.PAYLOAD) {
             params = new Object[1];
             params[0] = exchange.getIn().getMandatoryBody(CxfPayload.class);
-        } else if (endpoint.getDataFormat() == DataFormat.MESSAGE) {
+        } else if (endpoint.getDataFormat().dealias() == DataFormat.RAW) {
             params = new Object[1];
             params[0] = exchange.getIn().getMandatoryBody(InputStream.class);
         }

Modified: 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DataFormat.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DataFormat.java?rev=1339622&r1=1339621&r2=1339622&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DataFormat.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DataFormat.java
 Thu May 17 14:46:48 2012
@@ -29,18 +29,43 @@ public enum DataFormat {
      */
     PAYLOAD,
 
+
+    /**
+     * RAW is the raw message that is received from the transport layer.
+     * Streaming and non-streaming are both supported.
+     */
+    RAW,
+    
     /**
      * MESSAGE is the raw message that is received from the transport layer.
      * Streaming and non-streaming are both supported.
+     * @deprecated - equivalent to RAW mode for Camel 2.x
      */
-    MESSAGE,
+    @Deprecated
+    MESSAGE {
+        public DataFormat dealias() {
+            return RAW;
+        }
+    },
 
     /**
+     * CXF_MESSAGE is the message that is received from the transport layer
+     * and then processed through the full set of CXF interceptors.  This 
+     * provides the same functionality as the CXF MESSAGE mode providers.
+     * Streaming and non-streaming are both supported.
+     */
+    CXF_MESSAGE,    
+    
+    /**
      * POJOs (Plain old Java objects) are the Java parameters to the method
      * it is invoking on the target server.  The "serviceClass" property
      * must be included in the endpoint.  Streaming is not available for this
      * data format.
      */
-    POJO
+    POJO;
+    
+    public DataFormat dealias() {
+        return this;
+    }
     
 }

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=1339622&r1=1339621&r2=1339622&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 17 14:46:48 2012
@@ -616,7 +616,7 @@ public class DefaultCxfBinding implement
                 Map<String, String> nsMap = new HashMap<String, String>();
                 answer = new CxfPayload<SoapHeader>(headers, 
getPayloadBodyElements(message, nsMap), nsMap);
                 
-            } else if (dataFormat == DataFormat.MESSAGE) {
+            } else if (dataFormat.dealias() == DataFormat.RAW) {
                 answer = message.getContent(InputStream.class);
             }
 
@@ -720,7 +720,7 @@ public class DefaultCxfBinding implement
             answer = out.getBody();
         } else if (dataFormat == DataFormat.PAYLOAD) {
             answer = out.getBody(CxfPayload.class);
-        } else if (dataFormat == DataFormat.MESSAGE) {
+        } else if (dataFormat.dealias() == DataFormat.RAW) {
             answer = out.getBody(InputStream.class);
         }
         return answer;

Modified: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsTest.java?rev=1339622&r1=1339621&r2=1339622&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsTest.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsTest.java
 Thu May 17 14:46:48 2012
@@ -69,11 +69,26 @@ public class CxfEndpointUtilsTest extend
         assertEquals("We should get the right service name", service, 
SERVICE_NAME);
     }
 
+    public char sepChar() {
+        return '&';
+    }
+    
+    @SuppressWarnings("deprecation")
     @Test
-    public void testGetDataFormat() throws Exception {
-        CxfEndpoint endpoint = createEndpoint(getEndpointURI() + 
"&dataFormat=MESSAGE");
+    public void testGetDataFormatMessage() throws Exception {
+        CxfEndpoint endpoint = createEndpoint(getEndpointURI() + sepChar() + 
"dataFormat=MESSAGE");
         assertEquals("We should get the Message DataFormat", 
DataFormat.MESSAGE, endpoint.getDataFormat());
     }
+    @Test
+    public void testGetDataFormatCXF() throws Exception {
+        CxfEndpoint endpoint = createEndpoint(getEndpointURI() + sepChar() + 
"dataFormat=CXF_MESSAGE");
+        assertEquals("We should get the Message DataFormat", 
DataFormat.CXF_MESSAGE, endpoint.getDataFormat());
+    }
+    @Test
+    public void testGetDataFormatRAW() throws Exception {
+        CxfEndpoint endpoint = createEndpoint(getEndpointURI() + sepChar() + 
"dataFormat=RAW");
+        assertEquals("We should get the Message DataFormat", DataFormat.RAW, 
endpoint.getDataFormat());
+    }
 
     @Test
     public void testCheckServiceClassWithTheEndpoint() throws Exception {

Modified: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsWithSpringTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsWithSpringTest.java?rev=1339622&r1=1339621&r2=1339622&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsWithSpringTest.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsWithSpringTest.java
 Thu May 17 14:46:48 2012
@@ -71,18 +71,18 @@ public class CxfEndpointUtilsWithSpringT
                      endpoint.getServiceClass().getName());
     }
     
-    @Test
-    public void testGetDataFormat() throws Exception {
-        CxfEndpoint endpoint = createEndpoint(getEndpointURI() + 
"?dataFormat=MESSAGE");
-        assertEquals("We should get the Message DataFormat", 
DataFormat.MESSAGE, endpoint.getDataFormat());
+    public char sepChar() {
+        return '?';
     }
 
+
     @Test
     public void testGetProperties() throws Exception {
         CxfSpringEndpoint endpoint = 
(CxfSpringEndpoint)createEndpoint(getEndpointURI());
         QName service = endpoint.getServiceName();
         assertEquals("We should get the right service name", SERVICE_NAME, 
service);
-        assertEquals("The cxf endpoint's DataFromat should be MESSAGE", 
DataFormat.MESSAGE, endpoint.getDataFormat());
+        assertEquals("The cxf endpoint's DataFromat should be RAW", 
DataFormat.RAW,
+                     endpoint.getDataFormat().dealias());
         
         endpoint = 
(CxfSpringEndpoint)createEndpoint("cxf:bean:testPropertiesEndpoint");
         service = CxfEndpointUtils.getServiceName(endpoint);


Reply via email to