You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2016/07/19 09:00:17 UTC
[1/6] camel git commit: Added debugger docs to Gitbook
Repository: camel
Updated Branches:
refs/heads/master 19b80eede -> d67a95ea2
Added debugger docs to Gitbook
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/bf9ecdc6
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/bf9ecdc6
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/bf9ecdc6
Branch: refs/heads/master
Commit: bf9ecdc637b3af626a1fce87a6949d55f764d85b
Parents: 19b80ee
Author: Andrea Cosentino <an...@gmail.com>
Authored: Tue Jul 19 10:36:31 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Tue Jul 19 10:36:31 2016 +0200
----------------------------------------------------------------------
docs/user-manual/en/SUMMARY.md | 2 +-
docs/user-manual/en/debugger.adoc | 123 +++++++++++++++++++++++
docs/user-manual/en/debugger.data/debug.png | Bin 0 -> 212850 bytes
3 files changed, 124 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/bf9ecdc6/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index 1db0dcc..312bbc6 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -13,6 +13,7 @@
* [Batch Consumer](batch-consumer.adoc)
* [BrowsableEndpoint](browsable-endpoint.adoc)
* [CamelContext](camelcontext.adoc)
+ * [Debugger](debugger.adoc)
* [Dozer Type Conversion](dozer-type-conversion.adoc)
* [Endpoint](endpoint.adoc)
* [Exchange](exchange.adoc)
@@ -25,7 +26,6 @@
<!--
* [AOP](aop.adoc)
* [Camel-Core](camel-core.adoc)
- * [Debugger](debugger.adoc)
* [Delay Interceptor](delay-interceptor.adoc)
* [Dependency Injection](dependency-injections.adoc)
* [DSL](dsl.adoc)
http://git-wip-us.apache.org/repos/asf/camel/blob/bf9ecdc6/docs/user-manual/en/debugger.adoc
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/debugger.adoc b/docs/user-manual/en/debugger.adoc
new file mode 100644
index 0000000..d69fe3c
--- /dev/null
+++ b/docs/user-manual/en/debugger.adoc
@@ -0,0 +1,123 @@
+[[Debugger-Debugger]]
+Debugger
+~~~~~~~~
+
+*Available as of Camel 2.6*
+
+Camel link:debugger.html[Debugger] is much related to
+link:tracer.html[Tracer], in fact they are sisters. Debugger is a
+enhanced tracer with a debugger framework so that tooling can be
+developed to easily monitor Camel routes, trace messages and set
+breakpoints at points in a route etc.
+
+TIP:There is also a link:backlogdebugger.html[BacklogDebugger] which allows
+to debug from JMX, and 3rd party tooling.
+
+[[Debugger-AbouttheDebugger]]
+About the Debugger
+^^^^^^^^^^^^^^^^^^
+
+The Debugger allows tooling or the likes to attach breakpoints which is
+being invoked when link:exchange.html[Exchange]s is being routed.
+
+[[Debugger-Defaultimplementation]]
+Default implementation
+^^^^^^^^^^^^^^^^^^^^^^
+
+Camel provides a default implementation
+`org.apache.camel.impl.DefaultDebugger` which you can set on the
+`CamelContext` using the `setDebugger` method. +
+ Likewise you can get hold of the link:debugger.html[Debugger] using the
+`getDebugger` method on `CamelContext`.
+
+The `org.apache.camel.spi.Debugger` has methods to attach and remove
+breakpoints. And to suspend/resume all breakpoints etc. +
+ You can also attach a condition to the breakpoint so it only reacts if
+the condition matches.
+
+[[Debugger-EasilydebuggingCamelroutesfromcamel-test]]
+Easily debugging Camel routes from `camel-test`
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+If you are developing unit tests using the `camel-test` component, then
+the link:debugger.html[Debugger] comes out of the box. +
+ From *Camel 2.9* onwards you would need to explicit enable the
+debugger, by overriding `isUseDebugger()` method and return `true`.
+
+[[Debugger-Example]]
+Example
++++++++
+
+In this unit test
+
+[source,java]
+-----------------------------------------------
+public class DebugTest extends CamelTestSupport
+-----------------------------------------------
+
+We want to debug the following route
+
+[source,java]
+-----------------------------------------------
+@Override
+protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // this is the route we want to debug
+ from("direct:start")
+ .to("mock:a")
+ .transform(body().prepend("Hello "))
+ .to("mock:b");
+ }
+ };
+}
+-----------------------------------------------
+
+Which can easily done by overriding the `debugBefore` method as shown
+
+[source,java]
+-----------------------------------------------
+@Override
+public boolean isUseDebugger() {
+ // must enable debugger
+ return true;
+}
+
+@Override
+protected void debugBefore(Exchange exchange, Processor processor,
+ ProcessorDefinition<?> definition, String id, String shortName) {
+ // this method is invoked before we are about to enter the given processor
+ // from your Java editor you can just add a breakpoint in the code line below
+ log.info("Before " + definition + " with body " + exchange.getIn().getBody());
+}
+-----------------------------------------------
+
+Then from your Java editor just add a breakpoint inside the
+`debugBefore` method. Then fire up the unit test and wait for the Java
+editor to hit the breakpoint. Then you can inspect the
+link:exchange.html[Exchange] during debugging while it advances during
+routing. The `ProcessorDefinition` and the `id` and `shortName`
+parameters is all information which tells you where in the route the
+breakpoint was hit.
+
+TIP:There is also a `debugAfter` method which is invoked after the processor
+has been invoked. This allows you to _see_ what happens to the
+link:exchange.html[Exchange] right after it has invoked a processor in
+the route.
+
+The screenshot below shows the link:debugger.html[Debugger] in action.
+The IDE (IDEA) has hit the breakpoint and we can inspect the
+parameters. +
+ Notice how we can see that the message is to be send to the "mock:a"
+endpoint.
+
+image:debugger.data/debug.png[image]
+
+[[Debugger-SeeAlso]]
+See Also
+^^^^^^^^
+
+* link:tracer.html[Tracer]
+* link:backlogdebugger.html[BacklogDebugger]
+
http://git-wip-us.apache.org/repos/asf/camel/blob/bf9ecdc6/docs/user-manual/en/debugger.data/debug.png
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/debugger.data/debug.png b/docs/user-manual/en/debugger.data/debug.png
new file mode 100644
index 0000000..953edce
Binary files /dev/null and b/docs/user-manual/en/debugger.data/debug.png differ
[2/6] camel git commit: Added delay-interceptor docs to Gitbook
Posted by ac...@apache.org.
Added delay-interceptor docs to Gitbook
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6e55d2a1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6e55d2a1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6e55d2a1
Branch: refs/heads/master
Commit: 6e55d2a1bd9694aa7c74c814f3bde817ee3c3610
Parents: bf9ecdc
Author: Andrea Cosentino <an...@gmail.com>
Authored: Tue Jul 19 10:39:13 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Tue Jul 19 10:39:13 2016 +0200
----------------------------------------------------------------------
docs/user-manual/en/SUMMARY.md | 2 +-
docs/user-manual/en/delay-interceptor.adoc | 87 +++++++++++++++++++++++++
2 files changed, 88 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/6e55d2a1/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index 312bbc6..cf1ef2d 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -14,6 +14,7 @@
* [BrowsableEndpoint](browsable-endpoint.adoc)
* [CamelContext](camelcontext.adoc)
* [Debugger](debugger.adoc)
+ * [Delay Interceptor](delay-interceptor.adoc)
* [Dozer Type Conversion](dozer-type-conversion.adoc)
* [Endpoint](endpoint.adoc)
* [Exchange](exchange.adoc)
@@ -26,7 +27,6 @@
<!--
* [AOP](aop.adoc)
* [Camel-Core](camel-core.adoc)
- * [Delay Interceptor](delay-interceptor.adoc)
* [Dependency Injection](dependency-injections.adoc)
* [DSL](dsl.adoc)
* [Error Handler](.adoc)
http://git-wip-us.apache.org/repos/asf/camel/blob/6e55d2a1/docs/user-manual/en/delay-interceptor.adoc
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/delay-interceptor.adoc b/docs/user-manual/en/delay-interceptor.adoc
new file mode 100644
index 0000000..72d8b5b
--- /dev/null
+++ b/docs/user-manual/en/delay-interceptor.adoc
@@ -0,0 +1,87 @@
+[[DelayInterceptor-DelayInterceptor]]
+Delay Interceptor
+~~~~~~~~~~~~~~~~~
+
+*Available in Camel 1.5*
+
+The Delay interceptor is an route interceptor that is used for slowing
+processing of messages down. This allows you to enable this interceptor
+and set a fixed amount of delay between each step a message passes in
+the route path, to show how things is happening nice and slowly, so you
+are not bombarded with a zillion lines of logging output.
+
+The delay interceptor can be configured as follows:
+
+* setting the delay attribute in the spring camelContext tag.
+* adding the delay interceptor to the CamelContext in Java code.
+
+[[DelayInterceptor-ConfiguringusingSpring]]
+Configuring using Spring
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+Just set the delay attribute of the camelContext tag as shown below:
+
+[source,xml]
+--------------------------------------------------------------------------------------------------
+ <camelContext id="camel" delayer="500" xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="direct:start"/>
+ <to uri="mock:result"/>
+ </route>
+ </camelContext>
+--------------------------------------------------------------------------------------------------
+
+[[DelayInterceptor-ConfiguringusingJava]]
+Configuring using Java
+^^^^^^^^^^^^^^^^^^^^^^
+
+You can add the delayer interceptor in the RouteBulder as shown below:
+
+[source,java]
+------------------------------------------------------------------
+ public void configure() throws Exception {
+ // add the delay interceptor to delay each step 200 millis
+ getContext().addInterceptStrategy(new Delayer(200));
+
+ ... // regular routes here
+ }
+------------------------------------------------------------------
+
+In *Camel 2.0* its a bit easier as you can just do
+
+[source,java]
+-----------------------------
+getContext().setDelayer(200);
+-----------------------------
+
+[[DelayInterceptor-Granularity]]
+Granularity
+^^^^^^^^^^^
+
+In *Camel 2.0* you can configure it on both camel context and per route
+as you like. Per route will override the camel context setting. +
+ For example the route below is only the first route that has a delayer
+with 200 millis.
+
+[source,java]
+------------------------
+<camelContext ...>
+
+ <route delayer="200">
+ ...
+ </route>
+
+ <route>
+ ...
+ </route>
+
+</camelContext>
+------------------------
+
+[[DelayInterceptor-SeeAlso]]
+See Also
+^^^^^^^^
+
+* link:tracer.html[Tracer]
+* link:debugger.html[Debugger]
+
[6/6] camel git commit: Added Java-DSL docs to Gitbook
Posted by ac...@apache.org.
Added Java-DSL docs to Gitbook
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d67a95ea
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d67a95ea
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d67a95ea
Branch: refs/heads/master
Commit: d67a95ea21127efdbd89bc0fde33e15ddff776e3
Parents: 70d6968
Author: Andrea Cosentino <an...@gmail.com>
Authored: Tue Jul 19 10:57:42 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Tue Jul 19 10:57:42 2016 +0200
----------------------------------------------------------------------
docs/user-manual/en/SUMMARY.md | 1 +
docs/user-manual/en/java-dsl.adoc | 200 +++++++++++++++++++++++++++++++++
2 files changed, 201 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/d67a95ea/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index 448836f..bb215ef 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -18,6 +18,7 @@
* [Dependency Injection](dependency-injection.adoc)
* [Dozer Type Conversion](dozer-type-conversion.adoc)
* [DSL](dsl.adoc)
+ * [Java DSL](java-dsl.adoc)
* [Groovy DSL](groovy-dsl.adoc)
* [Endpoint](endpoint.adoc)
* [Exchange](exchange.adoc)
http://git-wip-us.apache.org/repos/asf/camel/blob/d67a95ea/docs/user-manual/en/java-dsl.adoc
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/java-dsl.adoc b/docs/user-manual/en/java-dsl.adoc
new file mode 100644
index 0000000..60a6681
--- /dev/null
+++ b/docs/user-manual/en/java-dsl.adoc
@@ -0,0 +1,200 @@
+[[JavaDSL-JavaDSL]]
+Java DSL
+~~~~~~~~
+
+Apache Camel offers a Java based DSL using the fluent builder style. The
+Java DSL is available by extending the
+link:routebuilder.html[RouteBuilder] class, and implement the
+`configure` method.
+
+This is best illustrate by an example. In the code below we create a new
+class called `MyRouteBuilder` that extends the
+`org.apache.camel.builder.RouteBuilder` from Camel. +
+ In the `configure` method the Java DSL is at our disposal.
+
+[source,java]
+-------------------------------------------------------------------------
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * A Camel Java DSL Router
+ */
+public class MyRouteBuilder extends RouteBuilder {
+
+ /**
+ * Let's configure the Camel routing rules using Java code...
+ */
+ public void configure() {
+
+ // here is a sample which processes the input files
+ // (leaving them in place - see the 'noop' flag)
+ // then performs content based routing on the message using XPath
+ from("file:src/data?noop=true")
+ .choice()
+ .when(xpath("/person/city = 'London'"))
+ .to("file:target/messages/uk")
+ .otherwise()
+ .to("file:target/messages/others");
+ }
+
+}
+-------------------------------------------------------------------------
+
+In the `configure` method we can define Camel link:routes.html[Routes].
+In the example above we have a single route, which pickup
+https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=CAMEL&title=File&linkCreation=true&fromPageId=30747520[File]s,
+(eg the from).
+
+[source,java]
+---------------------------------------
+ from("file:src/data?noop=true")
+---------------------------------------
+
+Then we use the link:content-based-router.html[Content Based Router] (eg
+the choice) to route the message depending if the person is from London
+or not.
+
+[source,java]
+-------------------------------------------------------
+ .choice()
+ .when(xpath("/person/city = 'London'"))
+ .to("file:target/messages/uk")
+ .otherwise()
+ .to("file:target/messages/others");
+-------------------------------------------------------
+
+[[JavaDSL-Routes]]
+Routes
+~~~~~~
+
+Camel supports the definition of routing rules using a Java
+link:dsl.html[DSL] (domain specific language) which avoids the need for
+cumbersome XML using a link:routebuilder.html[RouteBuilder].
+
+For example a simple route can be created as follows.
+
+[source,java]
+-------------------------------------------------------
+RouteBuilder builder = new RouteBuilder() {
+ public void configure() {
+ errorHandler(deadLetterChannel("mock:error"));
+
+ from("direct:a").to("direct:b");
+ }
+};
+-------------------------------------------------------
+
+As you can see from the above Camel uses link:uris.html[URIs] to wire
+endpoints together.
+
+[[JavaDSL-URIStringformatting]]
+URI String formatting
+^^^^^^^^^^^^^^^^^^^^^
+
+*Available as of Camel 2.0*
+
+If you have endpoint URIs that accept options and you want to be able to
+substitute the value, e.g. build the URI by concat the strings together,
+then you can use the `java.lang.String.format` method. But in Camel 2.0
+we have added two convenient methods in the Java DSL so you can do
+`fromF` and `toF` that uses String formatting to build the URI.
+
+[source,java]
+-------------------------------------------------------
+from("direct:start").toF("file://%s?fileName=%s", path, name);
+
+fromF("file://%s?include=%s", path, pattern).toF("mock:%s", result);
+-------------------------------------------------------
+
+[[JavaDSL-Filters]]
+Filters
+^^^^^^^
+
+You can combine simple routes with filters which can be arbitrary
+link:predicate.html[Predicate] implementations.
+
+[source,java]
+-------------------------------------------------------
+RouteBuilder builder = new RouteBuilder() {
+ public void configure() {
+ errorHandler(deadLetterChannel("mock:error"));
+
+ from("direct:a")
+ .filter(header("foo").isEqualTo("bar"))
+ .to("direct:b");
+ }
+};
+-------------------------------------------------------
+
+[[JavaDSL-Choices]]
+Choices
+^^^^^^^
+
+With a choice you provide a list of predicates and outcomes along with
+an optional default otherwise clause which is invoked if none of the
+conditions are met.
+
+[source,java]
+-------------------------------------------------------
+RouteBuilder builder = new RouteBuilder() {
+ public void configure() {
+ errorHandler(deadLetterChannel("mock:error"));
+
+ from("direct:a")
+ .choice()
+ .when(header("foo").isEqualTo("bar"))
+ .to("direct:b")
+ .when(header("foo").isEqualTo("cheese"))
+ .to("direct:c")
+ .otherwise()
+ .to("direct:d");
+ }
+};
+-------------------------------------------------------
+
+[[JavaDSL-Usingacustomprocessor]]
+Using a custom processor
+++++++++++++++++++++++++
+
+Here is an example of using a custom link:processor.html[Processor]
+
+[source,java]
+-------------------------------------------------------
+myProcessor = new Processor() {
+ public void process(Exchange exchange) {
+ log.debug("Called with exchange: " + exchange);
+ }
+};
+
+RouteBuilder builder = new RouteBuilder() {
+ public void configure() {
+ errorHandler(deadLetterChannel("mock:error"));
+
+ from("direct:a")
+ .process(myProcessor);
+ }
+};
+-------------------------------------------------------
+
+You can mix and match custom processors with filters and choices.
+
+[source,java]
+-------------------------------------------------------
+RouteBuilder builder = new RouteBuilder() {
+ public void configure() {
+ errorHandler(deadLetterChannel("mock:error"));
+
+ from("direct:a")
+ .filter(header("foo").isEqualTo("bar"))
+ .process(myProcessor);
+ }
+};
+-------------------------------------------------------
+
+[[JavaDSL-SeeAlso]]
+See Also
+^^^^^^^^
+
+* link:dsl.html[DSL]
+* link:examples.html[Examples]
+
[5/6] camel git commit: Added DSL and Groovy-DSL docs to Gitbook
Posted by ac...@apache.org.
Added DSL and Groovy-DSL docs to Gitbook
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/70d6968f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/70d6968f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/70d6968f
Branch: refs/heads/master
Commit: 70d6968fd5c2a79f2eb874bf6a854d8d3aaf58c3
Parents: b308eda
Author: Andrea Cosentino <an...@gmail.com>
Authored: Tue Jul 19 10:50:00 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Tue Jul 19 10:50:00 2016 +0200
----------------------------------------------------------------------
docs/user-manual/en/SUMMARY.md | 3 +-
docs/user-manual/en/dsl.adoc | 44 ++++
docs/user-manual/en/groovy-dsl.adoc | 402 +++++++++++++++++++++++++++++++
3 files changed, 448 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/70d6968f/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index 610d9d4..448836f 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -17,6 +17,8 @@
* [Delay Interceptor](delay-interceptor.adoc)
* [Dependency Injection](dependency-injection.adoc)
* [Dozer Type Conversion](dozer-type-conversion.adoc)
+ * [DSL](dsl.adoc)
+ * [Groovy DSL](groovy-dsl.adoc)
* [Endpoint](endpoint.adoc)
* [Exchange](exchange.adoc)
* [Exchange Pattern](exchange-pattern.adoc)
@@ -28,7 +30,6 @@
<!--
* [AOP](aop.adoc)
* [Camel-Core](camel-core.adoc)
- * [DSL](dsl.adoc)
* [Error Handler](.adoc)
* [Expression](.adoc)
* [Injector](.adoc)
http://git-wip-us.apache.org/repos/asf/camel/blob/70d6968f/docs/user-manual/en/dsl.adoc
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/dsl.adoc b/docs/user-manual/en/dsl.adoc
new file mode 100644
index 0000000..31f10ad
--- /dev/null
+++ b/docs/user-manual/en/dsl.adoc
@@ -0,0 +1,44 @@
+[[DSL-DSL]]
+DSL
+~~~
+
+Camel uses a Java _Domain Specific Language_ or DSL for creating
+link:enterprise-integration-patterns.html[Enterprise Integration
+Patterns] or link:routes.html[Routes] in a variety of domain-specific
+languages (DSL) as listed below.
+
+* link:java-dsl.html[Java DSL] - A Java based DSL using the fluent
+builder style.
+* link:spring.html[Spring XML] - A XML based DSL in Spring XML files
+* link:using-osgi-blueprint-with-camel.html[Blueprint XML] - A XML based
+DSL in OSGi Blueprint XML files
+* link:rest-dsl.html[Rest DSL] - A DSL to define REST services using a
+REST style in either Java or XML.
+* link:groovy-dsl.html[Groovy DSL] - A Groovy based DSL using Groovy
+programming language
+* link:scala-dsl.html[Scala DSL] - A Scala based DSL using Scala
+programming language
+* link:bean-integration.html[Annotation DSL] - Use annotations in Java
+beans.
+* https://github.com/koolio/kool/tree/master/kool-camel[Kotlin DSL] -
+*Work in progress* - Currently developed outside ASF, but will we
+included later in Camel when Kotlin and the DSL is ready.
+
+The main entry points for the DSL are
+
+* link:camelcontext.html[CamelContext] for creating a Camel routing
+rulebase
+* link:routebuilder.html[RouteBuilder] for creating a collection of
+routes using the routing DSL
+
+[[DSL-SeeAlso]]
+See Also
+^^^^^^^^
+
+For more examples of the DSL in action see
+
+* link:enterprise-integration-patterns.html[Enterprise Integration
+Patterns]
+* link:examples.html[Examples]
+* link:routes.html[Routes]
+
http://git-wip-us.apache.org/repos/asf/camel/blob/70d6968f/docs/user-manual/en/groovy-dsl.adoc
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/groovy-dsl.adoc b/docs/user-manual/en/groovy-dsl.adoc
new file mode 100644
index 0000000..8f3c126
--- /dev/null
+++ b/docs/user-manual/en/groovy-dsl.adoc
@@ -0,0 +1,402 @@
+[[GroovyDSL-AbouttheGroovyDSL]]
+About the Groovy DSL
+^^^^^^^^^^^^^^^^^^^^
+
+The Groovy DSL implementation is built on top of the existing Java-based
+link:dsl.html[DSL], but it additionally allows to use Groovy language
+features in your routes, particularly
+http://www.groovy-lang.org/closures.html[Closures] acting as
+link:processor.html[Processor], link:expression.html[Expression],
+link:predicate.html[Predicate], or link:aggregator.html[Aggregation
+Strategy]. +
+ With the Groovy DSL you write your RouteBuilder classes entirely in
+Groovy, while the link:scripting-languages.html[scripting component]
+allows to embed small scripts into Java routes. The Groovy DSL requires
+Groovy 2.0 or newer and is available as of *Camel 2.11*.
+
+[[GroovyDSL-Introduction]]
+Introduction
+^^^^^^^^^^^^
+
+Because Groovy is syntactically very similar to Java, you can write your
+Groovy routes just like Java routes. The same Java DSL classes are being
+used, with the exception that some of the DSL classes get extended with
+a bunch of new methods at runtime. This is achieved by turning
+camel-groovy into a Groovy
+http://docs.codehaus.org/display/GROOVY/Creating+an+extension+module[Extension
+Module] that defines extension methods on existing classes.
+
+The majority of the extension methods allow
+http://www.groovy-lang.org/closures.html[Closures] to be used as
+parameters e.g. for expressions, predicates, processors. The following
+example reverses a string in the message body and then prints the value
+to System.out:
+
+*MyRouteBuilder.groovy*
+
+[source,java]
+-----------------------------------------
+...
+ from('direct:test')
+ .transform { it.in.body.reverse() }
+ .process { println it.in.body }
+...
+-----------------------------------------
+
+The corresponding route in Java would look something like this:
+
+*MyRouteBuilder.java*
+
+[source,java]
+-----------------------------------------------------------------------------------------
+...
+ from("direct:test")
+ .transform(new Expression() {
+ @Override
+ public Object evaluate(Exchange e) {
+ return new StringBuffer(e.getIn().getBody().toString()).reverse().toString();
+ }
+ })
+ .process(new Processor() {
+ @Override
+ public void process(Exchange e) {
+ System.out.println(e.getIn().getBody());
+ }
+ });
+...
+-----------------------------------------------------------------------------------------
+
+[[GroovyDSL-DevelopingwiththeGroovyDSL]]
+Developing with the Groovy DSL
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+To be able to use the Groovy DSL in your camel routes you need to add
+the a dependency on *camel-groovy* which implements the Groovy DSL.
+
+If you use Maven you can just add the following to your pom.xml,
+substituting the version number for the latest & greatest release (see
+the download page for the latest versions).
+
+[source,xml]
+---------------------------------------
+<dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-groovy</artifactId>
+ <version>2.11.0</version>
+</dependency>
+---------------------------------------
+
+Additionally you need to make sure that the Groovy classes will be
+compiled. You can either use gmaven for this or, particularly with mixed
+projects containing Java and Groovy code, you might want to use the
+http://groovy.codehaus.org/Groovy-Eclipse+compiler+plugin+for+Maven[Groovy
+Eclipse compiler]:
+
+[source,xml]
+--------------------------------------------------------
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerId>groovy-eclipse-compiler</compilerId>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-eclipse-compiler</artifactId>
+ <version>2.7.0-01</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+--------------------------------------------------------
+
+As Eclipse user, you might want to configure the Maven Eclipse plugin in
+a way so that your project is set up correctly for using
+http://groovy.codehaus.org/Eclipse+Plugin[Eclipse Plugin for Groovy]
+when `mvn eclipse:eclipse` is executed:
+
+[source,xml]
+----------------------------------------------------------------------------------------
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <additionalProjectnatures>
+ <projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature>
+ </additionalProjectnatures>
+ <classpathContainers>
+ <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
+ <classpathContainer>GROOVY_DSL_SUPPORT</classpathContainer>
+ </classpathContainers>
+ </configuration>
+ </plugin>
+----------------------------------------------------------------------------------------
+
+[[GroovyDSL-UsingClosuresinyourroutes]]
+Using Closures in your routes
++++++++++++++++++++++++++++++
+
+Groovy closures can be used to write concise implementations of Camel
+processors, expressions, predicates, and aggregation strategies. It is
+recommended to keep more complicated implementations of these objects in
+their own classes, e.g. to be able to test them more easily and not to
+clutter up your routes with business logic.
+
+[[GroovyDSL-ProcessorClosures]]
+Processor Closures
+
+All Java DSL parameters of type `org.apache.camel.Processor` can be
+replaced by a closure that accepts an object of type
+`org.apache.camel.Exchange` as only parameter. The return value of the
+closure is disregarded. All closures may also refer to variables not
+listed in their parameter list. Example:
+
+[source,java]
+------------------------------------------------------------------------------
+...
+ private String someValue
+...
+ from('direct:test')
+ .process { Exchange exchange -> println (exchange.in.body + someValue) }
+ .process { println (it.in.body + someValue) } // equivalent
+...
+------------------------------------------------------------------------------
+
+[[GroovyDSL-ExpressionClosures]]
+Expression Closures
+
+All Java DSL parameters of type `org.apache.camel.Expression` can be
+replaced by a closure that accepts an object of type
+`org.apache.camel.Exchange` as only parameter. The return value of the
+closure is the result of the expression. Example:
+
+[source,java]
+-----------------------------------------------------
+...
+ private String someValue
+...
+ from('direct:test')
+ .transform { it.in.body.reverse() + someValue }
+ .setHeader("myHeader") { someValue.reverse() }
+...
+-----------------------------------------------------
+
+[[GroovyDSL-PredicateClosures]]
+Predicate Closures
+
+All Java DSL parameters of type `org.apache.camel.Predicate` can be
+replaced by a closure that accepts an object of type
+`org.apache.camel.Exchange` as only parameter. The return value of the
+closure is translated into a boolean value representing the result of
+the predicate. Example:
+
+[source,java]
+------------------------------------------------------
+...
+ private String someValue
+
+ // This time, the closure is stored in a variable
+ def pred = { Exchange e -> e.in.body != someValue }
+...
+ from('direct:test')
+ .filter(pred)
+...
+------------------------------------------------------
+
+[[GroovyDSL-AggregationStrategyClosures]]
+Aggregation Strategy Closures
+
+Java DSL parameters of type
+`org.apache.camel.processor.aggregate.AggregationStrategy` can be
+replaced by a closure that accepts two objects of type
+`org.apache.camel.Exchange` representing the two Exchanges to be
+aggregated. The return value of the closure must be the aggregated
+Exchange. Example:
+
+[source,java]
+-------------------------------------------------------------------------
+...
+ private String separator
+...
+ from('direct:test1')
+ .enrich('direct:enrich') { Exchange original, Exchange resource ->
+ original.in.body += resource.in.body + separator
+ original // don't forget to return resulting exchange
+ }
+...
+-------------------------------------------------------------------------
+
+[[GroovyDSL-Genericclosurebridges]]
+Generic closure bridges
+
+In addition to the above-mentioned DSL extensions, you can use closures
+even if no DSL method signature with closure parameters is available.
+Assuming there's no `filter(Closure)` method, you could instead write:
+
+[source,java]
+---------------------------------------------------------
+...
+ private String someValue
+
+ // This time, the closure is stored in a variable
+ def pred = { Exchange e -> e.in.body != someValue }
+...
+ from('direct:test')
+ // predicate(Closure) -> org.apache.camel.Predicate
+ .filter(predicate(pred))
+...
+---------------------------------------------------------
+
+Similarly, `expression(Closure)` returns a Camel expression,
+`processor(Closure)` returns a Processor, and `aggregator(Closure)`
+returns an AggregationStrategy.
+
+[[GroovyDSL-UsingGroovyXMLprocessing]]
+Using Groovy XML processing
++++++++++++++++++++++++++++
+
+Groovy provides special http://groovy-lang.org/processing-xml.html[XML
+processing support] through its `XmlParser`, `XmlNodePrinter` and
+`XmlSlurper` classes. camel-groovy provides two
+link:data-format.html[data formats] to use these classes directly in
+your routes.
+
+*Unmarshal XML with XmlParser*
+
+[source,java]
+-----------------------------------------------------
+...
+ from('direct:test1')
+ .unmarshal().gnode()
+ // message body is now of type groovy.util.Node
+...
+-----------------------------------------------------
+
+By default, XML processing is _namespace-aware_. You can change this by
+providing a boolean `false` parameter.
+
+*Unmarshal XML with XmlSlurper*
+
+[source,java]
+---------------------------------------------------------------------------
+...
+ from('direct:test1')
+ .unmarshal().gpath(false) // explicitly namespace-unaware
+ // message body is now of type groovy.util.slurpersupport.GPathResult
+...
+---------------------------------------------------------------------------
+
+Currently, marshalling is only supported for `groovy.util.Node` objects.
+
+*Marshal XML with XmlNodePrinter*
+
+[source,java]
+------------------------------------------------------
+...
+ from('direct:test1')
+ // message body must be of type groovy.util.Node
+ .marshal().gnode()
+...
+------------------------------------------------------
+
+[[GroovyDSL-UsingGroovyGStrings]]
+Using Groovy GStrings
++++++++++++++++++++++
+
+Groovy
+http://docs.groovy-lang.org/latest/html/documentation/index.html#all-strings[GStrings]
+are declared inside double-quotes and can contain arbitrary Groovy
+expressions like accessing properties or calling methods, e.g.
+
+[source,java]
+-----------------------------------------
+def x = "It is currently ${ new Date() }"
+-----------------------------------------
+
+Because GStrings aren't Strings, camel-groovy adds the necessary
+link:type-converter.html[TypeConverter] to automatically turn them into
+the required type.
+
+[[GroovyDSL-CustomDSLextensions]]
+Custom DSL extensions
++++++++++++++++++++++
+
+You can easily define your custom extensions - be it as a Java DSL
+extension for your Groovy routes or for any other class unrelated to
+Camel. All you have to do is to write your extension methods and provide
+a extension module descriptor - the details are described in the
+http://www.groovy-lang.org/metaprogramming.html#_extension_modules[Groovy
+documentation]. And as long as you don't require other extension
+methods, you can even use plain Java code to achieve this! +
+ As an example, let's write two DSL extensions to make commonly used DSL
+methods more concise:
+
+*MyExtension.java*
+
+[source,java]
+-------------------------------------------------------------------------------------------------------------------------------
+import org.apache.camel.Endpoint;
+import org.apache.camel.Predicate;
+
+public final class MyExtension {
+ private MyExtension() {
+ // Utility Class
+ }
+
+ // Set the id of a route to its consumer URI
+ public static RouteDefinition fromId(RouteDefinition delegate, String uri) {
+ return delegate.from(uri).routeId(uri);
+ }
+
+ public static RouteDefinition fromId(RouteDefinition delegate, Endpoint endpoint) {
+ return delegate.from(endpoint).routeId(endpoint.getEndpointUri());
+ }
+
+ // Make common choice pattern more concise
+
+ public static ProcessorDefinition<?> fork(ProcessorDefinition<?> delegate, String uri1, String uri2, Predicate predicate) {
+ return delegate.choice().when(predicate).to(uri1).otherwise().to(uri2);
+ }
+
+}
+-------------------------------------------------------------------------------------------------------------------------------
+
+Add a corresponding extension module descriptor to `META-INF/services`:
+
+*META-INF/services/org.codehaus.groovy.runtime.ExtensionModule*
+
+[source,java]
+----------------------------
+moduleName=my-extension
+moduleVersion=2.11
+extensionClasses=MyExtension
+staticExtensionClasses=
+----------------------------
+
+And now your Groovy route can look like this:
+
+*MyRoute.groovy*
+
+[source,java]
+------------------------------------------------------------
+...
+ fromId('direct:test1')
+ .fork('direct:null','direct:not-null',body().isNull())
+...
+------------------------------------------------------------
+
+Using the plain Java DSL, the route would look something like this:
+
+*MyRoute.java*
+
+[source,java]
+-----------------------------------
+...
+ from("direct:test1")
+ .routeId("direct:test1")
+ .choice()
+ .when(body().isNull())
+ .to("direct:null")
+ .otherwise()
+ .to("direct:not-null");
+...
+-----------------------------------
[4/6] camel git commit: Fix typo in dependency injection link in
Gitbook
Posted by ac...@apache.org.
Fix typo in dependency injection link in Gitbook
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b308eda1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b308eda1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b308eda1
Branch: refs/heads/master
Commit: b308eda1dceccc29ea3b0157149b71a261df2e25
Parents: 0a70406
Author: Andrea Cosentino <an...@gmail.com>
Authored: Tue Jul 19 10:43:50 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Tue Jul 19 10:43:50 2016 +0200
----------------------------------------------------------------------
docs/user-manual/en/SUMMARY.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/b308eda1/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index 1b3d94c..610d9d4 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -15,7 +15,7 @@
* [CamelContext](camelcontext.adoc)
* [Debugger](debugger.adoc)
* [Delay Interceptor](delay-interceptor.adoc)
- * [Dependency Injection](dependency-injections.adoc)
+ * [Dependency Injection](dependency-injection.adoc)
* [Dozer Type Conversion](dozer-type-conversion.adoc)
* [Endpoint](endpoint.adoc)
* [Exchange](exchange.adoc)
[3/6] camel git commit: Added dependency injections docs to Gitbook
Posted by ac...@apache.org.
Added dependency injections docs to Gitbook
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0a70406d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0a70406d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0a70406d
Branch: refs/heads/master
Commit: 0a70406d0f7f79be4a69efcbefba6c577b9b20cf
Parents: 6e55d2a
Author: Andrea Cosentino <an...@gmail.com>
Authored: Tue Jul 19 10:41:25 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Tue Jul 19 10:41:25 2016 +0200
----------------------------------------------------------------------
docs/user-manual/en/SUMMARY.md | 2 +-
docs/user-manual/en/dependency-injection.adoc | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/0a70406d/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index cf1ef2d..1b3d94c 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -15,6 +15,7 @@
* [CamelContext](camelcontext.adoc)
* [Debugger](debugger.adoc)
* [Delay Interceptor](delay-interceptor.adoc)
+ * [Dependency Injection](dependency-injections.adoc)
* [Dozer Type Conversion](dozer-type-conversion.adoc)
* [Endpoint](endpoint.adoc)
* [Exchange](exchange.adoc)
@@ -27,7 +28,6 @@
<!--
* [AOP](aop.adoc)
* [Camel-Core](camel-core.adoc)
- * [Dependency Injection](dependency-injections.adoc)
* [DSL](dsl.adoc)
* [Error Handler](.adoc)
* [Expression](.adoc)
http://git-wip-us.apache.org/repos/asf/camel/blob/0a70406d/docs/user-manual/en/dependency-injection.adoc
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/dependency-injection.adoc b/docs/user-manual/en/dependency-injection.adoc
new file mode 100644
index 0000000..4769a54
--- /dev/null
+++ b/docs/user-manual/en/dependency-injection.adoc
@@ -0,0 +1,17 @@
+[[DependencyInjection-DependencyInjection]]
+Dependency Injection
+~~~~~~~~~~~~~~~~~~~~
+
+_Dependency Injection_ or _Inversion of Control_ is a pattern where
+dependencies of an object are injected into the object without the
+object being too aware of how the injection is performed. The two most
+popular Dependency Injection libraries available at the time of writing
+are
+
+* link:spring.html[Spring]
+* link:guice.html[Guice]
+* link:cdi.html[CDI]
+
+Camel is developed such that any Dependency Injection framework can be
+used easily - though we've tried hard to optimise Camel for both
+link:spring.html[Spring],link:cdi.html[CDI] and link:guice.html[Guice]