camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Scala DSL - Supported languages
Date Sat, 14 Apr 2012 07:19:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/Scala+DSL+-+Supported+languages">Scala
DSL - Supported languages</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
        <br/>
                         <h4>Changes (3)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-changed-lines" >Support for <span class="diff-changed-words"><span
class="diff-added-chars"style="background-color: #dfd;">[</span>other languages<span
class="diff-added-chars"style="background-color: #dfd;">|Languages]</span></span>
inside Scala DSL routes is delivered through traits.  The {{org.apache.camel.scala.dsl.languages}}
package currently offers traits to support XPath.  To use any given language, you can mix-in
the trait when creating your <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">{{RouteBuilder}}
like this:</span> <span class="diff-added-words"style="background-color: #dfd;">{{RouteBuilder}}.</span>
<br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">{snippet:id=xpath|lang=java|url=camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/SplitterRouteBuilderTest.scala}
<br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">You
can use any of the support Camel [Languages] in the [Scala DSL], below is a couple of examples:
<br> <br></td></tr>
            <tr><td class="diff-unchanged" >h4. Using [XPath] <br>With the
XPath trait, you have an additional method available on an {{Exchange}} to do XPath queries
against the message.  Just look at this Splitter example, where the {{xpath}} method is used
in a {{Exchange &amp;rArr; Any*}} function literal <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>Support for <a href="/confluence/display/CAMEL/Languages" title="Languages">other
languages</a> inside Scala DSL routes is delivered through traits.  The <tt>org.apache.camel.scala.dsl.languages</tt>
package currently offers traits to support XPath.  To use any given language, you can mix-in
the trait when creating your <tt>RouteBuilder</tt>.</p>

<p>You can use any of the support Camel <a href="/confluence/display/CAMEL/Languages"
title="Languages">Languages</a> in the <a href="/confluence/display/CAMEL/Scala+DSL"
title="Scala DSL">Scala DSL</a>, below is a couple of examples:</p>

<h4><a name="ScalaDSL-Supportedlanguages-UsingXPath"></a>Using <a href="/confluence/display/CAMEL/XPath"
title="XPath">XPath</a></h4>
<p>With the XPath trait, you have an additional method available on an <tt>Exchange</tt>
to do XPath queries against the message.  Just look at this Splitter example, where the <tt>xpath</tt>
method is used in a <tt>Exchange &rArr; Any*</tt> function literal</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java"><span class="code-quote">"direct:b"</span> ==&gt;
{
  as(classOf[Document])
  split(xpath(<span class="code-quote">"/persons/person"</span>)) {
    to(<span class="code-quote">"mock:b"</span>)
    to(<span class="code-quote">"mock:c"</span>)
  }
}
</pre>
</div></div>

<h4><a name="ScalaDSL-Supportedlanguages-UsingJXPath"></a>Using <a href="/confluence/display/CAMEL/JXPath"
title="JXPath">JXPath</a></h4>
<p>With the <tt>org.apache.camel.scala.dsl.languages.JXPath</tt> trait,
you can an additional <tt>jxpath</tt> method on the <tt>Exchange</tt>.
 In the Recipient List example below, JXPath is used for getting the next endpoint's name
out of the message body.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java"><span class="code-quote">"direct:c"</span> ==&gt;
{
  to(<span class="code-quote">"mock:c"</span>)
  recipients(jxpath(<span class="code-quote">"./in/body/destination"</span>))
}
</pre>
</div></div>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Scala+DSL+-+Supported+languages">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=83962&revisedVersion=5&originalVersion=4">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Scala+DSL+-+Supported+languages?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message