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;
018
019 import java.util.Map;
020
021 /**
022 * @version $Revision: $
023 */
024 public interface ProducerTemplate<E extends Exchange> extends Service {
025
026 /**
027 * Sends the exchange to the default endpoint
028 *
029 * @param exchange the exchange to send
030 */
031 E send(E exchange);
032
033 /**
034 * Sends an exchange to the default endpoint using a supplied
035 *
036 * @{link Processor} to populate the exchange
037 *
038 * @param processor the transformer used to populate the new exchange
039 */
040 E send(Processor processor);
041
042 /**
043 * Sends the body to the default endpoint and returns the result content
044 *
045 * @param body the body to send
046 * @return the returned message body
047 */
048 Object sendBody(Object body);
049
050 /**
051 * Sends the body to the default endpoint with a specified header and header
052 * value
053 *
054 * @param body the payload send
055 * @param header the header name
056 * @param headerValue the header value
057 * @return the result
058 */
059 Object sendBodyAndHeader(Object body, String header, Object headerValue);
060
061 /**
062 * Sends the body to the default endpoint with the specified headers and
063 * header values
064 *
065 * @param body the payload send
066 * @return the result
067 */
068 Object sendBodyAndHeaders(Object body, Map<String, Object> headers);
069
070 // Allow sending to arbitrary endpoints
071 // -----------------------------------------------------------------------
072
073 /**
074 * Sends the exchange to the given endpoint
075 *
076 * @param endpointUri the endpoint URI to send the exchange to
077 * @param exchange the exchange to send
078 */
079 E send(String endpointUri, E exchange);
080
081 /**
082 * Sends an exchange to an endpoint using a supplied
083 *
084 * @{link Processor} to populate the exchange
085 *
086 * @param endpointUri the endpoint URI to send the exchange to
087 * @param processor the transformer used to populate the new exchange
088 */
089 E send(String endpointUri, Processor processor);
090
091 /**
092 * Sends the exchange to the given endpoint
093 *
094 * @param endpoint the endpoint to send the exchange to
095 * @param exchange the exchange to send
096 */
097 E send(Endpoint<E> endpoint, E exchange);
098
099 /**
100 * Sends an exchange to an endpoint using a supplied
101 *
102 * @{link Processor} to populate the exchange
103 *
104 * @param endpoint the endpoint to send the exchange to
105 * @param processor the transformer used to populate the new exchange
106 */
107 E send(Endpoint<E> endpoint, Processor processor);
108
109 /**
110 * Send the body to an endpoint
111 *
112 * @param endpoint
113 * @param body = the payload
114 * @return the result
115 */
116 Object sendBody(Endpoint<E> endpoint, Object body);
117
118 /**
119 * Send the body to an endpoint
120 *
121 * @param endpointUri
122 * @param body = the payload
123 * @return the result
124 */
125 Object sendBody(String endpointUri, Object body);
126
127 }