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.Endpoint;
020    import org.apache.camel.Exchange;
021    import org.apache.camel.Producer;
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 OutboundBinding is used
027     * by {@link Producer} implementations to translate between {@link Exchange}
028     * objects and protocol-specific or services-specific messages.
029     * 
030     * @param S
031     *            request type.
032     * @param T
033     *            response type.
034     * @param E
035     *            endpoint type.
036     */
037    public interface OutboundBinding<E extends Endpoint, S, T> {
038    
039        /**
040         * Creates or populates a request object from {@link Exchange} and endpoint configuration data.
041         * 
042         * @param endpoint endpoint providing binding-relevant information. 
043         * @param exchange exchange to read data from.
044         * @param request request to be populated or created (if <code>null</code>) from exchange data.
045         * @return the populated response.
046         */
047        S writeRequest(E endpoint, Exchange exchange, S request) throws Exception;
048        
049        /**
050         * Populates an {@link Exchange} from response data and endpoint configuration data.
051         * 
052         * @param endpoint endpoint providing binding-relevant information. 
053         * @param exchange exchange to be populated or created (if <code>null</code>) from response data.
054         * @param response response to read data from.
055         * @return the populated exchange.
056         */
057        Exchange readResponse(E endpoint, Exchange exchange, T response) throws Exception;
058        
059    }