camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Groovy Renderer User Guide
Date Sat, 18 Jul 2009 05:19:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CAMEL&amp;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> are supported
currently.</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 language to update it. A <a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Groovy+Renderer&amp;linkCreation=true&amp;fromPageId=2326785"
class="createlink">Groovy Renderer</a> 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">&lt;?xml
version="1.0" encoding="UTF-8" standalone="yes"?&gt;
&lt;route id="route1" xmlns:ns2="http://camel.apache.org/schema/web" xmlns="http://camel.apache.org/schema/spring"&gt;
    &lt;description&gt;This is an example route which you can start, stop and modify&lt;/description&gt;
    &lt;from uri="seda:foo"/&gt;
    &lt;to uri="mock:results" id="to1"/&gt;
&lt;/route&gt;</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 GroovyRenderer 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 we can update the route by input new DSL into the configure method. For example,
we 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">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 the route will deliver the following messages by parsing its header.
</p>
<h3><a name="GroovyRendererUserGuide-GuideformoreDSLs"></a>Guide for more
DSLs</h3>
<p>Though all kinds of DSLs can be accepted to create routes, but groovy renderer can't
render every details of the routes when opening them. <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 DSL. Following is a list showing which DSLs are fully supported and which can't
be.</p>
<h4><a name="GroovyRendererUserGuide-SupportedDSLs"></a>Supported DSLs</h4>

<h4><a name="GroovyRendererUserGuide-UnsupportedDSLs"></a>Un-supported DSLs</h4>
     </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=4&originalVersion=3">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/CAMEL/Groovy+Renderer+User+Guide?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message