You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2022/12/13 17:36:03 UTC

[camel] 03/04: (chores) documentation: reworked the Java DSL section on the getting started

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 9e1aa2e5142176faa332953daeb5a9be0e1f61b0
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Dec 13 17:12:30 2022 +0100

    (chores) documentation: reworked the Java DSL section on the getting started
---
 docs/main/modules/getting-started/pages/index.adoc | 49 +---------------------
 docs/user-manual/modules/ROOT/pages/java-dsl.adoc  | 31 +++++++++++++-
 2 files changed, 32 insertions(+), 48 deletions(-)

diff --git a/docs/main/modules/getting-started/pages/index.adoc b/docs/main/modules/getting-started/pages/index.adoc
index 2d2817c5166..c3f555f1e6c 100644
--- a/docs/main/modules/getting-started/pages/index.adoc
+++ b/docs/main/modules/getting-started/pages/index.adoc
@@ -407,54 +407,9 @@ Camel provides three ways for an application developer to specify routes:
 [[BookGettingStarted-IntroductiontoJavaDSL]]
 ==== Introduction to Java DSL
 
-For many people, the term "domain-specific language" implies a compiler
-or interpreter that can process an input file containing keywords and
-syntax specific to a particular domain. This is _not_ the approach taken
-by Camel. Camel documentation consistently uses the term "Java DSL"
-instead of "DSL", but this does not entirely avoid potential confusion.
-The Camel "Java DSL" is a class library that can be used in a way that
-looks almost like a DSL, except that it has a bit of Java syntactic
-baggage. You can see this in the example below. Comments afterwards
-explain some of the constructs used in the example.
-
-.*Example of Camel's "Java DSL"*
-[source,java]
-----
-RouteBuilder builder = new RouteBuilder() {
-    public void configure() {
-        from("queue:a").filter(header("foo").isEqualTo("bar")).to("queue:b");
-
-        from("queue:c").choice()
-                .when(header("foo").isEqualTo("bar")).to("queue:d")
-                .when(header("foo").isEqualTo("cheese")).to("queue:e")
-                .otherwise().to("queue:f");
-    }
-};
-CamelContext myCamelContext = new DefaultCamelContext();
-myCamelContext.addRoutes(builder);
-----
-
-The first line in the above example creates an object which is an
-instance of an anonymous subclass of `RouteBuilder` with the specified
-`configure()` method.
-
-The `CamelContext.addRoutes(RouterBuilder builder)` method invokes
-`builder.setContext(this)` – so the `RouteBuilder` object knows which
-`CamelContext` object it is associated with – and then invokes
-`builder.configure()`. The body of `configure()` invokes methods such as
-`from()`, `filter()`, `choice()`, `when()`, `isEqualTo()`, `otherwise()`
-and `to()`.
-
-The `RouteBuilder.from(String uri)` method invokes `getEndpoint(uri)` on
-the `CamelContext` associated with the `RouteBuilder` object to get the
-specified `Endpoint` and then puts a `FromBuilder` _wrapper_ around this
-`Endpoint`. The `FromBuilder.filter(Predicate predicate)` method creates
-a `FilterProcessor` object for the `Predicate` (that is, condition)
-object built from the `header("foo").isEqualTo("bar")` expression. In
-this way, these operations incrementally build up a `Route` object (with
-a `RouteBuilder` wrapper around it) and add it to the `CamelContext`
-object associated with the `RouteBuilder`.
+For many people, the term “domain-specific language” implies a compiler or interpreter that can process an input file containing keywords and syntax specific to a particular domain. This is not the approach taken by Camel. Our documentation consistently uses the term _“Java DSL”_ instead of “DSL”, but this does not entirely avoid potential confusion. The Camel _“Java DSL”_ is a class library that you can use in a way that looks almost like a DSL, except that it has a bit of Java syntacti [...]
 
+*Note*: our documentation contains an in-depth overview of the xref:manual::java-dsl.adoc[Java DSL].
 
 [[BookGettingStarted-ContinueLearningaboutCamel]]
 === Continue Learning about Camel
diff --git a/docs/user-manual/modules/ROOT/pages/java-dsl.adoc b/docs/user-manual/modules/ROOT/pages/java-dsl.adoc
index 88ab6929f19..17eae45cce8 100644
--- a/docs/user-manual/modules/ROOT/pages/java-dsl.adoc
+++ b/docs/user-manual/modules/ROOT/pages/java-dsl.adoc
@@ -64,4 +64,33 @@ Then we use the xref:components:eips:choice-eip.adoc[Content Based Router] EIP
 
 == More Details
 
-For more details see xref:dsl.adoc[DSL], xref:routes.adoc[Routes], and xref:processor.adoc[Processor].
\ No newline at end of file
+For more details see xref:dsl.adoc[DSL], xref:routes.adoc[Routes], and xref:processor.adoc[Processor].
+
+=== The Java DSL under the hood
+
+As mentioned in the Getting Started guide, you can use Camel's Java DSL in a way that almost looks like a DSL. For instance:
+
+*Note*: comments afterwards explain some of the constructs used in the example.
+
+.*Example of Camel's "Java DSL"*
+[source,java]
+----
+RouteBuilder builder = new RouteBuilder() {
+    public void configure() {
+        from("queue:a").filter(header("foo").isEqualTo("bar")).to("queue:b");
+
+        from("queue:c").choice()
+                .when(header("foo").isEqualTo("bar")).to("queue:d")
+                .when(header("foo").isEqualTo("cheese")).to("queue:e")
+                .otherwise().to("queue:f");
+    }
+};
+CamelContext myCamelContext = new DefaultCamelContext();
+myCamelContext.addRoutes(builder);
+----
+
+The first line in the above example creates an object which is an instance of an anonymous subclass of `RouteBuilder` with the specified `configure()` method.
+
+The `CamelContext.addRoutes(RouterBuilder builder)` method invokes `builder.setContext(this)` – so the `RouteBuilder` object knows which `CamelContext` object it is associated with – and then invokes `builder.configure()`. The body of `configure()` invokes methods such as `from()`, `filter()`, `choice()`, `when()`, `isEqualTo()`, `otherwise()` and `to()`.
+
+The `RouteBuilder.from(String uri)` method invokes `getEndpoint(uri)` on the `CamelContext` associated with the `RouteBuilder` object to get the specified `Endpoint` and then puts a `FromBuilder` _wrapper_ around this `Endpoint`. The `FromBuilder.filter(Predicate predicate)` method creates a `FilterProcessor` object for the `Predicate` (that is, condition) object built from the `header("foo").isEqualTo("bar")` expression. In this way, these operations incrementally build up a `Route` obj [...]