Author: jstrachan
Date: Wed Dec 10 23:51:20 2008
New Revision: 725612
URL: http://svn.apache.org/viewvc?rev=725612&view=rev
Log:
minor improvemnet to CAMEL-1171 so that we can use to(pattern, uris...) or
to(pattern, endpoints...) so if a pattern is specified with to() it is the
first parameter. Also added similar inOut(endpoints...) and inOnly(...)
methods. Finally added an extra ExchangePattern constructor argument to ToType
so that when using [inOut|inOnly](uris|endpoints) we only need a single step in
the DSL which is a tad faster & minimises copying etc
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SetExchangePatternTest.java
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java?rev=725612&r1=725611&r2=725612&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
Wed Dec 10 23:51:20 2008
@@ -139,12 +139,12 @@
/**
* Sends the exchange with certain exchange pattern to the given endpoint
*
+ * @param pattern the pattern to use for the message exchange
* @param uri the endpoint to send to
* @return the builder
*/
- public Type to(String uri, ExchangePattern ep) {
- addOutput(new SetExchangePatternType(ep));
- addOutput(new ToType(uri));
+ public Type to(ExchangePattern pattern, String uri) {
+ addOutput(new ToType(uri, pattern));
return (Type) this;
}
@@ -152,12 +152,12 @@
/**
* Sends the exchange with certain exchange pattern to the given endpoint
*
+ * @param pattern the pattern to use for the message exchange
* @param endpoint the endpoint to send to
* @return the builder
*/
- public Type to(Endpoint endpoint, ExchangePattern ep) {
- addOutput(new SetExchangePatternType(ep));
- addOutput(new ToType(endpoint));
+ public Type to(ExchangePattern pattern, Endpoint endpoint) {
+ addOutput(new ToType(endpoint, pattern));
return (Type) this;
}
@@ -174,6 +174,7 @@
return (Type) this;
}
+
/**
* Sends the exchange to a list of endpoints
*
@@ -193,7 +194,7 @@
* @param endpoints list of endpoints to send to
* @return the builder
*/
- public Type to(Collection<Endpoint> endpoints) {
+ public Type to(Iterable<Endpoint> endpoints) {
for (Endpoint endpoint : endpoints) {
addOutput(new ToType(endpoint));
}
@@ -201,6 +202,208 @@
}
+ /**
+ * Sends the exchange to a list of endpoints
+ *
+ * @param pattern the pattern to use for the message exchanges
+ * @param uris list of endpoints to send to
+ * @return the builder
+ */
+ public Type to(ExchangePattern pattern, String... uris) {
+ for (String uri : uris) {
+ addOutput(new ToType(uri, pattern));
+ }
+ return (Type) this;
+ }
+
+ /**
+ * Sends the exchange to a list of endpoints
+ *
+ * @param pattern the pattern to use for the message exchanges
+ * @param endpoints list of endpoints to send to
+ * @return the builder
+ */
+ public Type to(ExchangePattern pattern, Endpoint... endpoints) {
+ for (Endpoint endpoint : endpoints) {
+ addOutput(new ToType(endpoint, pattern));
+ }
+ return (Type) this;
+ }
+
+ /**
+ * Sends the exchange to a list of endpoints
+ *
+ * @param pattern the pattern to use for the message exchanges
+ * @param endpoints list of endpoints to send to
+ * @return the builder
+ */
+ public Type to(ExchangePattern pattern, Iterable<Endpoint> endpoints) {
+ for (Endpoint endpoint : endpoints) {
+ addOutput(new ToType(endpoint, pattern));
+ }
+ return (Type) this;
+ }
+
+
+ /**
+ * <a
href="http://activemq.apache.org/camel/exchange-pattern.html">ExchangePattern:</a>
+ * set the ExchangePattern [EMAIL PROTECTED] ExchangePattern} into the
exchange
+ *
+ * @param exchangePattern instance of [EMAIL PROTECTED] ExchangePattern}
+ * @return the builder
+ */
+ public Type setExchangePattern(ExchangePattern exchangePattern) {
+ addOutput(new SetExchangePatternType(exchangePattern));
+ return (Type) this;
+ }
+
+ /**
+ * <a
href="http://activemq.apache.org/camel/exchange-pattern.html">ExchangePattern:</a>
+ * set the exchange's ExchangePattern [EMAIL PROTECTED] ExchangePattern}
to be InOnly
+ *
+ *
+ * @return the builder
+ */
+ public Type inOnly() {
+ return setExchangePattern(ExchangePattern.InOnly);
+ }
+
+ /**
+ * Sends the message to the given endpoint using an
+ * <a href="http://activemq.apache.org/camel/event-message.html">Event
Message</a> or
+ * <a href="http://activemq.apache.org/camel/exchange-pattern.html">InOnly
exchange pattern</a>
+ *
+ * @param uri The endpoint uri which is used for sending the exchange
+ * @return the builder
+ */
+ public Type inOnly(String uri) {
+ return to(ExchangePattern.InOnly, uri);
+ }
+
+ /**
+ * Sends the message to the given endpoint using an
+ * <a href="http://activemq.apache.org/camel/event-message.html">Event
Message</a> or
+ * <a href="http://activemq.apache.org/camel/exchange-pattern.html">InOnly
exchange pattern</a>
+ *
+ * @param endpoint The endpoint which is used for sending the exchange
+ * @return the builder
+ */
+ public Type inOnly(Endpoint endpoint) {
+ return to(ExchangePattern.InOnly, endpoint);
+ }
+
+
+ /**
+ * Sends the message to the given endpoints using an
+ * <a href="http://activemq.apache.org/camel/event-message.html">Event
Message</a> or
+ * <a href="http://activemq.apache.org/camel/exchange-pattern.html">InOnly
exchange pattern</a>
+ *
+ * @param uris list of endpoints to send to
+ * @return the builder
+ */
+ public Type inOnly(String... uris) {
+ return to(ExchangePattern.InOnly, uris);
+ }
+
+
+ /**
+ * Sends the message to the given endpoints using an
+ * <a href="http://activemq.apache.org/camel/event-message.html">Event
Message</a> or
+ * <a href="http://activemq.apache.org/camel/exchange-pattern.html">InOnly
exchange pattern</a>
+ *
+ * @param endpoints list of endpoints to send to
+ * @return the builder
+ */
+ public Type inOnly(Endpoint... endpoints) {
+ return to(ExchangePattern.InOnly, endpoints);
+ }
+
+ /**
+ * Sends the message to the given endpoints using an
+ * <a href="http://activemq.apache.org/camel/event-message.html">Event
Message</a> or
+ * <a href="http://activemq.apache.org/camel/exchange-pattern.html">InOnly
exchange pattern</a>
+ *
+ * @param endpoints list of endpoints to send to
+ * @return the builder
+ */
+ public Type inOnly(Iterable<Endpoint> endpoints) {
+ return to(ExchangePattern.InOnly, endpoints);
+ }
+
+
+ /**
+ * <a
href="http://activemq.apache.org/camel/exchange-pattern.html">ExchangePattern:</a>
+ * set the exchange's ExchangePattern [EMAIL PROTECTED] ExchangePattern}
to be InOut
+ *
+ *
+ * @return the builder
+ */
+ public Type inOut() {
+ return setExchangePattern(ExchangePattern.InOut);
+ }
+
+ /**
+ * Sends the message to the given endpoint using an
+ * <a href="http://activemq.apache.org/camel/request-reply.html">Request
Reply</a> or
+ * <a href="http://activemq.apache.org/camel/exchange-pattern.html">InOut
exchange pattern</a>
+ *
+ * @param uri The endpoint uri which is used for sending the exchange
+ * @return the builder
+ */
+ public Type inOut(String uri) {
+ return to(ExchangePattern.InOut, uri);
+ }
+
+
+ /**
+ * Sends the message to the given endpoint using an
+ * <a href="http://activemq.apache.org/camel/request-reply.html">Request
Reply</a> or
+ * <a href="http://activemq.apache.org/camel/exchange-pattern.html">InOut
exchange pattern</a>
+ *
+ * @param endpoint The endpoint which is used for sending the exchange
+ * @return the builder
+ */
+ public Type inOut(Endpoint endpoint) {
+ return to(ExchangePattern.InOut, endpoint);
+ }
+
+ /**
+ * Sends the message to the given endpoints using an
+ * <a href="http://activemq.apache.org/camel/request-reply.html">Request
Reply</a> or
+ * <a href="http://activemq.apache.org/camel/exchange-pattern.html">InOut
exchange pattern</a>
+ *
+ * @param uris list of endpoints to send to
+ * @return the builder
+ */
+ public Type inOut(String... uris) {
+ return to(ExchangePattern.InOut, uris);
+ }
+
+
+ /**
+ * Sends the message to the given endpoints using an
+ * <a href="http://activemq.apache.org/camel/request-reply.html">Request
Reply</a> or
+ * <a href="http://activemq.apache.org/camel/exchange-pattern.html">InOut
exchange pattern</a>
+ *
+ * @param endpoints list of endpoints to send to
+ * @return the builder
+ */
+ public Type inOut(Endpoint... endpoints) {
+ return to(ExchangePattern.InOut, endpoints);
+ }
+
+ /**
+ * Sends the message to the given endpoints using an
+ * <a href="http://activemq.apache.org/camel/request-reply.html">Request
Reply</a> or
+ * <a href="http://activemq.apache.org/camel/exchange-pattern.html">InOut
exchange pattern</a>
+ *
+ * @param endpoints list of endpoints to send to
+ * @return the builder
+ */
+ public Type inOut(Iterable<Endpoint> endpoints) {
+ return to(ExchangePattern.InOut, endpoints);
+ }
+
/**
* <a href="http://activemq.apache.org/camel/multicast.html">Multicast
EIP:</a>
@@ -1682,84 +1885,6 @@
addOutput(new MarshalType(dataTypeRef));
return (Type) this;
}
-
- /**
- * <a
href="http://activemq.apache.org/camel/exchange-pattern.html">ExchangePattern:</a>
- * set the ExchangePattern [EMAIL PROTECTED] ExchangePattern} into the
exchange
- *
- * @param exchangePattern instance of [EMAIL PROTECTED] ExchangePattern}
- * @return the builder
- */
- public Type setExchangePattern(ExchangePattern exchangePattern) {
- addOutput(new SetExchangePatternType(exchangePattern));
- return (Type) this;
- }
-
- /**
- * <a
href="http://activemq.apache.org/camel/exchange-pattern.html">ExchangePattern:</a>
- * set the exchange's ExchangePattern [EMAIL PROTECTED] ExchangePattern}
to be InOnly
- *
- *
- * @return the builder
- */
- public Type inOnly() {
- return setExchangePattern(ExchangePattern.InOnly);
- }
-
- /**
- * <a
href="http://activemq.apache.org/camel/exchange-pattern.html">ExchangePattern:</a>
- * set the exchange's ExchangePattern [EMAIL PROTECTED] ExchangePattern}
to be InOut
- *
- *
- * @return the builder
- */
- public Type inOut() {
- return setExchangePattern(ExchangePattern.InOut);
- }
-
- /**
- * <a
href="http://activemq.apache.org/camel/exchange-pattern.html">ExchangePattern:</a>
- * set the exchange's ExchangePattern [EMAIL PROTECTED] ExchangePattern}
to be InOnly
- *
- * @param uri The endpoint uri which is used for sending the exchange
- * @return the builder
- */
- public Type inOnly(String uri) {
- return to(uri, ExchangePattern.InOnly);
- }
-
- /**
- * <a
href="http://activemq.apache.org/camel/exchange-pattern.html">ExchangePattern:</a>
- * set the exchange's ExchangePattern [EMAIL PROTECTED] ExchangePattern}
to be InOut
- *
- * @param uri The endpoint uri which is used for sending the exchange
- * @return the builder
- */
- public Type inOut(String uri) {
- return to(uri, ExchangePattern.InOut);
- }
-
- /**
- * <a
href="http://activemq.apache.org/camel/exchange-pattern.html">ExchangePattern:</a>
- * set the exchange's ExchangePattern [EMAIL PROTECTED] ExchangePattern}
to be InOnly
- *
- * @param uri The endpoint which is used for sending the exchange
- * @return the builder
- */
- public Type inOnly(Endpoint endpoint) {
- return to(endpoint, ExchangePattern.InOnly);
- }
-
- /**
- * <a
href="http://activemq.apache.org/camel/exchange-pattern.html">ExchangePattern:</a>
- * set the exchange's ExchangePattern [EMAIL PROTECTED] ExchangePattern}
to be InOut
- *
- * @param uri The endpoint which is used for sending the exchange
- * @return the builder
- */
- public Type inOut(Endpoint endpoint) {
- return to(endpoint, ExchangePattern.InOut);
- }
// Properties
//
-------------------------------------------------------------------------
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java?rev=725612&r1=725611&r2=725612&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java
Wed Dec 10 23:51:20 2008
@@ -46,6 +46,16 @@
setEndpoint(endpoint);
}
+ public ToType(String uri, ExchangePattern pattern) {
+ this(uri);
+ this.pattern = pattern;
+ }
+
+ public ToType(Endpoint endpoint, ExchangePattern pattern) {
+ this(endpoint);
+ this.pattern = pattern;
+ }
+
@Override
public String toString() {
return "To[" + getLabel() + "]";
Modified:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SetExchangePatternTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SetExchangePatternTest.java?rev=725612&r1=725611&r2=725612&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SetExchangePatternTest.java
(original)
+++
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SetExchangePatternTest.java
Wed Dec 10 23:51:20 2008
@@ -76,7 +76,7 @@
//Set the exchange pattern to InOut, then send it from
direct:inOut to mock:result endpoint
from("direct:inOut").setExchangePattern(ExchangePattern.InOnly).to("mock:result");
//Send the exchange from direct:inOut1 to mock:result with
setting the exchange pattern to be RobustInOnly
- from("direct:inOut1").to("mock:result",
ExchangePattern.RobustInOnly);
+ from("direct:inOut1").to(ExchangePattern.RobustInOnly,
"mock:result");
//Send the exchange from direct:inOut2 to mock:result with
setting the exchange pattern to be InOnly
from("direct:inOut2").inOnly("mock:result");
// END SNIPPET: example