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 RSWebClient
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.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 requestEntity
that 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 requestEntity
that 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 aResponse
object.Object
bindResponseToCamelBody(Object response, org.apache.camel.Exchange camelExchange)
By default, we just return the response object.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)
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 exchangevoid
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.protected void
setCharsetWithContentType(org.apache.camel.Exchange camelExchange)
void
setHeaderFilterStrategy(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:CxfRsBinding
Populate the CxfRsResponse object from the camel exchange- Specified by:
populateCxfRsResponseFromExchange
in 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:CxfRsBinding
Populate the camel exchange from the CxfRsRequest, the exchange will be consumed by the processor which the CxfRsConsumer attached.- Specified by:
populateExchangeFromCxfRsRequest
in 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:CxfRsBinding
Bind the camel headers to request headers that gets passed to CXF RSWebClient
APIs.- Specified by:
bindCamelHeadersToRequestHeaders
in 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:
bindCamelMessageBodyToRequestBody
in 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 aResponse
object.- Specified by:
bindResponseHeadersToCamelHeaders
in 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:CxfRsBinding
Bind the Camel message to a requestEntity
that gets passed toAsyncInvoker.method(java.lang.String, javax.ws.rs.client.Entity, javax.ws.rs.client.InvocationCallback)
.- Specified by:
bindCamelMessageToRequestEntity
in interfaceCxfRsBinding
- Parameters:
body
- the message bodycamelMessage
- the source messagecamelExchange
- the Camel exchange- Returns:
- the
Entity
to 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:CxfRsBinding
Bind the Camel message to a requestEntity
that gets passed toAsyncInvoker.method(java.lang.String, javax.ws.rs.client.Entity, javax.ws.rs.client.InvocationCallback)
.- Specified by:
bindCamelMessageToRequestEntity
in interfaceCxfRsBinding
- Parameters:
body
- the message bodycamelMessage
- the source messagecamelExchange
- the Camel exchangewebClient
- the CXF JAXRS WebClient- Returns:
- the
Entity
to 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:
bindResponseToCamelBody
in 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:
getHeaderFilterStrategy
in interfaceorg.apache.camel.spi.HeaderFilterStrategyAware
-
setHeaderFilterStrategy
public void setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy strategy)
- Specified by:
setHeaderFilterStrategy
in 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)
-
-