camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r907978 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/ components/camel-http/src/main/java/org/apache/camel/component/http/
Date Tue, 09 Feb 2010 09:06:52 GMT
Author: ningjiang
Date: Tue Feb  9 09:06:51 2010
New Revision: 907978

URL: http://svn.apache.org/viewvc?rev=907978&view=rev
Log:
CAMEL-2453 put the HttpServletRequest and HttpServletResponse into HttpMessage header.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java?rev=907978&r1=907977&r2=907978&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java Tue Feb  9 09:06:51
2010
@@ -116,6 +116,9 @@
     String TRACE_EVENT_EXCHANGE  = "CamelTraceEventExchange";
     
     String SOAP_ACTION = "CamelSoapAction";
+    
+    String HTTP_SERVLET_REQUEST = "CamelHttpServletRequest";
+    String HTTP_SERVLET_RESPONSE = "CamelHttpServletResponse";
 
     /**
      * Returns the {@link ExchangePattern} (MEP) of this exchange.

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java?rev=907978&r1=907977&r2=907978&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java
(original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java
Tue Feb  9 09:06:51 2010
@@ -19,12 +19,14 @@
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
+
 import javax.servlet.ServletInputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.camel.Converter;
 import org.apache.camel.Exchange;
+import org.apache.camel.Message;
 import org.apache.camel.component.http.helper.GZIPHelper;
 
 /**
@@ -40,23 +42,25 @@
     }
 
     @Converter
-    public static HttpServletRequest toServletRequest(HttpMessage message) {
+    public static HttpServletRequest toServletRequest(Message message) {
         if (message == null) {
             return null;
         }
-        return message.getRequest();
+        return message.getHeader(Exchange.HTTP_SERVLET_REQUEST, HttpServletRequest.class);
     }
 
     @Converter
-    public static HttpServletResponse toServletResponse(HttpMessage message) {
+    public static HttpServletResponse toServletResponse(Message message) {
         if (message == null) {
             return null;
         }
-        return message.getResponse();
+        return message.getHeader(Exchange.HTTP_SERVLET_RESPONSE, HttpServletResponse.class);
     }
+    
+    
 
     @Converter
-    public static ServletInputStream toServletInputStream(HttpMessage message) throws IOException
{
+    public static ServletInputStream toServletInputStream(Message message) throws IOException
{
         HttpServletRequest request = toServletRequest(message);
         if (request != null) {
             return request.getInputStream();
@@ -65,12 +69,12 @@
     }
 
     @Converter
-    public static InputStream toInputStream(HttpMessage message) throws Exception {
+    public static InputStream toInputStream(Message message) throws Exception {
         return toInputStream(toServletRequest(message));
     }
 
     @Converter
-    public static BufferedReader toReader(HttpMessage message) throws IOException {
+    public static BufferedReader toReader(Message message) throws IOException {
         HttpServletRequest request = toServletRequest(message);
         if (request != null) {
             return request.getReader();

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java?rev=907978&r1=907977&r2=907978&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
(original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
Tue Feb  9 09:06:51 2010
@@ -37,6 +37,9 @@
         setExchange(exchange);
         this.request = request;
         this.response = response;
+        // Put the request and response into the message header
+        this.setHeader(Exchange.HTTP_SERVLET_REQUEST, request);
+        this.setHeader(Exchange.HTTP_SERVLET_RESPONSE, response);
 
         // use binding to read the request allowing end users to use their
         // implementation of the binding



Mime
View raw message