org.apache.camel.component.netty.http
Class DefaultNettyHttpBinding

java.lang.Object
  extended by org.apache.camel.component.netty.http.DefaultNettyHttpBinding
All Implemented Interfaces:
NettyHttpBinding

public class DefaultNettyHttpBinding
extends Object
implements NettyHttpBinding

Default NettyHttpBinding.


Constructor Summary
DefaultNettyHttpBinding()
           
DefaultNettyHttpBinding(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
           
 
Method Summary
 org.apache.camel.spi.HeaderFilterStrategy getHeaderFilterStrategy()
          Gets the header filter strategy
 void populateCamelHeaders(org.jboss.netty.handler.codec.http.HttpRequest request, Map<String,Object> headers, org.apache.camel.Exchange exchange, NettyHttpConfiguration configuration)
          Binds from Netty HttpRequest to Camel headers as a Map.
 void populateCamelHeaders(org.jboss.netty.handler.codec.http.HttpResponse response, Map<String,Object> headers, org.apache.camel.Exchange exchange, NettyHttpConfiguration configuration)
          Binds from Netty HttpResponse to Camel headers as a Map.
 void setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
          Sets the header filter strategy to use.
protected  String shouldUrlDecodeHeader(NettyHttpConfiguration configuration, String headerName, Object value, String charset)
          Decodes the header if needed to, or returns the header value as is.
 org.apache.camel.Message toCamelMessage(org.jboss.netty.handler.codec.http.HttpRequest request, org.apache.camel.Exchange exchange, NettyHttpConfiguration configuration)
          Binds from Netty HttpRequest to Camel Message.
 org.apache.camel.Message toCamelMessage(org.jboss.netty.handler.codec.http.HttpResponse response, org.apache.camel.Exchange exchange, NettyHttpConfiguration configuration)
          Binds from Netty HttpResponse to Camel Message.
 org.jboss.netty.handler.codec.http.HttpRequest toNettyRequest(org.apache.camel.Message message, String uri, NettyHttpConfiguration configuration)
          Binds from Camel Message to Netty HttpRequest.
 org.jboss.netty.handler.codec.http.HttpResponse toNettyResponse(org.apache.camel.Message message, NettyHttpConfiguration configuration)
          Binds from Camel Message to Netty HttpResponse.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultNettyHttpBinding

public DefaultNettyHttpBinding()

DefaultNettyHttpBinding

public DefaultNettyHttpBinding(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
Method Detail

toCamelMessage

public org.apache.camel.Message toCamelMessage(org.jboss.netty.handler.codec.http.HttpRequest request,
                                               org.apache.camel.Exchange exchange,
                                               NettyHttpConfiguration configuration)
                                        throws Exception
Description copied from interface: NettyHttpBinding
Binds from Netty HttpRequest to Camel Message.

Will use NettyHttpBinding.populateCamelHeaders(org.jboss.netty.handler.codec.http.HttpRequest, java.util.Map, org.apache.camel.Exchange, NettyHttpConfiguration) for populating the headers.

Specified by:
toCamelMessage in interface NettyHttpBinding
Parameters:
request - the netty http request
exchange - the exchange that should contain the returned message.
configuration - the endpoint configuration
Returns:
the message to store on the given exchange
Throws:
Exception - is thrown if error during binding

populateCamelHeaders

public void populateCamelHeaders(org.jboss.netty.handler.codec.http.HttpRequest request,
                                 Map<String,Object> headers,
                                 org.apache.camel.Exchange exchange,
                                 NettyHttpConfiguration configuration)
                          throws Exception
Description copied from interface: NettyHttpBinding
Binds from Netty HttpRequest to Camel headers as a Map.

Specified by:
populateCamelHeaders in interface NettyHttpBinding
Parameters:
request - the netty http request
headers - the Camel headers that should be populated
exchange - the exchange that should contain the returned message.
configuration - the endpoint configuration
Throws:
Exception - is thrown if error during binding

shouldUrlDecodeHeader

protected String shouldUrlDecodeHeader(NettyHttpConfiguration configuration,
                                       String headerName,
                                       Object value,
                                       String charset)
                                throws UnsupportedEncodingException
Decodes the header if needed to, or returns the header value as is.

Parameters:
configuration - the configuration
headerName - the header name
value - the current header value
charset - the charset to use for decoding
Returns:
the decoded value (if decoded was needed) or a toString representation of the value.
Throws:
UnsupportedEncodingException - is thrown if error decoding.

toCamelMessage

public org.apache.camel.Message toCamelMessage(org.jboss.netty.handler.codec.http.HttpResponse response,
                                               org.apache.camel.Exchange exchange,
                                               NettyHttpConfiguration configuration)
                                        throws Exception
Description copied from interface: NettyHttpBinding
Binds from Netty HttpResponse to Camel Message.

Will use NettyHttpBinding.populateCamelHeaders(org.jboss.netty.handler.codec.http.HttpResponse, java.util.Map, org.apache.camel.Exchange, NettyHttpConfiguration) for populating the headers.

Specified by:
toCamelMessage in interface NettyHttpBinding
Parameters:
response - the netty http response
exchange - the exchange that should contain the returned message.
configuration - the endpoint configuration
Returns:
the message to store on the given exchange
Throws:
Exception - is thrown if error during binding

populateCamelHeaders

public void populateCamelHeaders(org.jboss.netty.handler.codec.http.HttpResponse response,
                                 Map<String,Object> headers,
                                 org.apache.camel.Exchange exchange,
                                 NettyHttpConfiguration configuration)
                          throws Exception
Description copied from interface: NettyHttpBinding
Binds from Netty HttpResponse to Camel headers as a Map.

Specified by:
populateCamelHeaders in interface NettyHttpBinding
Parameters:
response - the netty http response
headers - the Camel headers that should be populated
exchange - the exchange that should contain the returned message.
configuration - the endpoint configuration
Throws:
Exception - is thrown if error during binding

toNettyResponse

public org.jboss.netty.handler.codec.http.HttpResponse toNettyResponse(org.apache.camel.Message message,
                                                                       NettyHttpConfiguration configuration)
                                                                throws Exception
Description copied from interface: NettyHttpBinding
Binds from Camel Message to Netty HttpResponse.

Specified by:
toNettyResponse in interface NettyHttpBinding
Parameters:
message - the Camel message
configuration - the endpoint configuration
Returns:
the http response
Throws:
Exception - is thrown if error during binding

toNettyRequest

public org.jboss.netty.handler.codec.http.HttpRequest toNettyRequest(org.apache.camel.Message message,
                                                                     String uri,
                                                                     NettyHttpConfiguration configuration)
                                                              throws Exception
Description copied from interface: NettyHttpBinding
Binds from Camel Message to Netty HttpRequest.

Specified by:
toNettyRequest in interface NettyHttpBinding
Parameters:
message - the Camel message
uri - the uri which is the intended uri to call, though the message may override the uri
configuration - the endpoint configuration
Returns:
the http request
Throws:
Exception - is thrown if error during binding

getHeaderFilterStrategy

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

Specified by:
getHeaderFilterStrategy in interface NettyHttpBinding
Returns:
the strategy

setHeaderFilterStrategy

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

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


Apache Camel