Author: buildbot
Date: Thu Dec 20 21:18:10 2012
New Revision: 843275
Log:
Production update by buildbot for camel
Modified:
websites/production/camel/content/cache/main.pageCache
websites/production/camel/content/groovy-dsl.html
Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.
Modified: websites/production/camel/content/groovy-dsl.html
==============================================================================
--- websites/production/camel/content/groovy-dsl.html (original)
+++ websites/production/camel/content/groovy-dsl.html Thu Dec 20 21:18:10 2012
@@ -77,18 +77,49 @@
<td valign="top" width="100%">
<div class="wiki-content maincontent"><h3><a shape="rect"
name="GroovyDSL-AbouttheGroovyDSL"></a>About the Groovy DSL</h3>
-<p>The Groovy DSL implementation is built on top of the existing Java-based <a
shape="rect" href="dsl.html" title="DSL">DSL</a>, but it additionally allows to
use Groovy language features in your routes, particularly <a shape="rect"
class="external-link" href="http://groovy.codehaus.org/Closures"
rel="nofollow">Closures</a> acting as <a shape="rect" href="processor.html"
title="Processor">processor</a>, <a shape="rect" href="expression.html"
title="Expression">expression</a>, <a shape="rect" href="predicate.html"
title="Predicate">predicate</a>, or <a shape="rect" href="aggregator.html"
title="Aggregator">aggregation strategy</a>.<br clear="none">
+<p>The Groovy DSL implementation is built on top of the existing Java-based <a
shape="rect" href="dsl.html" title="DSL">DSL</a>, but it additionally allows to
use Groovy language features in your routes, particularly <a shape="rect"
class="external-link" href="http://groovy.codehaus.org/Closures"
rel="nofollow">Closures</a> acting as <a shape="rect" href="processor.html"
title="Processor">Processor</a>, <a shape="rect" href="expression.html"
title="Expression">Expression</a>, <a shape="rect" href="predicate.html"
title="Predicate">Predicate</a>, or <a shape="rect" href="aggregator.html"
title="Aggregator">Aggregation Strategy</a>.<br clear="none">
With the Groovy DSL you write your RouteBuilder classes entirely in Groovy,
while the <a shape="rect" href="scripting-languages.html" title="Scripting
Languages">scripting component</a> allows to embed small scripts into Java
routes. The Groovy DSL requires Groovy 2.0 or newer and is available as of
<b>Camel 2.11</b>.</p>
-<h3><a shape="rect" name="GroovyDSL-Overview"></a>Overview</h3>
+<h3><a shape="rect" name="GroovyDSL-Introduction"></a>Introduction</h3>
-<p>TODO</p>
+<p>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
<a shape="rect" class="external-link"
href="http://docs.codehaus.org/display/GROOVY/Creating+an+extension+module"
rel="nofollow">Extension Module</a> that defines extension methods on existing
classes.</p>
+
+<p>The majority of the extension methods allow <a shape="rect"
class="external-link" href="http://groovy.codehaus.org/Closures"
rel="nofollow">Closures</a> 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: </p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width:
1px;"><b>MyRouteBuilder.groovy</b></div><div class="codeContent panelContent">
+<pre class="code-java">
+...
+ from('direct:test')
+ .transform { it.in.body.reverse() }
+ .process { println it.in.body }
+...
+</pre>
+</div></div>
+
+<p>The corresponding route in Java would look something like this:</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width:
1px;"><b>MyRouteBuilder.java</b></div><div class="codeContent panelContent">
+<pre class="code-java">
+...
+ from(<span class="code-quote">"direct:test"</span>)
+ .transform(<span class="code-keyword">new</span> Expression() {
+ @Override
+ <span class="code-keyword">public</span> <span
class="code-object">Object</span> evaluate(Exchange e) {
+ <span class="code-keyword">return</span> <span
class="code-keyword">new</span> <span
class="code-object">StringBuffer</span>(e.getIn().getBody().toString()).reverse().toString();
+ }
+ })
+ .process(<span class="code-keyword">new</span> Processor() {
+ @Override
+ <span class="code-keyword">public</span> void process(Exchange e) {
+ <span
class="code-object">System</span>.out.println(e.getIn().getBody());
+ }
+ });
+...
+</pre>
+</div></div>
-<h4><a shape="rect" name="GroovyDSL-UsingClosures"></a>Using Closures</h4>
-<h4><a shape="rect" name="GroovyDSL-UsingGroovyXMLprocessing"></a>Using Groovy
XML processing</h4>
-<h4><a shape="rect" name="GroovyDSL-CustomDSLextensions"></a>Custom DSL
extensions</h4>
<h3><a shape="rect" name="GroovyDSL-DevelopingwiththeGroovyDSL"></a>Developing
with the Groovy DSL</h3>
@@ -144,7 +175,24 @@ With the Groovy DSL you write your Route
<span class="code-tag"></configuration></span>
<span class="code-tag"></plugin></span>
</pre>
-</div></div></div>
+</div></div>
+
+<h4><a shape="rect" name="GroovyDSL-UsingClosuresinyourroutes"></a>Using
Closures in your routes</h4>
+
+<h4><a shape="rect" name="GroovyDSL-UsingGroovyXMLprocessing"></a>Using Groovy
XML processing</h4>
+
+<h4><a shape="rect" name="GroovyDSL-UsingGroovyGStrings"></a>Using Groovy
GStrings</h4>
+
+<p>Groovy <a shape="rect" class="external-link"
href="http://groovy.codehaus.org/Strings+and+GString"
rel="nofollow">GStrings</a> are declared inside double-quotes and can contain
arbitrary Groovy expressions like accessing properties or calling methods, e.g.
</p>
+<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<pre class="code-java">
+def x = <span class="code-quote">"It is currently ${ <span
class="code-keyword">new</span> Date() }"</span>
+</pre>
+</div></div>
+<p>Because GStrings aren't Strings, camel-groovy adds the necessary <a
shape="rect" href="type-converter.html" title="Type
Converter">TypeConverter</a> to automatically turn them into the required
type.</p>
+
+
+<h4><a shape="rect" name="GroovyDSL-CustomDSLextensions"></a>Custom DSL
extensions</h4></div>
</td>
<td valign="top">
<div class="navigation">