<html>
<head>
<base href="http://cwiki.apache.org/confluence">
<link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CAMEL&forWysiwyg=true"
type="text/css">
</head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
<h2><a href="http://cwiki.apache.org/confluence/display/CAMEL/Groovy+Renderer+User+Guide">Groovy
Renderer User Guide</a></h2>
<h4>Page <b>edited</b> by <a href="http://cwiki.apache.org/confluence/display/~xueqiang.mi">Xueqiang
Mi</a>
</h4>
<br/>
<div class="notificationGreySide">
<h2><a name="GroovyRendererUserGuide-GroovyRendererUserGuide"></a>Groovy
Renderer User Guide</h2>
<p>This page presents how to editing the route definition in groovy language through
the <a href="/confluence/display/CAMEL/Web+Console" title="Web Console">Web Console</a>
and which <a href="/confluence/display/CAMEL/DSL" title="DSL">DSLs</a> have beensupported
currently.</p>
<h3><a name="GroovyRendererUserGuide-WhatisGroovyRenderer"></a>What is Groovy
Renderer</h3>
<p>Groovy Renderer is a component, which can translate a route instance in <a href="/confluence/display/CAMEL/CamelContext"
title="CamelContext">CamelContext</a> into a route builder in groovy language. By
using it, <a href="/confluence/display/CAMEL/Web+Console" title="Web Console">Web Console</a>
allows developers disliking prolix XML to edit or update a route using groovy.</p>
<h3><a name="GroovyRendererUserGuide-GettingStarted"></a>Getting Started</h3>
<p>Through <a href="/confluence/display/CAMEL/Web+Console" title="Web Console">Web
Console</a>, you can review every route in the <a href="/confluence/display/CAMEL/CamelContext"
title="CamelContext">CamelContext</a>. After opening a route in your browser, the
URL may be <a href="http://localhost:8080/routes/route1" rel="nofollow">http://localhost:8080/routes/route1</a>,
you can choose the edit link with groovy to update it. A groovy renderer will turn the route
into groovy route definition. For example, after chooseing to edit a route defined by the
following XML:</p>
<style type="text/css">
@import url(/confluence/download/resources/confluence.ext.code:code/shStyles.css);
</style>
<!--[if IE]>
<style type="text/css">
.code textarea, .code input { padding: 0 !important; }
</style>
<![endif]-->
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shCore.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushCSharp.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushPhp.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushJScript.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushVb.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushSql.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushXml.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushShell.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushDelphi.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushPython.js"></script>
<script class="javascript" src="/confluence/download/resources/confluence.ext.code:code/shBrushJava.js"></script>
<div class="code">
<textarea name="newcodemacro" class="xml:nocontrols:nogutter" rows="10" readonly="readonly"><?xml
version="1.0" encoding="UTF-8" standalone="yes"?>
<route id="route1" xmlns:ns2="http://camel.apache.org/schema/web" xmlns="http://camel.apache.org/schema/spring">
<description>This is an example route which you can start, stop and modify</description>
<from uri="seda:foo"/>
<to uri="mock:results" id="to1"/>
</route></textarea>
<script class="javascript">
if(!window.newcodemacro_initialised)
{
window.newcodemacro_initialised = true;
window.oldonloadmethod = window.onload;
window.onload = function(){
dp.SyntaxHighlighter.HighlightAll('newcodemacro');
if(window.oldonloadmethod)
{
window.oldonloadmethod();
}
}
}
</script>
</div>
<p>The groovy renderer will translate it into a route definition as follows:</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">import
org.apache.camel.language.groovy.GroovyRouteBuilder;
class GroovyRoute extends GroovyRouteBuilder {
void configure() {
from("seda:foo").to("mock:results")
}
}</textarea>
<script class="javascript">
if(!window.newcodemacro_initialised)
{
window.newcodemacro_initialised = true;
window.oldonloadmethod = window.onload;
window.onload = function(){
dp.SyntaxHighlighter.HighlightAll('newcodemacro');
if(window.oldonloadmethod)
{
window.oldonloadmethod();
}
}
}
</script>
</div>
<p>Then you can update the route by input DSLs into the configure method. For example,
you can change it into a <a href="/confluence/display/CAMEL/Content+Based+Router" title="Content
Based Router">Content Based Router</a> by updating it as follows.</p>
<div class="code">
<textarea name="newcodemacro" class="java:nocontrols:nogutter" rows="10" readonly="readonly">import
org.apache.camel.language.groovy.GroovyRouteBuilder;
class GroovyRoute extends GroovyRouteBuilder {
void configure() {
from("seda:a").choice().when(header("foo").isEqualTo("bar")).to("seda:b")
.when(header("foo").isEqualTo("cheese")).to("seda:c").otherwise().to("seda:d")
}
}</textarea>
<script class="javascript">
if(!window.newcodemacro_initialised)
{
window.newcodemacro_initialised = true;
window.oldonloadmethod = window.onload;
window.onload = function(){
dp.SyntaxHighlighter.HighlightAll('newcodemacro');
if(window.oldonloadmethod)
{
window.oldonloadmethod();
}
}
}
</script>
</div>
<p>Save it and then the route will deliver the following messages by parsing its header.</p>
<h3><a name="GroovyRendererUserGuide-GuideformoreDSLsDSL"></a>Guide for
more <a href="/confluence/display/CAMEL/DSL" title="DSL">DSLs</a></h3>
<p> <a href="/confluence/display/CAMEL/Web+Console" title="Web Console">Web Console</a>
focuses on providing a editor for developers to update a route at runtime, but won't try to
provide a development environment with full support of DSLs. Groovy renderer can't render
every details of the DSLs when opening a route though all of the DSLs can be accepted when
creating it. Following is a list showing which DSLs are fully supported and which are not.</p>
<h4><a name="GroovyRendererUserGuide-SupportedDSLs"></a>Supported DSLs</h4>
<ul>
<li>aggregate</li>
<li>choice</li>
<li>convertBody</li>
<li>deadLetter</li>
<li>delay</li>
<li>enrich</li>
<li>filter</li>
<li>from</li>
<li>loadBalance</li>
<li>loop</li>
<li>marshal</li>
<li>pipeline</li>
<li>recipientList</li>
<li>routeSlip</li>
<li>setBody</li>
<li>sort</li>
<li>throttle</li>
<li>to</li>
<li>transform</li>
<li>wireTap</li>
<li>xPath</li>
</ul>
<h4><a name="GroovyRendererUserGuide-UnsupportedDSLs"></a>Un-supported DSLs</h4>
<ul>
<li>bean</li>
<li>process</li>
</ul>
</div>
<div id="commentsSection" class="wiki-content pageSection">
<div style="float: right;">
<a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
</div>
<a href="http://cwiki.apache.org/confluence/display/CAMEL/Groovy+Renderer+User+Guide">View
Online</a>
|
<a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=2326785&revisedVersion=10&originalVersion=9">View
Change</a>
|
<a href="http://cwiki.apache.org/confluence/display/CAMEL/Groovy+Renderer+User+Guide?showComments=true&showCommentArea=true#addcomment">Add
Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
|