camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Expression
Date Mon, 07 Jan 2013 13:16: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/Expression">Expression</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
        <br/>
                         <h4>Changes (4)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-unchanged" >h2. Expressions <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Expressions
and [Predicates|Predicate] can then be used to create the various [Enterprise Integration
Patterns|Enterprise Integration Patterns] in the [DSL] or [Xml Configuration] like the [Recipient
List]. <br></td></tr>
            <tr><td class="diff-unchanged" >To support dynamic rules Camel supports
pluggable [Expression|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Expression.html]
strategies using a variety of different [Languages]. <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Expressions
and [Predicates|Predicate] can then be used to create the various [Enterprise Integration
Patterns|Enterprise Integration Patterns] in the [DSL] or [Xml Configuration] like the [Recipient
List]. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h3.
API <br></td></tr>
            <tr><td class="diff-unchanged" > <br>If you are outside of the
[DSL] and want to create your own expressions you can either implement the [Expression interface|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Expression.html],
reuse one of the other builders or try the [ExpressionBuilder class|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/builder/ExpressionBuilder.html].
<br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h4.
Expression <br> <br>The API for a Camel Expression is defined in the {{org.apache.camel.Expression}}
interface as shown: <br>{code} <br>public interface Expression { <br> <br>
   /** <br>     * Returns the value of the expression on the given exchange <br>
    * <br>     * @param exchange the message exchange on which to evaluate the expression
<br>     * @param type the expected type of the evaluation result <br>     * @return
the value of the expression <br>     */ <br>    &lt;T&gt; T evaluate(Exchange
exchange, Class&lt;T&gt; type); <br>} <br>{code} <br> <br>h4.
Predicate <br>The API for a Camel Predicate is defined in the {{org.apache.camel.Predicate}}
interface as shown: <br>{code} <br>public interface Predicate { <br> <br>
   /** <br>     * Evaluates the predicate on the message exchange and returns true if
this <br>     * exchange matches the predicate <br>     *  <br>     * @param
exchange the message exchange <br>     * @return true if the predicate matches <br>
    */ <br>    boolean matches(Exchange exchange); <br> <br>} <br>{code}
<br> <br> <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h3. Expression Languages <br>The
following languages are supported out of the box <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="Expression-Expressions"></a>Expressions</h2>

<p>Expressions and <a href="/confluence/display/CAMEL/Predicate" title="Predicate">Predicates</a>
can then be used to create the various <a href="/confluence/display/CAMEL/Enterprise+Integration+Patterns"
title="Enterprise Integration Patterns">Enterprise Integration Patterns</a> in the
<a href="/confluence/display/CAMEL/DSL" title="DSL">DSL</a> or <a href="/confluence/display/CAMEL/Xml+Configuration"
title="Xml Configuration">Xml Configuration</a> like the <a href="/confluence/display/CAMEL/Recipient+List"
title="Recipient List">Recipient List</a>.<br/>
To support dynamic rules Camel supports pluggable <a href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Expression.html"
class="external-link" rel="nofollow">Expression</a> strategies using a variety of
different <a href="/confluence/display/CAMEL/Languages" title="Languages">Languages</a>.</p>

<h3><a name="Expression-API"></a>API</h3>

<p>If you are outside of the <a href="/confluence/display/CAMEL/DSL" title="DSL">DSL</a>
and want to create your own expressions you can either implement the <a href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Expression.html"
class="external-link" rel="nofollow">Expression interface</a>, reuse one of the other
builders or try the <a href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/builder/ExpressionBuilder.html"
class="external-link" rel="nofollow">ExpressionBuilder class</a>.</p>

<h4><a name="Expression-Expression"></a>Expression</h4>

<p>The API for a Camel Expression is defined in the <tt>org.apache.camel.Expression</tt>
interface as shown:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">public</span> <span class="code-keyword">interface</span>
Expression {

    /**
     * Returns the value of the expression on the given exchange
     *
     * @param exchange the message exchange on which to evaluate the expression
     * @param type the expected type of the evaluation result
     * @<span class="code-keyword">return</span> the value of the expression
     */
    &lt;T&gt; T evaluate(Exchange exchange, <span class="code-object">Class</span>&lt;T&gt;
type);
}
</pre>
</div></div>

<h4><a name="Expression-Predicate"></a>Predicate</h4>
<p>The API for a Camel Predicate is defined in the <tt>org.apache.camel.Predicate</tt>
interface as shown:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">public</span> <span class="code-keyword">interface</span>
Predicate {

    /**
     * Evaluates the predicate on the message exchange and returns <span class="code-keyword">true</span>
<span class="code-keyword">if</span> <span class="code-keyword">this</span>
     * exchange matches the predicate
     * 
     * @param exchange the message exchange
     * @<span class="code-keyword">return</span> <span class="code-keyword">true</span>
<span class="code-keyword">if</span> the predicate matches
     */
    <span class="code-object">boolean</span> matches(Exchange exchange);

}
</pre>
</div></div>



<h3><a name="Expression-ExpressionLanguages"></a>Expression Languages</h3>
<p>The following languages are supported out of the box</p>
<ul>
	<li><a href="/confluence/display/CAMEL/Bean+Language" title="Bean Language">Bean
Language</a> for using Java for expressions</li>
	<li><a href="/confluence/display/CAMEL/Constant" title="Constant">Constant</a></li>
	<li>the unified <a href="/confluence/display/CAMEL/EL" title="EL">EL</a>
from JSP and JSF</li>
	<li><a href="/confluence/display/CAMEL/Header" title="Header">Header</a></li>
	<li><a href="/confluence/display/CAMEL/JXPath" title="JXPath">JXPath</a></li>
	<li><a href="/confluence/display/CAMEL/Mvel" title="Mvel">Mvel</a></li>
	<li><a href="/confluence/display/CAMEL/OGNL" title="OGNL">OGNL</a></li>
	<li><a href="/confluence/display/CAMEL/Ref+Language" title="Ref Language">Ref
Language</a></li>
	<li><a href="/confluence/display/CAMEL/Property" title="Property">Property</a></li>
	<li><a href="/confluence/display/CAMEL/Scripting+Languages" title="Scripting Languages">Scripting
Languages</a> such as
	<ul>
		<li><a href="/confluence/display/CAMEL/BeanShell" title="BeanShell">BeanShell</a></li>
		<li><a href="/confluence/display/CAMEL/JavaScript" title="JavaScript">JavaScript</a></li>
		<li><a href="/confluence/display/CAMEL/Groovy" title="Groovy">Groovy</a></li>
		<li><a href="/confluence/display/CAMEL/Python" title="Python">Python</a></li>
		<li><a href="/confluence/display/CAMEL/PHP" title="PHP">PHP</a></li>
		<li><a href="/confluence/display/CAMEL/Ruby" title="Ruby">Ruby</a></li>
	</ul>
	</li>
	<li><a href="/confluence/display/CAMEL/Simple" title="Simple">Simple</a>
	<ul>
		<li><a href="/confluence/display/CAMEL/File+Language" title="File Language">File
Language</a></li>
	</ul>
	</li>
	<li><a href="/confluence/display/CAMEL/SpEL" title="SpEL">Spring Expression Language</a></li>
	<li><a href="/confluence/display/CAMEL/SQL" title="SQL">SQL</a></li>
	<li><a href="/confluence/display/CAMEL/Tokenizer" title="Tokenizer">Tokenizer</a></li>
	<li><a href="/confluence/display/CAMEL/XPath" title="XPath">XPath</a></li>
	<li><a href="/confluence/display/CAMEL/XQuery" title="XQuery">XQuery</a></li>
	<li><a href="/confluence/display/CAMEL/VTD-XML" title="VTD-XML">VTD&#45;XML</a></li>
</ul>


<p>Most of these languages is also supported used as <a href="/confluence/display/CAMEL/Annotation+Based+Expression+Language"
title="Annotation Based Expression Language">Annotation Based Expression Language</a>.</p>


<h3><a name="Expression-UsingExpressionsinyourIDE"></a>Using Expressions
in your IDE</h3>
<p>To use different expression and predicates in your IDE you need to perform a static
import of the builder class for the language(s) you wish to use.</p>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Language(s) </th>
<th class='confluenceTh'> Builder class to import </th>
</tr>
<tr>
<td class='confluenceTd'> <a href="/confluence/display/CAMEL/Scripting+Languages"
title="Scripting Languages">Scripting Languages</a> such as <a href="/confluence/display/CAMEL/BeanShell"
title="BeanShell">BeanShell</a>, <a href="/confluence/display/CAMEL/JavaScript"
title="JavaScript">JavaScript</a>, <a href="/confluence/display/CAMEL/Groovy"
title="Groovy">Groovy</a>, <a href="/confluence/display/CAMEL/PHP" title="PHP">PHP</a>,
<a href="/confluence/display/CAMEL/Python" title="Python">Python</a> and <a
href="/confluence/display/CAMEL/Ruby" title="Ruby">Ruby</a> </td>
<td class='confluenceTd'>  <a href="http://camel.apache.org/maven/current/camel-script/apidocs/org/apache/camel/builder/script/ScriptBuilder.html"
class="external-link" rel="nofollow">org.apache.camel.builder.script.ScriptBuilder</a>
</td>
</tr>
<tr>
<td class='confluenceTd'> <a href="/confluence/display/CAMEL/SQL" title="SQL">SQL</a>
</td>
<td class='confluenceTd'> <a href="http://camel.apache.org/maven/current/camel-josql/apidocs/org/apache/camel/builder/sql/SqlBuilder.html"
class="external-link" rel="nofollow">org.apache.camel.builder.josql.SqlBuilder</a>
</td>
</tr>
<tr>
<td class='confluenceTd'> <a href="/confluence/display/CAMEL/XPath" title="XPath">XPath</a>
</td>
<td class='confluenceTd'> <a href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/builder/xml/XPathBuilder.html"
class="external-link" rel="nofollow">org.apache.camel.builder.xml.XPathBuilder</a>
</td>
</tr>
<tr>
<td class='confluenceTd'> <a href="/confluence/display/CAMEL/XQuery" title="XQuery">XQuery</a>
</td>
<td class='confluenceTd'> <a href="http://camel.apache.org/maven/current/camel-saxon/apidocs/org/apache/camel/builder/saxon/XQueryBuilder.html"
class="external-link" rel="nofollow">org.apache.camel.builder.saxon.XQueryBuilder</a>
</td>
</tr>
</tbody></table>
</div>






<h4><a name="Expression-SeeAlso"></a>See Also</h4>
<ul class="alternate" type="square">
	<li><a href="/confluence/display/CAMEL/Predicate" title="Predicate">Predicate</a></li>
</ul>

    </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/Expression">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=49332&revisedVersion=10&originalVersion=9">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Expression?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message