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: 36635 $
023 */
024 public interface ProducerTemplate<E extends Exchange> extends Service {
025 /**
026 * Sends the exchange to the default endpoint
027 *
028 * @param exchange the exchange to send
029 */
030 E send(E exchange);
031
032 /**
033 * Sends an exchange to the default endpoint using a supplied
034 *
035 * @param processor the transformer used to populate the new exchange
036 * {@link Processor} to populate the exchange
037 */
038 E send(Processor processor);
039
040 /**
041 * Sends the body to the default endpoint and returns the result content
042 *
043 * @param body the body to send
044 * @return the returned message body
045 */
046 Object sendBody(Object body);
047
048 /**
049 * Sends the body to the default endpoint with a specified header and header
050 * value
051 *
052 * @param body the payload send
053 * @param header the header name
054 * @param headerValue the header value
055 * @return the result
056 */
057 Object sendBodyAndHeader(Object body, String header, Object headerValue);
058
059 /**
060 * Sends the body to the default endpoint with the specified headers and
061 * header values
062 *
063 * @param body the payload send
064 * @return the result
065 */
066 Object sendBodyAndHeaders(Object body, Map<String, Object> headers);
067
068 // Allow sending to arbitrary endpoints
069 // -----------------------------------------------------------------------
070
071 /**
072 * Sends the exchange to the given endpoint
073 *
074 * @param endpointUri the endpoint URI to send the exchange to
075 * @param exchange the exchange to send
076 */
077 E send(String endpointUri, E exchange);
078
079 /**
080 * Sends an exchange to an endpoint using a supplied
081 *
082 * @param endpointUri the endpoint URI to send the exchange to
083 * @param processor the transformer used to populate the new exchange
084 * {@link Processor} to populate the exchange
085 */
086 E send(String endpointUri, Processor processor);
087
088 /**
089 * Sends an exchange to an endpoint using a supplied
090 *
091 * @param endpointUri the endpoint URI to send the exchange to
092 * @param pattern the message {@link ExchangePattern} such as
093 * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut}
094 * @param processor the transformer used to populate the new exchange
095 * {@link Processor} to populate the exchange
096 */
097 E send(String endpointUri, ExchangePattern pattern, Processor processor);
098
099 /**
100 * Sends the exchange to the given endpoint
101 *
102 * @param endpoint the endpoint to send the exchange to
103 * @param exchange the exchange to send
104 */
105 E send(Endpoint<E> endpoint, E exchange);
106
107 /**
108 * Sends an exchange to an endpoint using a supplied
109 *
110 * @param endpoint the endpoint to send the exchange to
111 * @param processor the transformer used to populate the new exchange
112 * {@link Processor} to populate the exchange
113 */
114 E send(Endpoint<E> endpoint, Processor processor);
115
116 /**
117 * Sends an exchange to an endpoint using a supplied
118 *
119 * @param endpoint the endpoint to send the exchange to
120 * @param pattern the message {@link ExchangePattern} such as
121 * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut}
122 * @param processor the transformer used to populate the new exchange
123 * {@link Processor} to populate the exchange
124 */
125 E send(Endpoint<E> endpoint, ExchangePattern pattern, Processor processor);
126
127 /**
128 * Send the body to an endpoint
129 *
130 * @param endpoint
131 * @param body = the payload
132 * @return the result
133 */
134 Object sendBody(Endpoint<E> endpoint, Object body);
135
136 /**
137 * Send the body to an endpoint
138 *
139 * @param endpointUri
140 * @param body = the payload
141 * @return the result
142 */
143 Object sendBody(String endpointUri, Object body);
144
145 /**
146 * Send the body to an endpoint with the given {@link ExchangePattern}
147 * returning any result output body
148 *
149 * @param endpoint
150 * @param body = the payload
151 * @param pattern the message {@link ExchangePattern} such as
152 * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut}
153 * @return the result
154 */
155 Object sendBody(Endpoint<E> endpoint, ExchangePattern pattern, Object body);
156
157 /**
158 * Send the body to an endpoint
159 *
160 * @param endpointUri
161 * @param pattern the message {@link ExchangePattern} such as
162 * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut}
163 * @param body = the payload
164 * @return the result
165 */
166 Object sendBody(String endpointUri, ExchangePattern pattern, Object body);
167
168 /**
169 * Sends the body to an endpoint with a specified header and header value
170 *
171 * @param endpointUri the endpoint URI to send to
172 * @param body the payload send
173 * @param header the header name
174 * @param headerValue the header value
175 * @return the result
176 */
177 Object sendBodyAndHeader(String endpointUri, Object body, String header,
178 Object headerValue);
179
180 /**
181 * Sends the body to an endpoint with a specified header and header value
182 *
183 * @param endpoint the Endpoint to send to
184 * @param body the payload send
185 * @param header the header name
186 * @param headerValue the header value
187 * @return the result
188 */
189 Object sendBodyAndHeader(Endpoint endpoint, Object body, String header,
190 Object headerValue);
191
192 /**
193 * Sends the body to an endpoint with a specified header and header value
194 *
195 * @param endpoint the Endpoint to send to
196 * @param pattern the message {@link ExchangePattern} such as
197 * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut}
198 * @param body the payload send
199 * @param header the header name
200 * @param headerValue the header value
201 * @return the result
202 */
203 Object sendBodyAndHeader(Endpoint endpoint, ExchangePattern pattern, Object body, String header,
204 Object headerValue);
205
206 /**
207 * Sends the body to an endpoint with a specified header and header value
208 *
209 * @param endpoint the Endpoint URI to send to
210 * @param pattern the message {@link ExchangePattern} such as
211 * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut}
212 * @param body the payload send
213 * @param header the header name
214 * @param headerValue the header value
215 * @return the result
216 */
217 Object sendBodyAndHeader(String endpoint, ExchangePattern pattern, Object body, String header,
218 Object headerValue);
219
220 /**
221 * Sends the body to an endpoint with the specified headers and header
222 * values
223 *
224 * @param endpointUri the endpoint URI to send to
225 * @param body the payload send
226 * @return the result
227 */
228 Object sendBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers);
229
230 /**
231 * Sends the body to an endpoint with the specified headers and header
232 * values
233 *
234 * @param endpoint the endpoint URI to send to
235 * @param body the payload send
236 * @return the result
237 */
238 Object sendBodyAndHeaders(Endpoint endpoint, Object body, Map<String, Object> headers);
239
240
241 // Methods using an InOut ExchangePattern
242 // -----------------------------------------------------------------------
243
244 /**
245 * Send the body to an endpoint returning any result output body
246 *
247 * @param endpoint
248 * @param processor the processor which will populate the exchange before sending
249 * @return the result
250 */
251 E request(Endpoint<E> endpoint, Processor processor);
252
253 /**
254 * Send the body to an endpoint returning any result output body
255 *
256 * @param endpoint
257 * @param body = the payload
258 * @return the result
259 */
260 Object requestBody(Endpoint<E> endpoint, Object body);
261
262 /**
263 * Send the body to an endpoint returning any result output body
264 *
265 * @param endpoint
266 * @param body = the payload
267 * @param header
268 * @param headerValue
269 * @return the result
270 */
271 Object requestBodyAndHeader(Endpoint<E> endpoint, Object body, String header, Object headerValue);
272
273 /**
274 * Send the body to an endpoint returning any result output body
275 *
276 * @param endpoint
277 * @param processor the processor which will populate the exchange before sending
278 * @return the result
279 */
280 E request(String endpoint, Processor processor);
281
282 /**
283 * Send the body to an endpoint returning any result output body
284 *
285 * @param endpoint
286 * @param body = the payload
287 * @return the result
288 */
289 Object requestBody(String endpoint, Object body);
290
291 /**
292 * Send the body to an endpoint returning any result output body
293 *
294 * @param endpoint
295 * @param body = the payload
296 * @param header
297 * @param headerValue
298 * @return the result
299 */
300 Object requestBodyAndHeader(String endpoint, Object body, String header, Object headerValue);
301 }