org.apache.camel.component.http4
Class DefaultHttpBinding

java.lang.Object
  extended by org.apache.camel.component.http4.DefaultHttpBinding
All Implemented Interfaces:
HttpBinding

public class DefaultHttpBinding
extends Object
implements HttpBinding

Binding between HttpMessage and HttpServletResponse.

Version:

Constructor Summary
DefaultHttpBinding()
          Deprecated. 
DefaultHttpBinding(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
          Deprecated. 
DefaultHttpBinding(HttpEndpoint endpoint)
           
 
Method Summary
protected  boolean checkChunked(org.apache.camel.Message message, org.apache.camel.Exchange exchange)
           
protected  void copyStream(InputStream is, OutputStream os)
           
protected  void doWriteDirectResponse(org.apache.camel.Message message, javax.servlet.http.HttpServletResponse response, org.apache.camel.Exchange exchange)
           
 void doWriteExceptionResponse(Throwable exception, javax.servlet.http.HttpServletResponse response)
          Strategy method that writes the response to the http response stream when an exception occurred
 void doWriteFaultResponse(org.apache.camel.Message message, javax.servlet.http.HttpServletResponse response, org.apache.camel.Exchange exchange)
          Strategy method that writes the response to the http response stream for a fault message
protected  void doWriteGZIPResponse(org.apache.camel.Message message, javax.servlet.http.HttpServletResponse response, org.apache.camel.Exchange exchange)
           
 void doWriteResponse(org.apache.camel.Message message, javax.servlet.http.HttpServletResponse response, org.apache.camel.Exchange exchange)
          Strategy method that writes the response to the http response stream for an OUT message
 org.apache.camel.spi.HeaderFilterStrategy getHeaderFilterStrategy()
          Gets the header filter strategy
protected  boolean isText(String contentType)
           
 boolean isUseReaderForPayload()
          Should reader by used instead of input stream.
 Object parseBody(HttpMessage httpMessage)
          Parses the body from a HttpMessage
protected  void populateAttachments(javax.servlet.http.HttpServletRequest request, HttpMessage message)
           
protected  void populateRequestParameters(javax.servlet.http.HttpServletRequest request, HttpMessage message)
           
 void readRequest(javax.servlet.http.HttpServletRequest request, HttpMessage message)
          Strategy to read the given request and bindings it to the given message.
 void setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
          Sets the header filter strategy to use.
 void setUseReaderForPayload(boolean useReaderForPayload)
          Should the ServletRequest.getReader() be exposed as the payload of input messages in the Camel Message.getBody() or not.
 void writeResponse(org.apache.camel.Exchange exchange, javax.servlet.http.HttpServletResponse response)
          Writes the exchange to the servlet response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultHttpBinding

@Deprecated
public DefaultHttpBinding()
Deprecated. 


DefaultHttpBinding

@Deprecated
public DefaultHttpBinding(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
Deprecated. 


DefaultHttpBinding

public DefaultHttpBinding(HttpEndpoint endpoint)
Method Detail

readRequest

public void readRequest(javax.servlet.http.HttpServletRequest request,
                        HttpMessage message)
Description copied from interface: HttpBinding
Strategy to read the given request and bindings it to the given message.

Specified by:
readRequest in interface HttpBinding
Parameters:
request - the request
message - the message to populate with data from request

populateRequestParameters

protected void populateRequestParameters(javax.servlet.http.HttpServletRequest request,
                                         HttpMessage message)
                                  throws Exception
Throws:
Exception

populateAttachments

protected void populateAttachments(javax.servlet.http.HttpServletRequest request,
                                   HttpMessage message)

writeResponse

public void writeResponse(org.apache.camel.Exchange exchange,
                          javax.servlet.http.HttpServletResponse response)
                   throws IOException
Description copied from interface: HttpBinding
Writes the exchange to the servlet response.

Default implementation will delegate to the following methods depending on the status of the exchange

Specified by:
writeResponse in interface HttpBinding
Parameters:
exchange - the exchange
response - the http response
Throws:
IOException - can be thrown from http response

doWriteExceptionResponse

public void doWriteExceptionResponse(Throwable exception,
                                     javax.servlet.http.HttpServletResponse response)
                              throws IOException
Description copied from interface: HttpBinding
Strategy method that writes the response to the http response stream when an exception occurred

Specified by:
doWriteExceptionResponse in interface HttpBinding
Parameters:
exception - the exception occurred
response - the http response
Throws:
IOException - can be thrown from http response

doWriteFaultResponse

public void doWriteFaultResponse(org.apache.camel.Message message,
                                 javax.servlet.http.HttpServletResponse response,
                                 org.apache.camel.Exchange exchange)
                          throws IOException
Description copied from interface: HttpBinding
Strategy method that writes the response to the http response stream for a fault message

Specified by:
doWriteFaultResponse in interface HttpBinding
Parameters:
message - the fault message
response - the http response
exchange - the exchange to provide context for header filtering
Throws:
IOException - can be thrown from http response

doWriteResponse

public void doWriteResponse(org.apache.camel.Message message,
                            javax.servlet.http.HttpServletResponse response,
                            org.apache.camel.Exchange exchange)
                     throws IOException
Description copied from interface: HttpBinding
Strategy method that writes the response to the http response stream for an OUT message

Specified by:
doWriteResponse in interface HttpBinding
Parameters:
message - the OUT message
response - the http response
exchange - the exchange to provide context for header filtering
Throws:
IOException - can be thrown from http response

isText

protected boolean isText(String contentType)

copyStream

protected void copyStream(InputStream is,
                          OutputStream os)
                   throws IOException
Throws:
IOException

doWriteDirectResponse

protected void doWriteDirectResponse(org.apache.camel.Message message,
                                     javax.servlet.http.HttpServletResponse response,
                                     org.apache.camel.Exchange exchange)
                              throws IOException
Throws:
IOException

checkChunked

protected boolean checkChunked(org.apache.camel.Message message,
                               org.apache.camel.Exchange exchange)

doWriteGZIPResponse

protected void doWriteGZIPResponse(org.apache.camel.Message message,
                                   javax.servlet.http.HttpServletResponse response,
                                   org.apache.camel.Exchange exchange)
                            throws IOException
Throws:
IOException

parseBody

public Object parseBody(HttpMessage httpMessage)
                 throws IOException
Description copied from interface: HttpBinding
Parses the body from a HttpMessage

Specified by:
parseBody in interface HttpBinding
Parameters:
httpMessage - the http message
Returns:
the parsed body returned as either a InputStream or a Reader depending on the HttpBinding.setUseReaderForPayload(boolean) property.
Throws:
IOException - can be thrown

isUseReaderForPayload

public boolean isUseReaderForPayload()
Description copied from interface: HttpBinding
Should reader by used instead of input stream.

Specified by:
isUseReaderForPayload in interface HttpBinding
Returns:
true if reader should be used
See Also:
for more details

setUseReaderForPayload

public void setUseReaderForPayload(boolean useReaderForPayload)
Description copied from interface: HttpBinding
Should the ServletRequest.getReader() be exposed as the payload of input messages in the Camel Message.getBody() or not. If false then the ServletRequest.getInputStream() will be exposed.

Is default false.

Specified by:
setUseReaderForPayload in interface HttpBinding
Parameters:
useReaderForPayload - whether to use reader or not

getHeaderFilterStrategy

public org.apache.camel.spi.HeaderFilterStrategy getHeaderFilterStrategy()
Description copied from interface: HttpBinding
Gets the header filter strategy

Specified by:
getHeaderFilterStrategy in interface HttpBinding
Returns:
the strategy

setHeaderFilterStrategy

public void setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
Description copied from interface: HttpBinding
Sets the header filter strategy to use.

Will default use HttpHeaderFilterStrategy

Specified by:
setHeaderFilterStrategy in interface HttpBinding
Parameters:
headerFilterStrategy - the custom strategy


Apache CAMEL