2. Standard Filters
• Mule includes the following standard filters that you can apply to your routers:
• Payload Type Filter
Expression Filter
• Using XPath Expressions
• Using JXPath Expressions
• Using OGNL Expressions
• RegEx Filter
• Wildcard Filter
• Exception Type Filter
• Message Property Filter
Logic Filters
• And Filter
• Or Filter
• Not Filter
3. Payload Type Filter
• Checks the class type of the payload object
inside a message.
• Example:
<payload-type-filter
expectedType="java.lang.String"/>
4. Expression Filter
• Evaluates a range of expressions. Use
the evaluator attribute to specify
the expression evaluator to use, one of the
following: header, payload-type, exception-
type, wildcard, regex, ognl, xpath, jxpath,
bean, groovy, or custom. Use
the expression attribute to set the actual
expression. If the expression type
is xpath, bean, or ognl, the expression should
be a boolean
5. Using XPath Expressions
• XPath expressions are supported using the
standard XPath query language. It is based on
JAXP, the Java API for XML processing. You can
learn more about writing XPath queries from
the XPath tutorial.
Example:
<expression-filter evaluator="xpath"
expression="(msg/header/resultcode)='succes
s'"/>
6. Using JXPath Expressions
• JXPath is an XPath interpreter that can apply
XPath expressions to graphs of objects of all
kinds: JavaBeans, Maps, Servlet contexts, DOM
etc, including mixtures thereof. For more
information about JXPath, see the JXpath user
guide. For querying XML, it is recommended to
use XPath expressions instead.
• <expression-filter evaluator="jxpath"
expression="(msg/header/resultcode)='success'"
/>
7. Using OGNL Expressions
• OGNL is a simple yet very powerful expression
language for plain Java objects. Similar to JXPath,
it works on object graphs, and thus the
corresponding filter enables simple and efficient
content routing for payloads. For example:
• <expression-filter evaluator="ognl"
expression="[MULE:0].equals(42)"/>
• or more simply:
• <ognl-filter expression="[MULE:0].equals(42)"/>