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 package org.apache.camel.component.gae.bind;
018
019 import org.apache.camel.Consumer;
020 import org.apache.camel.Endpoint;
021 import org.apache.camel.Exchange;
022
023 /**
024 * Represents the binding of request and response types to an {@link Exchange}.
025 * The request and response types are defined via the type parameters
026 * <code>S</code> and <code>T</code>, respectively. The InboundBinding is used
027 * by {@link Consumer} implementations or their clients to translate between
028 * protocol-specific or services-specific messages and {@link Exchange} objects.
029 *
030 * @param S
031 * request type.
032 * @param T
033 * response type.
034 * @param E
035 * endpoint type.
036 */
037 public interface InboundBinding<E extends Endpoint, S, T> {
038
039 /**
040 * Populates an {@link Exchange} from request data and endpoint configuration data.
041 *
042 * @param endpoint endpoint providing binding-relevant information.
043 * @param exchange exchange to be populated or created (if <code>null</code>) from request data.
044 * @param request request to read data from.
045 * @return the populated exchange.
046 */
047 Exchange readRequest(E endpoint, Exchange exchange, S request) throws Exception;
048
049 /**
050 * Creates or populates a response object from {@link Exchange} and endpoint configuration data.
051 *
052 * @param endpoint endpoint providing binding-relevant information.
053 * @param exchange exchange to read data from.
054 * @param response to be populated or created (if <code>null</code>) from exchange data.
055 * @return the populated response.
056 */
057 T writeResponse(E endpoint, Exchange exchange, T response) throws Exception;
058
059 }