001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.camel.component.cxf.jaxrs;
019
020 import java.lang.reflect.Method;
021 import java.util.Map;
022
023 import javax.ws.rs.core.MultivaluedMap;
024 import org.apache.cxf.message.Exchange;
025
026 /**
027 * Interface to bind between Camel and CXF exchange for RESTful resources.
028 *
029 * @version $Revision: 14523 $
030 */
031 public interface CxfRsBinding {
032
033 /**
034 * Populate the camel exchange from the CxfRsRequest, the exchange will be consumed
035 * by the processor which the CxfRsConsumer attached.
036 *
037 * @param camelExchange camel exchange object
038 * @param cxfExchange cxf exchange object
039 * @param method the method which is need for the camel component
040 * @param paramArray the parameter list for the method invocation
041 */
042 void populateExchangeFromCxfRsRequest(Exchange cxfExchange,
043 org.apache.camel.Exchange camelExchange,
044 Method method,
045 Object[] paramArray);
046
047 /**
048 * Populate the CxfRsResponse object from the camel exchange
049 * @param camelExchange camel exchange object
050 * @param cxfExchange cxf exchange object
051 * @return the response object
052 * @throws Exception
053 */
054 Object populateCxfRsResponseFromExchange(org.apache.camel.Exchange camelExchange,
055 Exchange cxfExchange) throws Exception;
056
057 /**
058 * Bind the camel in message body to a request body that gets passed
059 * to CXF RS {@link org.apache.cxf.jaxrs.client.WebClient} APIs.
060 *
061 * @param camelMessage the source message
062 * @param camelExchange the Camel exchange
063 * @return the request object to be passed to invoke a WebClient
064 * @throws Exception
065 */
066 Object bindCamelMessageBodyToRequestBody(org.apache.camel.Message camelMessage,
067 org.apache.camel.Exchange camelExchange)
068 throws Exception;
069
070 /**
071 * Bind the camel headers to request headers that gets passed to CXF RS
072 * {@link org.apache.cxf.jaxrs.client.WebClient} APIs.
073 *
074 * @param camelHeaders the source headers
075 * @param camelExchange the Camel exchange
076 * @param headers to be passed to WebClient
077 * @throws Exception
078 */
079 MultivaluedMap<String, String> bindCamelHeadersToRequestHeaders(Map<String, Object> camelHeaders,
080 org.apache.camel.Exchange camelExchange)
081 throws Exception;
082
083
084 /**
085 * Bind the HTTP response body to camel out body
086 * @param response
087 * @param exchange
088 * @return the object to be set in the Camel out message body
089 */
090 Object bindResponseToCamelBody(Object response, org.apache.camel.Exchange camelExchange)
091 throws Exception;
092
093 /**
094 * Bind the response headers to camel out headers.
095 *
096 * @param response
097 * @param exchange
098 * @return headers to be set in the Camel out message
099 * @throws Exception
100 */
101 Map<String, Object> bindResponseHeadersToCamelHeaders(Object response,
102 org.apache.camel.Exchange exchange)
103 throws Exception;
104
105 }