org.apache.camel.component.http
Class DefaultHttpBinding

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

public class DefaultHttpBinding
extends Object
implements HttpBinding

Binding between HttpMessage and HttpServletResponse.

Version:

Constructor Summary
DefaultHttpBinding()
          Deprecated. 
DefaultHttpBinding(HeaderFilterStrategy headerFilterStrategy)
          Deprecated. 
DefaultHttpBinding(HttpEndpoint endpoint)
           
 
Method Summary
protected  boolean checkChunked(Message message, Exchange exchange)
           
protected  void doWriteDirectResponse(Message message, javax.servlet.http.HttpServletResponse response, 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(Message message, javax.servlet.http.HttpServletResponse response, Exchange exchange)
          Strategy method that writes the response to the http response stream for a fault message
protected  void doWriteGZIPResponse(Message message, javax.servlet.http.HttpServletResponse response, Exchange exchange)
           
 void doWriteResponse(Message message, javax.servlet.http.HttpServletResponse response, Exchange exchange)
          Strategy method that writes the response to the http response stream for an OUT message
 HeaderFilterStrategy getHeaderFilterStrategy()
          Gets the header filter strategy
 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(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(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(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 UnsupportedEncodingException
Throws:
UnsupportedEncodingException

populateAttachments

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

writeResponse

public void writeResponse(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(Message message,
                                 javax.servlet.http.HttpServletResponse response,
                                 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(Message message,
                            javax.servlet.http.HttpServletResponse response,
                            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

doWriteDirectResponse

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

checkChunked

protected boolean checkChunked(Message message,
                               Exchange exchange)

doWriteGZIPResponse

protected void doWriteGZIPResponse(Message message,
                                   javax.servlet.http.HttpServletResponse response,
                                   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 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(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