Hi I am not totally happy about this. You may end with a type converter duplicate when you do a Message -> InputStream as an existing type converter may exists.
I would like to -1 this ticket in the 2.x timeframe. The issue is that we have specialized xxxMessage objects where it may be better to not have that at all and store message specific stuff in another way. The Camel pipeline will preserve the HttpMessage along the way until you hit another specialized message such as JmsMessage etc. So willem do you mind doing a revert on this one and set the ticket to FUTURE. On Tue, Feb 9, 2010 at 10:06 AM, <ningji...@apache.org> wrote: > 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 > > > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus