Author: davsclaus
Date: Tue Nov 11 11:48:11 2008
New Revision: 713136
URL: http://svn.apache.org/viewvc?rev=713136&view=rev
Log:
CAMEL-1065: Aligned sendBody and requestBody methods. Polished javadoc.
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java?rev=713136&r1=713135&r2=713136&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java
Tue Nov 11 11:48:11 2008
@@ -49,7 +49,7 @@
Exchange send(Exchange exchange);
/**
- * Sends an exchange to the default endpoint using a supplied
+ * Sends an exchange to the default endpoint using a supplied processor
*
* @param processor the transformer used to populate the new exchange
* [EMAIL PROTECTED] Processor} to populate the exchange
@@ -288,12 +288,40 @@
*/
Object sendBodyAndHeaders(Endpoint endpoint, Object body, Map<String,
Object> headers);
+ /**
+ * Sends the body to an endpoint with the specified headers and header
+ * values
+ *
+ * @param endpointUri the endpoint URI to send to
+ * @param pattern the message [EMAIL PROTECTED] ExchangePattern} such as
+ * [EMAIL PROTECTED] ExchangePattern#InOnly} or [EMAIL PROTECTED]
ExchangePattern#InOut}
+ * @param body the payload to send
+ * @param headers headers
+ * @return the result (see class javadoc)
+ */
+ Object sendBodyAndHeaders(String endpointUri, ExchangePattern pattern,
Object body,
+ Map<String, Object> headers);
+
+ /**
+ * Sends the body to an endpoint with the specified headers and header
+ * values
+ *
+ * @param endpoint the endpoint URI to send to
+ * @param pattern the message [EMAIL PROTECTED] ExchangePattern} such as
+ * [EMAIL PROTECTED] ExchangePattern#InOnly} or [EMAIL PROTECTED]
ExchangePattern#InOut}
+ * @param body the payload to send
+ * @param headers headers
+ * @return the result (see class javadoc)
+ */
+ Object sendBodyAndHeaders(Endpoint endpoint, ExchangePattern pattern,
Object body,
+ Map<String, Object> headers);
+
// Methods using an InOut ExchangePattern
// -----------------------------------------------------------------------
/**
- * Send the body to an endpoint returning any result output body.
+ * Sends an exchange to an endpoint using a supplied processor
* Uses an [EMAIL PROTECTED] ExchangePattern#InOut} message exchange
pattern.
*
* @param endpoint the Endpoint to send to
@@ -303,6 +331,16 @@
Exchange request(Endpoint endpoint, Processor processor);
/**
+ * Sends an exchange to an endpoint using a supplied processor
+ * Uses an [EMAIL PROTECTED] ExchangePattern#InOut} message exchange
pattern.
+ *
+ * @param endpointUri the endpoint URI to send to
+ * @param processor the processor which will populate the exchange before
sending
+ * @return the result (see class javadoc)
+ */
+ Exchange request(String endpointUri, Processor processor);
+
+ /**
* Send the body to an endpoint returning any result output body.
* Uses an [EMAIL PROTECTED] ExchangePattern#InOut} message exchange
pattern.
*
@@ -316,6 +354,16 @@
* Send the body to an endpoint returning any result output body.
* Uses an [EMAIL PROTECTED] ExchangePattern#InOut} message exchange
pattern.
*
+ * @param endpointUri the endpoint URI to send to
+ * @param body the payload
+ * @return the result (see class javadoc)
+ */
+ Object requestBody(String endpointUri, Object body);
+
+ /**
+ * Send the body to an endpoint returning any result output body.
+ * Uses an [EMAIL PROTECTED] ExchangePattern#InOut} message exchange
pattern.
+ *
* @param endpoint the Endpoint to send to
* @param body the payload
* @param header the header name
@@ -329,31 +377,34 @@
* Uses an [EMAIL PROTECTED] ExchangePattern#InOut} message exchange
pattern.
*
* @param endpointUri the endpoint URI to send to
- * @param processor the processor which will populate the exchange before
sending
+ * @param body the payload
+ * @param header the header name
+ * @param headerValue the header value
* @return the result (see class javadoc)
*/
- Exchange request(String endpointUri, Processor processor);
+ Object requestBodyAndHeader(String endpointUri, Object body, String
header, Object headerValue);
/**
- * Send the body to an endpoint returning any result output body.
+ * Sends the body to an endpoint with the specified headers and header
+ * values.
* Uses an [EMAIL PROTECTED] ExchangePattern#InOut} message exchange
pattern.
*
* @param endpointUri the endpoint URI to send to
- * @param body the payload
+ * @param body the payload to send
+ * @param headers headers
* @return the result (see class javadoc)
*/
- Object requestBody(String endpointUri, Object body);
+ Object requestBodyAndHeaders(String endpointUri, Object body, Map<String,
Object> headers);
/**
- * Send the body to an endpoint returning any result output body.
+ * Sends the body to an endpoint with the specified headers and header
+ * values.
* Uses an [EMAIL PROTECTED] ExchangePattern#InOut} message exchange
pattern.
*
- * @param endpointUri the endpoint URI to send to
- * @param body the payload
- * @param header the header name
- * @param headerValue the header value
+ * @param endpoint the endpoint URI to send to
+ * @param body the payload to send
+ * @param headers headers
* @return the result (see class javadoc)
*/
- Object requestBodyAndHeader(String endpointUri, Object body, String
header, Object headerValue);
-
+ Object requestBodyAndHeaders(Endpoint endpoint, Object body, Map<String,
Object> headers);
}
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java?rev=713136&r1=713135&r2=713136&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java
Tue Nov 11 11:48:11 2008
@@ -160,6 +160,23 @@
return extractResultBody(result);
}
+ public Object sendBodyAndHeaders(String endpointUri, ExchangePattern
pattern, Object body, Map<String, Object> headers) {
+ return sendBodyAndHeaders(resolveMandatoryEndpoint(endpointUri),
pattern, body, headers);
+ }
+
+ public Object sendBodyAndHeaders(Endpoint endpoint, ExchangePattern
pattern, final Object body, final Map<String, Object> headers) {
+ Exchange result = send(endpoint, pattern, new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ Message in = exchange.getIn();
+ for (Map.Entry<String, Object> header : headers.entrySet()) {
+ in.setHeader(header.getKey(), header.getValue());
+ }
+ in.setBody(body);
+ }
+ });
+ return extractResultBody(result);
+ }
+
// Methods using an InOut ExchangePattern
// -----------------------------------------------------------------------
@@ -187,6 +204,14 @@
return sendBodyAndHeader(endpoint, ExchangePattern.InOut, body,
header, headerValue);
}
+ public Object requestBodyAndHeaders(String endpointUri, Object body,
Map<String, Object> headers) {
+ return requestBodyAndHeaders(resolveMandatoryEndpoint(endpointUri),
body, headers);
+ }
+
+ public Object requestBodyAndHeaders(Endpoint endpoint, final Object body,
final Map<String, Object> headers) {
+ return sendBodyAndHeaders(endpoint, ExchangePattern.InOut, body,
headers);
+ }
+
// Methods using the default endpoint
// -----------------------------------------------------------------------