You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/10/19 16:15:17 UTC
[camel] branch main updated: CAMEL-18626: Java DSL to allow property placeholders in setExchangePattern
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 23b91562c8e CAMEL-18626: Java DSL to allow property placeholders in setExchangePattern
23b91562c8e is described below
commit 23b91562c8e22e1264b635e93310397b9befb1f7
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Oct 19 18:14:51 2022 +0200
CAMEL-18626: Java DSL to allow property placeholders in setExchangePattern
---
.../java/org/apache/camel/model/ProcessorDefinition.java | 16 +++++++++++++++-
.../apache/camel/processor/SetExchangePatternTest.java | 7 +++++++
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java
index cd65bebf76e..91868e4ec96 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java
@@ -588,7 +588,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
}
/**
- * <a href= "http://camel.apache.org/exchange-pattern.html">ExchangePattern:</a> set the {@link ExchangePattern}
+ * <a href="http://camel.apache.org/exchange-pattern.html">ExchangePattern:</a> set the {@link ExchangePattern}
* into the {@link Exchange}.
* <p/>
* The pattern set on the {@link Exchange} will be changed from this point going foward.
@@ -601,6 +601,20 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
return asType();
}
+ /**
+ * <a href="http://camel.apache.org/exchange-pattern.html">ExchangePattern:</a> set the {@link ExchangePattern}
+ * into the {@link Exchange}.
+ * <p/>
+ * The pattern set on the {@link Exchange} will be changed from this point going foward.
+ *
+ * @param exchangePattern the exchange pattern
+ * @return the builder
+ */
+ public Type setExchangePattern(String exchangePattern) {
+ addOutput(new SetExchangePatternDefinition(exchangePattern));
+ return asType();
+ }
+
/**
* Sends the message to the given endpoint using an <a href="http://camel.apache.org/event-message.html">Event
* Message</a> or <a href="http://camel.apache.org/exchange-pattern.html">InOnly exchange pattern</a>
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/SetExchangePatternTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/SetExchangePatternTest.java
index 94947ee3a30..4071dcba964 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/SetExchangePatternTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/SetExchangePatternTest.java
@@ -64,6 +64,11 @@ public class SetExchangePatternTest extends ContextTestSupport {
assertMessageReceivedWithPattern("direct:testSetExchangePatternInOnly", ExchangePattern.InOnly);
}
+ @Test
+ public void testSetAsString() throws Exception {
+ assertMessageReceivedWithPattern("direct:asString", ExchangePattern.InOut);
+ }
+
@Test
public void testPreserveOldMEPInOut() throws Exception {
// the mock should get an InOut MEP
@@ -156,6 +161,8 @@ public class SetExchangePatternTest extends ContextTestSupport {
// Set the exchange pattern to InOut, then send it on
from("direct:testSetExchangePatternInOnly").setExchangePattern(ExchangePattern.InOnly).to("mock:result");
// END SNIPPET: example
+
+ from("direct:asString").setExchangePattern("InOut").to("mock:result");
}
};
}