Class DefaultCxfRsBinding
- java.lang.Object
-
- org.apache.camel.component.cxf.jaxrs.DefaultCxfRsBinding
-
- All Implemented Interfaces:
CxfRsBinding,org.apache.camel.spi.HeaderFilterStrategyAware
- Direct Known Subclasses:
SimpleCxfRsBinding
public class DefaultCxfRsBinding extends Object implements CxfRsBinding, org.apache.camel.spi.HeaderFilterStrategyAware
Default strategy to bind between Camel and CXF exchange for RESTful resources.
-
-
Constructor Summary
Constructors Constructor Description DefaultCxfRsBinding()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 RSWebClientAPIs.ObjectbindCamelMessageBodyToRequestBody(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.javax.ws.rs.client.Entity<Object>bindCamelMessageToRequestEntity(Object body, org.apache.camel.Message camelMessage, org.apache.camel.Exchange camelExchange)Bind the Camel message to a requestEntitythat gets passed toAsyncInvoker.method(java.lang.String, javax.ws.rs.client.Entity, javax.ws.rs.client.InvocationCallback).javax.ws.rs.client.Entity<Object>bindCamelMessageToRequestEntity(Object body, org.apache.camel.Message camelMessage, org.apache.camel.Exchange camelExchange, org.apache.cxf.jaxrs.client.WebClient webClient)Bind the Camel message to a requestEntitythat gets passed toAsyncInvoker.method(java.lang.String, javax.ws.rs.client.Entity, javax.ws.rs.client.InvocationCallback).Map<String,Object>bindResponseHeadersToCamelHeaders(Object response, org.apache.camel.Exchange camelExchange)We will return an empty Map unless the response parameter is aResponseobject.ObjectbindResponseToCamelBody(Object response, org.apache.camel.Exchange camelExchange)By default, we just return the response object.protected voidcopyOperationResourceInfoStack(org.apache.cxf.message.Message cxfMessage, org.apache.camel.Message camelMessage)protected voidcopyProtocolHeader(org.apache.cxf.message.Message cxfMessage, org.apache.camel.Message camelMessage, org.apache.camel.Exchange camelExchange)org.apache.camel.spi.HeaderFilterStrategygetHeaderFilterStrategy()ObjectpopulateCxfRsResponseFromExchange(org.apache.camel.Exchange camelExchange, org.apache.cxf.message.Exchange cxfExchange)Populate the CxfRsResponse object from the camel exchangevoidpopulateExchangeFromCxfRsRequest(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.protected voidsetCharsetWithContentType(org.apache.camel.Exchange camelExchange)voidsetHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy strategy)
-
-
-
Method Detail
-
populateCxfRsResponseFromExchange
public Object populateCxfRsResponseFromExchange(org.apache.camel.Exchange camelExchange, org.apache.cxf.message.Exchange cxfExchange) throws Exception
Description copied from interface:CxfRsBindingPopulate the CxfRsResponse object from the camel exchange- Specified by:
populateCxfRsResponseFromExchangein interfaceCxfRsBinding- Parameters:
camelExchange- camel exchange objectcxfExchange- 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:CxfRsBindingPopulate the camel exchange from the CxfRsRequest, the exchange will be consumed by the processor which the CxfRsConsumer attached.- Specified by:
populateExchangeFromCxfRsRequestin interfaceCxfRsBinding- Parameters:
cxfExchange- cxf exchange objectcamelExchange- camel exchange objectmethod- the method which is need for the camel componentparamArray- the parameter list for the method invocation
-
setCharsetWithContentType
protected void setCharsetWithContentType(org.apache.camel.Exchange camelExchange)
-
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:CxfRsBindingBind the camel headers to request headers that gets passed to CXF RSWebClientAPIs.- Specified by:
bindCamelHeadersToRequestHeadersin interfaceCxfRsBinding- Parameters:
camelHeaders- the source headerscamelExchange- 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:
bindCamelMessageBodyToRequestBodyin interfaceCxfRsBinding- Parameters:
camelMessage- the source messagecamelExchange- 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 aResponseobject.- Specified by:
bindResponseHeadersToCamelHeadersin interfaceCxfRsBinding- Parameters:
response- the responsecamelExchange- the exchange- Returns:
- headers to be set in the Camel out message
- Throws:
Exception- can be thrown if error in the binding process
-
bindCamelMessageToRequestEntity
public javax.ws.rs.client.Entity<Object> bindCamelMessageToRequestEntity(Object body, org.apache.camel.Message camelMessage, org.apache.camel.Exchange camelExchange) throws Exception
Description copied from interface:CxfRsBindingBind the Camel message to a requestEntitythat gets passed toAsyncInvoker.method(java.lang.String, javax.ws.rs.client.Entity, javax.ws.rs.client.InvocationCallback).- Specified by:
bindCamelMessageToRequestEntityin interfaceCxfRsBinding- Parameters:
body- the message bodycamelMessage- the source messagecamelExchange- the Camel exchange- Returns:
- the
Entityto use - Throws:
Exception- can be thrown if error in the binding process
-
bindCamelMessageToRequestEntity
public javax.ws.rs.client.Entity<Object> bindCamelMessageToRequestEntity(Object body, org.apache.camel.Message camelMessage, org.apache.camel.Exchange camelExchange, org.apache.cxf.jaxrs.client.WebClient webClient) throws Exception
Description copied from interface:CxfRsBindingBind the Camel message to a requestEntitythat gets passed toAsyncInvoker.method(java.lang.String, javax.ws.rs.client.Entity, javax.ws.rs.client.InvocationCallback).- Specified by:
bindCamelMessageToRequestEntityin interfaceCxfRsBinding- Parameters:
body- the message bodycamelMessage- the source messagecamelExchange- the Camel exchangewebClient- the CXF JAXRS WebClient- Returns:
- the
Entityto use - 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:
bindResponseToCamelBodyin interfaceCxfRsBinding- Parameters:
response- the responsecamelExchange- 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:
getHeaderFilterStrategyin interfaceorg.apache.camel.spi.HeaderFilterStrategyAware
-
setHeaderFilterStrategy
public void setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy strategy)
- Specified by:
setHeaderFilterStrategyin interfaceorg.apache.camel.spi.HeaderFilterStrategyAware
-
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)
-
-