Class 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 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
      • 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 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
      • 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 request Entity that gets passed to AsyncInvoker.method(java.lang.String, javax.ws.rs.client.Entity, javax.ws.rs.client.InvocationCallback).
        Specified by:
        bindCamelMessageToRequestEntity in interface CxfRsBinding
        Parameters:
        body - the message body
        camelMessage - the source message
        camelExchange - 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 request Entity that gets passed to AsyncInvoker.method(java.lang.String, javax.ws.rs.client.Entity, javax.ws.rs.client.InvocationCallback).
        Specified by:
        bindCamelMessageToRequestEntity in interface CxfRsBinding
        Parameters:
        body - the message body
        camelMessage - the source message
        camelExchange - the Camel exchange
        webClient - 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 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
      • 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)