org.apache.camel.component.cxf.jaxrs
Class DefaultCxfRsBinding

java.lang.Object
  extended by org.apache.camel.component.cxf.jaxrs.DefaultCxfRsBinding
All Implemented Interfaces:
CxfRsBinding, org.apache.camel.spi.HeaderFilterStrategyAware

public class DefaultCxfRsBinding
extends Object
implements CxfRsBinding, org.apache.camel.spi.HeaderFilterStrategyAware

Default strategy to bind between Camel and CXF exchange for RESTful resources.

Version:

Field Summary
protected  Map<String,String> camelToCxfHeaderMap
           
protected  Map<String,String> cxfToCamelHeaderMap
           
 
Constructor Summary
DefaultCxfRsBinding()
           
 
Method Summary
 javax.ws.rs.core.MultivaluedMap<String,String> bindCamelHeadersToRequestHeaders(Map<String,Object> camelHeaders, org.apache.camel.Exchange camelExchange)
          Bind the camel headers to request headers that gets passed to CXF RS WebClient APIs.
 Object bindCamelMessageBodyToRequestBody(org.apache.camel.Message camelMessage, org.apache.camel.Exchange camelExchange)
          This method call Message.getBody(MessageContentsList) to allow an appropriate converter to kick in even through we only read the first element off the MessageContextList.
 Map<String,Object> bindResponseHeadersToCamelHeaders(Object response, org.apache.camel.Exchange camelExchange)
          We will return an empty Map unless the response parameter is a Response object.
 Object bindResponseToCamelBody(Object response, org.apache.camel.Exchange camelExchange)
          By default, we just return the response object.
protected  void copyMessageHeader(org.apache.cxf.message.Message cxfMessage, org.apache.camel.Message camelMessage, String cxfKey, String camelKey)
           
protected  void copyOperationResourceInfoStack(org.apache.cxf.message.Message cxfMessage, org.apache.camel.Message camelMessage)
           
protected  void copyProtocolHeader(org.apache.cxf.message.Message cxfMessage, org.apache.camel.Message camelMessage, org.apache.camel.Exchange camelExchange)
           
 Map<String,String> getCamelToCxfHeaderMap()
           
 Map<String,String> getCxfToCamelHeaderMap()
           
 org.apache.camel.spi.HeaderFilterStrategy getHeaderFilterStrategy()
           
 Object populateCxfRsResponseFromExchange(org.apache.camel.Exchange camelExchange, org.apache.cxf.message.Exchange cxfExchange)
          Populate the CxfRsResponse object from the camel exchange
 void populateExchangeFromCxfRsRequest(org.apache.cxf.message.Exchange cxfExchange, org.apache.camel.Exchange camelExchange, Method method, Object[] paramArray)
          Populate the camel exchange from the CxfRsRequest, the exchange will be consumed by the processor which the CxfRsConsumer attached.
 void setCamelToCxfHeaderMap(Map<String,String> camelToCxfHeaderMap)
           
 void setCxfToCamelHeaderMap(Map<String,String> cxfToCamelHeaderMap)
           
 void setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy strategy)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

camelToCxfHeaderMap

protected Map<String,String> camelToCxfHeaderMap

cxfToCamelHeaderMap

protected Map<String,String> cxfToCamelHeaderMap
Constructor Detail

DefaultCxfRsBinding

public DefaultCxfRsBinding()
Method Detail

populateCxfRsResponseFromExchange

public Object populateCxfRsResponseFromExchange(org.apache.camel.Exchange camelExchange,
                                                org.apache.cxf.message.Exchange cxfExchange)
                                         throws Exception
Description copied from interface: CxfRsBinding
Populate the CxfRsResponse object from the camel exchange

Specified by:
populateCxfRsResponseFromExchange in interface CxfRsBinding
Parameters:
camelExchange - camel exchange object
cxfExchange - cxf exchange object
Returns:
the response object
Throws:
Exception - can be thrown if error in the binding process

populateExchangeFromCxfRsRequest

public void populateExchangeFromCxfRsRequest(org.apache.cxf.message.Exchange cxfExchange,
                                             org.apache.camel.Exchange camelExchange,
                                             Method method,
                                             Object[] paramArray)
Description copied from interface: CxfRsBinding
Populate the camel exchange from the CxfRsRequest, the exchange will be consumed by the processor which the CxfRsConsumer attached.

Specified by:
populateExchangeFromCxfRsRequest in interface CxfRsBinding
Parameters:
cxfExchange - cxf exchange object
camelExchange - camel exchange object
method - the method which is need for the camel component
paramArray - the parameter list for the method invocation

bindCamelHeadersToRequestHeaders

public javax.ws.rs.core.MultivaluedMap<String,String> bindCamelHeadersToRequestHeaders(Map<String,Object> camelHeaders,
                                                                                       org.apache.camel.Exchange camelExchange)
                                                                                throws Exception
Description copied from interface: CxfRsBinding
Bind the camel headers to request headers that gets passed to CXF RS WebClient APIs.

Specified by:
bindCamelHeadersToRequestHeaders in interface CxfRsBinding
Parameters:
camelHeaders - the source headers
camelExchange - the Camel exchange
Returns:
the headers
Throws:
Exception - can be thrown if error in the binding process

bindCamelMessageBodyToRequestBody

public Object bindCamelMessageBodyToRequestBody(org.apache.camel.Message camelMessage,
                                                org.apache.camel.Exchange camelExchange)
                                         throws Exception
This method call Message.getBody(MessageContentsList) to allow an appropriate converter to kick in even through we only read the first element off the MessageContextList. If that returns null, we check the body to see if it is a List or an array and then return the first element. If that fails, we will simply return the object.

Specified by:
bindCamelMessageBodyToRequestBody in interface CxfRsBinding
Parameters:
camelMessage - the source message
camelExchange - the Camel exchange
Returns:
the request object to be passed to invoke a WebClient
Throws:
Exception - can be thrown if error in the binding process

bindResponseHeadersToCamelHeaders

public Map<String,Object> bindResponseHeadersToCamelHeaders(Object response,
                                                            org.apache.camel.Exchange camelExchange)
                                                     throws Exception
We will return an empty Map unless the response parameter is a Response object.

Specified by:
bindResponseHeadersToCamelHeaders in interface CxfRsBinding
Parameters:
response - the response
camelExchange - the exchange
Returns:
headers to be set in the Camel out message
Throws:
Exception - can be thrown if error in the binding process

bindResponseToCamelBody

public Object bindResponseToCamelBody(Object response,
                                      org.apache.camel.Exchange camelExchange)
                               throws Exception
By default, we just return the response object.

Specified by:
bindResponseToCamelBody in interface CxfRsBinding
Parameters:
response - the response
camelExchange - the exchange
Returns:
the object to be set in the Camel out message body
Throws:
Exception - can be thrown if error in the binding process

getHeaderFilterStrategy

public org.apache.camel.spi.HeaderFilterStrategy getHeaderFilterStrategy()
Specified by:
getHeaderFilterStrategy in interface org.apache.camel.spi.HeaderFilterStrategyAware

setHeaderFilterStrategy

public void setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy strategy)
Specified by:
setHeaderFilterStrategy in interface org.apache.camel.spi.HeaderFilterStrategyAware

getCamelToCxfHeaderMap

public Map<String,String> getCamelToCxfHeaderMap()

setCamelToCxfHeaderMap

public void setCamelToCxfHeaderMap(Map<String,String> camelToCxfHeaderMap)

getCxfToCamelHeaderMap

public Map<String,String> getCxfToCamelHeaderMap()

setCxfToCamelHeaderMap

public void setCxfToCamelHeaderMap(Map<String,String> cxfToCamelHeaderMap)

copyMessageHeader

protected void copyMessageHeader(org.apache.cxf.message.Message cxfMessage,
                                 org.apache.camel.Message camelMessage,
                                 String cxfKey,
                                 String camelKey)

copyProtocolHeader

protected void copyProtocolHeader(org.apache.cxf.message.Message cxfMessage,
                                  org.apache.camel.Message camelMessage,
                                  org.apache.camel.Exchange camelExchange)

copyOperationResourceInfoStack

protected void copyOperationResourceInfoStack(org.apache.cxf.message.Message cxfMessage,
                                              org.apache.camel.Message camelMessage)


Apache CAMEL