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 2020/04/21 20:07:16 UTC
[camel] branch master updated: CAMEL-14943: ToD EIP in Java DSL
should be easier to set advanced options
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new df6e5ed CAMEL-14943: ToD EIP in Java DSL should be easier to set advanced options
df6e5ed is described below
commit df6e5ed693ce3c464edecea04555e1f99f6dd005
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 21 21:25:43 2020 +0200
CAMEL-14943: ToD EIP in Java DSL should be easier to set advanced options
---
.../apache/camel/model/ProcessorDefinition.java | 11 ++++++++
.../apache/camel/model/ToDynamicDefinition.java | 21 ++++++++++++++
.../camel/processor/ToDynamicFluentTest.java | 33 ++++++++++++++++++++++
3 files changed, 65 insertions(+)
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/model/ProcessorDefinition.java b/core/camel-core-engine/src/main/java/org/apache/camel/model/ProcessorDefinition.java
index 09c4e91..d4b9db3 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/model/ProcessorDefinition.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/model/ProcessorDefinition.java
@@ -224,6 +224,17 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
/**
* Sends the exchange to the given dynamic endpoint
*
+ * @return the builder
+ */
+ public ToDynamicDefinition toD() {
+ ToDynamicDefinition answer = new ToDynamicDefinition();
+ addOutput(answer);
+ return answer;
+ }
+
+ /**
+ * Sends the exchange to the given dynamic endpoint
+ *
* @param uri the dynamic endpoint to send to (resolved using simple
* language by default)
* @return the builder
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/model/ToDynamicDefinition.java b/core/camel-core-engine/src/main/java/org/apache/camel/model/ToDynamicDefinition.java
index a3d90a3..681a7c1 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/model/ToDynamicDefinition.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/model/ToDynamicDefinition.java
@@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlTransient;
import org.apache.camel.ExchangePattern;
import org.apache.camel.builder.EndpointProducerBuilder;
+import org.apache.camel.spi.AsEndpointUri;
import org.apache.camel.spi.Metadata;
/**
@@ -90,6 +91,26 @@ public class ToDynamicDefinition extends NoOutputDefinition<ToDynamicDefinition>
// -------------------------------------------------------------------------
/**
+ * The uri of the endpoint to send to. The uri can be dynamic computed using
+ * the {@link org.apache.camel.language.simple.SimpleLanguage} expression.
+ */
+ public ToDynamicDefinition uri(@AsEndpointUri String uri) {
+ setUri(uri);
+ return this;
+ }
+
+ /**
+ * The uri of the endpoint to send to.
+ *
+ * @param endpointProducerBuilder the dynamic endpoint to send to (resolved
+ * using simple language by default)
+ */
+ public ToDynamicDefinition uri(@AsEndpointUri EndpointProducerBuilder endpointProducerBuilder) {
+ setEndpointProducerBuilder(endpointProducerBuilder);
+ return this;
+ }
+
+ /**
* Sets the optional {@link ExchangePattern} used to invoke this endpoint
*/
public ToDynamicDefinition pattern(ExchangePattern pattern) {
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/ToDynamicFluentTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/ToDynamicFluentTest.java
new file mode 100644
index 0000000..5109b500
--- /dev/null
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/ToDynamicFluentTest.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class ToDynamicFluentTest extends ToDynamicTest {
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .toD().cacheSize(5).allowOptimisedComponents(false).uri("mock:${header.foo}");
+ }
+ };
+ }
+}